NB. I stumbled across this trying to help my daughter with her
NB. homework of finding a zero for the following function.  I attempted to
NB. cheat by graphing it but was puzzled by what I got until I realized
NB. that, applied to negatives, this function returns complex numbers and
NB. the plot package treats these as 2-D point pairs.
NB. I actually solved it for one root by inspection.

  ff=: 13 : '((3*y.^%2)-(5*y.^%4))-2'
  ff2=: 13 : '((3*%:y.)-5*%:%:y.)-2'
  NB. These should be the same but there's a tiny precision difference

  (ff-:ff2)i:16j1000    NB. Not the same over this domain
0
  (ff,ff2) _16          NB. Negative arguments give complex results
_9.0710678j4.9289322 _9.0710678j4.9289322

  >./"1 | 9 11 o./ (ff-ff2)i:16j1000  NB. So compare real and imaginary
parts
1.7763568e_15 2.6645353e_15            NB.  separately->tiny differences...

  plot (ff-ff2) i: 16j1000            NB. Gives an interesting pattern.


--
Devon McCormick
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to