WP 34S on DM 42 integral fail
04-12-2022, 07:06 PM
Post: #1
 lrdheat Senior Member Posts: 857 Joined: Feb 2014
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
04-12-2022, 07:20 PM
Post: #2
 lrdheat Senior Member Posts: 857 Joined: Feb 2014
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.
04-12-2022, 09:57 PM
Post: #3
 ijabbott Senior Member Posts: 1,297 Joined: Jul 2015
RE: WP 34S on DM 42 integral fail
I guess it has something to do with the discontinuity between the bounds.

— Ian Abbott
04-12-2022, 11:35 PM
Post: #4
 lrdheat Senior Member Posts: 857 Joined: Feb 2014
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…
04-13-2022, 12:38 AM
Post: #5
 Steve Simpkin Senior Member Posts: 1,209 Joined: Dec 2013
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.
04-13-2022, 12:52 AM
Post: #6
 Thomas Klemm Senior Member Posts: 2,103 Joined: Dec 2013
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.
04-13-2022, 03:51 AM
Post: #7
 lrdheat Senior Member Posts: 857 Joined: Feb 2014
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.
04-13-2022, 08:55 AM
Post: #8
 J-F Garnier Senior Member Posts: 946 Joined: Dec 2013
RE: WP 34S on DM 42 integral fail

J-F
04-13-2022, 02:28 PM
Post: #9
 lrdheat Senior Member Posts: 857 Joined: Feb 2014
RE: WP 34S on DM 42 integral fail
04-13-2022, 04:00 PM
Post: #10
 Albert Chan Senior Member Posts: 2,678 Joined: Jul 2018
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

1.35517995835
04-13-2022, 05:42 PM
Post: #11
 lrdheat Senior Member Posts: 857 Joined: Feb 2014
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
04-13-2022, 07:38 PM (This post was last modified: 04-17-2022 11:22 AM by Albert Chan.)
Post: #12
 Albert Chan Senior Member Posts: 2,678 Joined: Jul 2018
RE: WP 34S on DM 42 integral fail

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.
 « Next Oldest | Next Newest »

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