Handling of complex numbers in J is at a variance with what is done in other languages.
APL: (at https://tryapl.org/ ) 1 ○ 1J1e¯100 0.8414709848J5.403023059E¯101 Guile: scheme@(guile-user)> (sin 1+1d-100i) $1 = 0.8414709848078965+5.4030230586813975e-101i scheme@(guile-user)> Julia: julia> sin(1+1e-100im) 0.8414709848078965 + 5.4030230586813975e-101im Octave: >> format longg >> sin(1+1e-100i) ans = 0.8414709848078965 + 5.403023058681397e-101i >> Python: >>> import cmath >>> cmath.sin(1+1e-100j) (0.8414709848078965+5.4030230586813975e-101j) >>> J: (J805) 1 o. 1j1e_100 0.841471 +. 1 o. 1j1e_100 0.841471 0 +. (1&o.t.i.20) p. 1j1e_100 0.841471 5.40302e_101 There is a pretty trick to compute the derivative f'(x) of a complex analytic function f(x) on the real axis by using a complex difference quotient with an imaginary increment less than eps=2^-52: f'(x) \approx (f(x+1e-100i)-f(x-1e-100i))/2e-100i This method can be surprisingly accurate. Here is an example in Octave. >> D=@(f)@(x)(f(x+1e-100i)-f(x-1e-100i))/2e-100i ; >> f=D(@sin) ; >> x=linspace(-10,10,1e6) ; norm(f(x)-cos(x),"inf") ans = 1.1102e-16 Can you tell me why J does not do the same thing with complex arithmetic as almost any other language (including surprisingly APL)? Yours sincerely, Imre Patyi ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
