Post Reply 
WP 34S on DM 42 integral fail
04-12-2022, 07:06 PM
Post: #1
WP 34S on DM 42 integral fail
When integrating from -2 to 3 the function 1/3Root(x), my WP 34S comes up with 0. The answer should be ~.739. I use an 8 size stack and full precision. My code is LBL ‘F0’, FILL, 3Root(x), (1/x), RTN
Find all posts by this user
Quote this message in a reply
04-12-2022, 07:20 PM
Post: #2
RE: WP 34S on DM 42 integral fail
Of course, if I break it into 2 integrals, from (-2 to 0) + from (0 to 3), I come up with the correct result quickly. I am curious as to why the WP 34S could not deal with using the -2 to 3 domain, and if this is unexpected.
Find all posts by this user
Quote this message in a reply
04-12-2022, 09:57 PM
Post: #3
RE: WP 34S on DM 42 integral fail
I guess it has something to do with the discontinuity between the bounds.

— Ian Abbott
Find all posts by this user
Quote this message in a reply
04-12-2022, 11:35 PM
Post: #4
RE: WP 34S on DM 42 integral fail
My TI-30X Pro had no problem with the integration, did not require breaking the integral into two…
Find all posts by this user
Quote this message in a reply
04-13-2022, 12:38 AM
Post: #5
RE: WP 34S on DM 42 integral fail
My TI-89 and HP Prime (IOS App) provided the correct answer just fine. My Casio fx-991EX and fx-CG50 both gave a Math Error.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-13-2022, 12:52 AM
Post: #6
RE: WP 34S on DM 42 integral fail
From xrom/integrate.wp34s:
Quote:// - the double exponential method relies on the function to be
// integrated being analytic over the integration interval, except,
// perhaps, at the interval ends. Thus, if it is known that the
// integrand, _or any of its derivatives_, has a discontinuity at some
// point inside the integration interval, it is advised to break the
// interval at such point and compute two separate integrals, one
// at each side of the problematic point. Better results will be
// get this way. Thus, beware of abs, fp, ip and such non analytic
// functions inside the integrand program. Other methods (Romberg)
// may behave better in this respect, but, on the other side, the
// double exponential method manages discontinuities (of the
// integrand or its derivatives) at the interval edges better and
// is usually way faster that the Romberg method

In this specific case you can just integrate from 2 to 3.
Also you can skip the FILL command in your program.
Find all posts by this user
Quote this message in a reply
04-13-2022, 03:51 AM
Post: #7
RE: WP 34S on DM 42 integral fail
Re Steve…I have been surprised that the CASIO fx-CG50 cannot handle discontinuities where an integration would be a finite result. If the discontinuity is at 0 for example, one is forced to use 1*10^-12 for a starting point. Also surprised that it cannot handle trig or exponential commands with complex numbers, does not calculate prime factors, does not have a product command to complement the summation capability. Still, and excellent calculator. Really shines with graphing, graphing analysis, fantastic labeling of the x and y axis, Great with regressions and distributions! Fast as well.
Find all posts by this user
Quote this message in a reply
04-13-2022, 08:55 AM
Post: #8
RE: WP 34S on DM 42 integral fail
Already discussed here ?

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
04-13-2022, 02:28 PM
Post: #9
RE: WP 34S on DM 42 integral fail
Wow! I forgot about this…other nice examples, remedies given as well!
Find all posts by this user
Quote this message in a reply
04-13-2022, 04:00 PM
Post: #10
RE: WP 34S on DM 42 integral fail
(04-12-2022 11:35 PM)lrdheat Wrote:  My TI-30X Pro had no problem with the integration, did not require breaking the integral into two…

Maybe it did "break" integral into two (or more pieces), see Adaptive quadrature

Example, gaussquad() use adaptive Gaussian quadratures with 15 points.

XCas> gaussquad(surd(x,3), x=-2..3.)

1.35517995835
Find all posts by this user
Quote this message in a reply
04-13-2022, 05:42 PM
Post: #11
RE: WP 34S on DM 42 integral fail
I’m integrating the reciprocal of your function…this results in an undefined point at x=0.

This produces, if correct, ~.7379
Find all posts by this user
Quote this message in a reply
04-13-2022, 07:38 PM (This post was last modified: 04-17-2022 11:22 AM by Albert Chan.)
Post: #12
RE: WP 34S on DM 42 integral fail
XCas> gaussquad(surd(x,-3), x,-2.,3.)

0.739024156625

This work ! But, I would advice split the integral yourself, to be safe.
Adaptive scheme may be fooled. (no matter how good it is, it only see sample points)

Below is adaptive simpson's scheme to do above integral.
Note line 150. It never touched undefined point at x=0
(But, if integral limits changed, say, -2 .. 6, it will hit x=0 dead on)

10 X1=-2 @ X3=3 @ E=.0001
20 T=TIME @ X2=(X3+X1)/2 @ CALL F(X1,F1) @ CALL F(X2,F2) @ CALL F(X3,F3)
30 S=(F1+4*F2+F3)*(X3-X1)/6
40 CALL SIMPSON(X1,X2,X3,F1,F2,F3,32*E,S) @ DISP S,TIME-T @ END
50 SUB F(X,Y) @ Y=SGN(X)*ABS(X)^(-1/3) @ STOP

100 SUB SIMPSON(X1,X3,X5,F1,F3,F5,E,S)
110 H=(X5-X1)/4 @ X2=X1+H @ X4=X5-H
120 CALL F(X2,F2) @ CALL F(X4,F4)
130 H=H/3 @ S1=(F1+4*F2+F3)*H @ S2=(F3+4*F4+F5)*H
140 S3=S1+S2 @ D=S3-S @ H=E/2
150 IF H<1.E-15 OR ABS(D)<H THEN S=S3+D/15 @ STOP
160 CALL SIMPSON(X1,X2,X3,F1,F2,F3,H,S1)
170 CALL SIMPSON(X3,X4,X5,F3,F4,F5,H,S2)
180 S=S1+S2

>RUN
 .73902427614      18.76

Update: slightly modified SIMPSON() recurse condition, with following:

40 CALL SIMPSON(X1,X2,X3,F1,F2,F3,30*E,S) @ DISP S,TIME-T @ END
150 IF H<15E-15 OR ABS(D)<H THEN S=S3+D/15 @ STOP

> RUN
 .73902420507      15.44

The changes is to compare Sharp BASIC translated HP71B code speed.
Find all posts by this user
Quote this message in a reply
Post Reply 




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