What are the rules required to re-format a verb to make it processable by N?

The original equation:
(2^x) - 2^2*x = _8

The reformatted equation:
 (8: + (2&^) - (2&^)@(2&*))

Why the colon?

Why the @ sign?

Why the ampersand?

Why not make a monadic verb?:

v =: 3 : '8 + (2^y) - (2^2*y)'
vv =: (8: + (2&^) - (2&^)@(2&*))

  v 1

6


  vv 1

6


NB. Both verbs are the same, but:


    v N (^:20) 1

|domain error

| v N(^:20)1


   vv N (^:20) 1

1.75372


??


Skip Cave
Cave Consulting LLC

On Mon, Jan 29, 2018 at 3:12 AM, Rob Hodgkinson <[email protected]> wrote:

> Minor correction Raul (- instead of +) ?
> ...   use (8: + (2&^) - (2&^)@(2&*))
>
> So Skip, just to clarify to see this solution put through Newton-Raphson;
>
> 1)  Create the Newton-Raphson adverb as you stated earlier;
>
> ​​
> N=: 1 : '- u % u d. 1’
>
> 2)  Apply for a number of iterations using ^: and give it an initial value
> of 1  …   fn N (^:iterations) start-value
>
> ​​
> ​​
> (8: + (2&^) - (2&^)@(2&*))N (^:20) 1
> 1.75372
>
>    9!:11]14  NB. or increase print precision
>    (8: + (2&^) - (2&^)@(2&*))N (^:20) 1
> 1.7537248941553
>
> Hope that clarifies things, as without the function appropriately defined
> as Raul described, N returns a Domain Error if it can’t work with the
> function.
>
> Rob
>
> > On 29 Jan 2018, at 7:57 pm, Raul Miller <[email protected]> wrote:
> >
> > d. 1 wants to be able to use the chain rule for 2^2*x, and it seems
> > like the implementation was from an early version of J, and has not
> > kept up with all the more recent changes. So, you should put that
> > changed term into an f@g form.
> >
> > In other words, use (8: + (2&^) + (2&^)@(2&*))
> >
> > Thanks,
> >
> > --
> > Raul
> >
> >
> > On Mon, Jan 29, 2018 at 1:46 AM, Skip Cave <[email protected]>
> wrote:
> >> I see what I did wrong.
> >>
> >> The equation is:  8 + (2^x) - 2^2*x = 0
> >>
> >> The  third term is (2^2*x) not (2^2^x)
> >>
> >> That should get close to the answer x=1.75372
> >>
> >> I'm mostly interested in how to formulate the code to implement the
> Newton
> >> Raphson solution
> >> using
> >>
> >> N=: 1 : '- u % u d. 1'
> >>
> >> In the NR code, where does the equation verb go?
> >> How does it need to be structured? Where does the iteration count limit
> go?
> >>
> >> Skip
> >>
> >>
> >>
> >>
> >> Skip Cave
> >> Cave Consulting LLC
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to