Post Reply 
Comments and discussion on Valentin's 4th "Then and Now" - Area
01-23-2023, 10:44 PM
Post: #23
RE: Comments and discussion on Valentin's 4th "Then and Now" - Area
(01-21-2023 08:06 PM)Albert Chan Wrote:  I had also considered breaking up main area into more natural 2 pieces, and apply u-transformation.

\(\displaystyle \int_a^{a+b} = \int_0^a + \int_a^{a+b} \)

Code is more readable, because this does not involve "back folding".
But, I may need math to explain how u-substitution work, and why I need it here.
INTEGRAL built-in u-sub is not enough. (that's why JFG sum main area from 4 pieces)

To keep post short, I gave up on that idea.

This was my 2-splits main area solution, as opposed to 3-splits: \( \displaystyle
\int_0^{a+b} = \int_0^{a/2} - \int_a^{a/2} + \int_a^b\)

10 M=30.07 @ A=.831971149978 @ B=2.82740261413-A @ P=10^(-9)
20 T=1/3 @ DEF FND(Y,S)=SGN(Y+S)*ABS(Y+S)^T-SGN(Y-S)*ABS(Y-S)^T
30 DEF FNF(Y)=FND(Y,SQR(-LN(Y*Y/M+EXP(-SIN(Y)))))
40 DEF FNG(Z)=FNF(A*Z)*A+FNF(A+B*Z)*B
45 DEF FNU(U,U2)=FNG(U2*U*(4-3*U))*U2*(1-U)*12
50 SETTIME 0 @ DISP INTEGRAL(0,1,P,FNU(IVAR,IVAR*IVAR)),TIME

>run
 2.07662636771        .71      ! @200x, HP71B = 142 seconds
>p=1e-10 @ run 50
 2.07662636775      1.42      ! @200x, HP71B = 284 seconds

Both 3-splits and 2-splits are equally good.

3-splits use 3*127 = 381 FNF() calls to get 12 accurate digits.
2-splits use 2*127 = 254 calls to get 11+ digits, 2*255 = 510 to get full 12.



We wanted u-substitution to produce polynomial-like integrand, easy for INTEGRAL to handle.
Let x = U, where U is a function of u

\(\displaystyle \int _0^1 g(x)\;dx = \int _0^1 g(U)\,(U' \; du) \)

Based from plots, I had guessed g(x) both ends curve like cube root, left side more extreme.
To transform to polynomial like integrand, I cube left edge, and square the other.
We start from derivatives: (u^3)' = 3u^2, ((1-u)^2)' = -2(1-u)

\(→ U' = K\,u^2\,(1-u)\)

For u = 0 .. 1, U' has sign of K, a non-zero constant --> x and u are one-to-one.

\(→ U = \int U' du = K \left(\frac{u^3}{3} - \frac{u^4}{4} \right) + C \)

Matching integral limits, x=0 → u=0, x=1 → u=1, we have K = 12, C = 0

\(→ U = u^3\,(4-3u) \quad,\quad U' = 12u^2\,(1-u)\)

NOTE: U does not have to be a polynomial of u. see Kahan's Q(x) example
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Comments and discussion on Valentin's 4th "Then and Now" - Area - Albert Chan - 01-23-2023 10:44 PM



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