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