A rule I was working with was that if the individual terms were
differentiable, then their sums would be differentiable.

This turns out to be slightly more rigorous than what's actually required:

   8: d. 1
0"0
   8 d. 1
|nonce error

but

   (8 + ]) d. 1
1x"0

In other words, 8: is a verb that d. 1 can handle directly, but if 8
is a term in a larger verb it would still be handled correctly. (A
"term" here is something which is added to something else.
https://www.mathsisfun.com/definitions/term.html )

Other than that, though, it looks like most of the definition of d.
was implemented based on tacit J from the early days (before hooks and
forks):

   2&^ d. 1
0.693147180559945286&*@(2&^)
   (2 ^ ]) d. 1
|domain error

So & gets used -- because d. seems to have a good idea of how to deal with it.

And I used @ because I wanted d. to use the chain rule (and when I
looked up the chain rule, I saw math expressions that looked like @
expressions).

Basically... although d. offers some significant capabilities, it
probably still helps to refer to math texts on differentiation when
trying to figure out how to use it.

That said - if your verb is made out of differentiable things which
are combined with + * and/or @ then the result should be
differentiable, since there's well known rules about how to
differentiate those kinds of things. ("Differentiate" here means using
d. 1 but it should also mean using D. 1)

Thanks,

-- 
Raul


On Mon, Jan 29, 2018 at 12:15 PM, Skip Cave <[email protected]> wrote:
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to