help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how do detect a complex function?


From: Nicholas Jankowski
Subject: Re: how do detect a complex function?
Date: Sat, 20 Jun 2020 17:27:21 -0400

How inefficient would it be? It seems to me that for most cases, complex numbers would be returned at the first function evaluation.

Perhaps a start would be to evaluate the function at the limits of integration and check whether either returned value is complex. If either is, use quadgk. If not, try quadcc. If quadcc throws an error, then you can catch it and redirect to quadgk.

Obviously this check wouldn't catch every complex function, but it should get most. The error-catching approach then becomes a failsafe rather than the default.

Yeah, it'll fail on anything with limits evaluating on the real axis.  and checking the integrand isn't trivial.  e.g, integral (sqrt(x), -1,1) would pass both a limit and integrand check unless you had some complex domain check.  

added limit and f(limit) checks to function attached to the bug. 

but it still doesn't catch complex functions with real limits that eval to real answers at those limits.  eg:

integral (exp(i*x), 0,pi) = 2i
--> f(0) = 1, f(pi) = -1,  but f(pi/2) = i

(easiest would be to just abandon quadcc. but the others are slooooooow.)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]