Post Reply 
Problem with integral on WP 34s
09-12-2021, 11:15 PM (This post was last modified: 09-13-2021 09:39 AM by Albert Chan.)
Post: #23
RE: Problem with integral on WP 34s
(09-12-2021 08:41 PM)Nigel (UK) Wrote:  The comments from [double exponential] integration code state that
Quote:the double exponential method relies on the function to be
integrated being analytic over the integration interval, except,
perhaps, at the interval ends

Even if integrand is analytic, it may be wise to break-up integral.

Example, ∫(z^(1/3), z = -2 .. 3)

>>> from mpmath import *
>>> def f(x): f.n+=1; return cbrt(x) # complex cube root, principle branch
...
>>> f.n=0; quad(f, (-2,3), error=1), f.n
((mpc(real='4.1920063238379486', imag='1.6347100863481141'), mpf('0.01')), 427)

Now, break-up integral to 2 pieces.

>>> f.n=0; quad(f, (-2,0,3), error=1), f.n
((mpc(real='4.1900023206128241', imag='1.6366854539575821'), mpf('1.0e-24')), 106)

>>> F = lambda z: mpc(z)**(4/3)/(4/3)
>>> F(3) - F(-2) # integral true value
mpc(real='4.1900023206128232', imag='1.6366854539575817')
>>> F(3) + F(2)*exp(pi/3*1j) # another way
mpc(real='4.1900023206128232', imag='1.6366854539575821')
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Problem with integral on WP 34s - lrdheat - 09-08-2021, 01:43 AM
RE: Problem with integral on WP 34s - Albert Chan - 09-12-2021 11:15 PM



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