Post Reply 
WP 34S on DM 42 integral fail
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 


Messages In This Thread
WP 34S on DM 42 integral fail - lrdheat - 04-12-2022, 07:06 PM
RE: WP 34S on DM 42 integral fail - Albert Chan - 04-13-2022 07:38 PM



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