Post Reply 
HP71B Integral Questions
02-05-2020, 05:09 PM (This post was last modified: 02-09-2020 11:31 PM by Albert Chan.)
Post: #7
RE: HP71B Integral Questions
I noticed u-transformation can be applied more than once, accelerate some integrals.

Example: \( \int _{-1} ^1 {dx \over \sqrt{1-x^2}} = 2\;\sin^{-1} 1 = \pi\)

Below, FNB(U) is u-transformed FNA(X), which is more accurate, and run much faster.

Code:
10 INPUT "P=? ";P
20 DEF FNA(X) @ N=N+1 @ FNA=1/SQRT(1-X*X) @ END DEF
30 DEF FNB(U)=1.5*(1-U*U)*FNA(U*(3-U*U)/2)
40 T=TIME @ N=0 @ I=INTEGRAL(-1,1,P,FNA(IVAR))
50 DISP "IA(";N;") =";I,IBOUND,TIME-T;"SEC"
60 T=TIME @ N=0 @ I=INTEGRAL(-1,1,P,FNB(IVAR))
70 DISP "IB(";N;") =";I,IBOUND,TIME-T;"SEC"

>RUN
P=? 1E-4
IA( 8191 ) = 3.14133371246      3.14116984016E-4        6.34 SEC
IB( 31 ) = 3.14159247755        3.14127673304E-4        .03 SEC
>RUN
P=? 1E-5
IA( 65535 ) = 3.14156045534     -3.1415397954E-5        50.97 SEC
IB( 31 ) = 3.14159263336        3.14127673304E-4        .03 SEC

Lets call integrand of IB (= u-transformed FNB) as FNC.
If we plot FNB and FNC, u = -1 to 1, FNB is much flatter, min=FNB(0)=3/2, max=FNB(±1)=√3

Intuition may suggest IA is easier to integrate, but it will be dead wrong.

The code never evaluate the end-points integrand limit, and skip over them.
That's why we only have 2^N-1 samples points, instead of 2^N+1.

Trapezoid number, T1 = 0 (*always*)

FNB, which T1 should really be 2√3, skewed badly all the romberg numbers.
To confirm, I tried doing by hand, with T1=2√3, IA(31+2) = 3.14159265428

FNC does not suffer from this, since limit(FNC, U=-1) = limit(FNC, U=+1) = 0
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP71B Integral Questions - Albert Chan - 02-02-2020, 03:31 PM
RE: HP71B Integral Questions - Albert Chan - 02-03-2020, 01:58 PM
RE: HP71B Integral Questions - J-F Garnier - 02-03-2020, 03:00 PM
RE: HP71B Integral Questions - Albert Chan - 02-03-2020, 04:15 PM
RE: HP71B Integral Questions - Albert Chan - 02-03-2020, 11:15 PM
RE: HP71B Integral Questions - J-F Garnier - 02-05-2020, 08:43 AM
RE: HP71B Integral Questions - Albert Chan - 02-05-2020 05:09 PM
RE: HP71B Integral Questions - Wes Loewer - 02-06-2020, 06:53 PM
RE: HP71B Integral Questions - Albert Chan - 02-06-2020, 11:16 PM
RE: HP71B Integral Questions - Wes Loewer - 02-07-2020, 03:49 AM
RE: HP71B Integral Questions - Albert Chan - 02-07-2020, 08:14 AM
RE: HP71B Integral Questions - J-F Garnier - 02-07-2020, 08:23 AM
RE: HP71B Integral Questions - Wes Loewer - 02-07-2020, 01:19 PM
RE: HP71B Integral Questions - Albert Chan - 02-07-2020, 05:08 PM
RE: HP71B Integral Questions - J-F Garnier - 02-07-2020, 05:54 PM
RE: HP71B Integral Questions - Wes Loewer - 02-07-2020, 08:16 PM
RE: HP71B Integral Questions - Wes Loewer - 02-07-2020, 08:12 PM
RE: HP71B Integral Questions - J-F Garnier - 02-05-2020, 06:20 PM
RE: HP71B Integral Questions - Albert Chan - 02-05-2020, 07:52 PM
RE: HP71B Integral Questions - J-F Garnier - 02-06-2020, 08:37 AM
RE: HP71B Integral Questions - Wes Loewer - 02-08-2020, 10:46 AM
RE: HP71B Integral Questions - J-F Garnier - 02-08-2020, 10:59 AM
RE: HP71B Integral Questions - Wes Loewer - 02-08-2020, 03:04 PM
RE: HP71B Integral Questions - Albert Chan - 02-09-2020, 01:43 PM
RE: HP71B Integral Questions - Wes Loewer - 02-09-2020, 08:33 PM
RE: HP71B Integral Questions - Albert Chan - 02-10-2020, 01:33 PM
RE: HP71B Integral Questions - Wes Loewer - 02-09-2020, 09:03 PM
RE: HP71B Integral Questions - Albert Chan - 02-11-2020, 05:03 PM
RE: HP71B Integral Questions - Albert Chan - 02-11-2020, 11:57 PM
RE: HP71B Integral Questions - Albert Chan - 02-21-2020, 11:23 PM



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