Post Reply 
Error with exp function and imaginary numbers
07-28-2020, 07:10 PM
Post: #7
RE: Error with exp function and imaginary numbers
The question is another. I wrote a program that calculates the "Bessel function of the first kind Jn (z)", with n ∈ R and "z" ∈ C and with Arg (z <Pi / 2). Below the program:

#cas
//BesselJ_Gen(n,z) Jn(z) n∈ℝ z∈ℂ
//φ, ARG(z), di z < π/2
BesselJ_Gen(n,z):=
BEGIN
LOCAL funzione;
IF ARG(z)<π/2 THEN
funzione:=1/π*int(cos(z*sin(t)-n*t),t,0,π)-sin(n*π)/π*int(e^((−z)*sinh(t)-n*t),t,0,∞);
RETURN approx(funzione);
ELSE
RETURN "Error: ARG(z)≥π/2";
END;
END;
#end

The program does not work with the HP PRIME G2 probably due to an error attributable to the sine and cosine functions or to an error attributable to the complex exponential. In particular, in the calculation of the "Bessel function of the first kind Jn (z)", with n = 2.5, z = -2-3*i, the calculator must integrate the following function: exp((- 2-3*i)*SINH(x)+2.5*x) from zero to infinity. For an error related to the computation of the complex exponential (or for an error related to the sine and the cosine functions that derive from it), this function cannot be integrated by the "romberg" command in the range from zero to infinity.

The virtual HP PRIME calculator, on the other hand, runs the program quickly and correctly (the results have been compared with Wolfram Mathematica).[/php]
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Error with exp function and imaginary numbers - robmio - 07-28-2020 07:10 PM



User(s) browsing this thread: 1 Guest(s)