Showing posts with label numeric integration. Show all posts
Showing posts with label numeric integration. Show all posts

Saturday, November 19, 2022

Casio fx-9750GIII: Integrals with Infinite Limits

Casio fx-9750GIII:  Integrals with Infinite Limits





A Substitution to Get to Infinity... 


It is quite a challenge to calculate numerical integrals with infinite limits such as 


∫( f(x) dx, a, ∞)


∫( f(x) dx, -∞, a)


∫( f(x) dx, -∞, ∞)



A trick is to substitute x = tan Θ.  Then:


Θ = arctan x


dx = sec^2 Θ dΘ = cos^-2 Θ dΘ



Note that


lim t→∞ arctan t = π/2


lim t→-∞ arctan t = -π/2  


In this blog, assume that radian angle mode is used in all calculations.


Let's go over some examples and see how it works.  I used a Casio fx-9750GIII, however, this technique should work with all calculators with numerical integral calculations.  Furthermore, changing the integral will allow for Simpson's Rule or Trapezoid Rule approximation.


For the upper limit, I approximate π/2.


A = 1.5708  (π/2 to 4 places)

B = 1.570796  (π/2 to 6 places)

C = 1.57079633 (π/2 to 8 places)



Example 1:  


∫( e^(-x^2) dx, 0, ∞)  


transforms to


∫( e^(-tan^2 Θ)/cos^2 Θ dΘ, 0, ≈π/2)


Calculations (fx-9750GIII):


Upper Limit: A (see above),  Result:  0.8862269255


Upper Limit: B,  Result:  0.8862269255


Upper Limit: C,  Result:  0.8862269255




Example 2:  


∫(x^0.5 * e^(-x) dx, 0, ∞)


transforms to


∫((tan Θ)^0.5 * e^(-tan Θ))/cos^2 Θ dΘ, 0, π/2)


Calculations:


Upper limits A, B, C:  0.862269255


Coincidently, ∫( e^(-x^2) dx, 0, ∞)  = ∫(x^0.5 * e^(-x) dx, 0, ∞) = Γ(1.5) = √(π)/2




Example 3:


∫( e^x*(x^2 + 1) dx, -∞, 0)


transforms to


∫( e^(tan Θ) * (tan^2 Θ + 1)/cos^2 Θ dΘ, -π/2, 0)

=  ∫( e^(tan Θ) * 1/cos^2 Θ * 1/cos^2 Θ dΘ, -π/2, 0)

∫( e^(tan Θ)/cos^4 Θ dΘ, -π/2, 0)


For upper limits A, B, C, the answer returned is 3, which is the exact answer.  


For integrals like this all is needed is a four digit approximation of π/2 = 1.5708.



Let's keep going:


Example 4:


∫( (x^2 + 1)/(x^4 - 1) dx, 0, ∞) 


transforms to


∫( 1/cos^Θ * (tan^2 Θ + 1)/(tan^4 Θ - 1) dΘ, 0, π/2)

= ∫( 1/(sin^4 Θ - cos^4 Θ) dΘ, 0, π/2)


On the fx-9750GIII get MA Error.  



Example 5:


∫( 1/√(x^2 + 3*x + 1) dx, 0, ∞)


transforms to 


∫( 1/(cos^2 Θ * √(tan^2 Θ + 3 * tan Θ + 1)) dΘ, 0, π/2)


like example 4, I get the MA Error.



Observation:  the transformation works best if the integral involves some form of either of the following:


f(x) * e^(g(x))


or 


f(x) * e^(-g(x))



Gamma


The Gamma Function is an excellent candidate for this transformation.  


Γ(t) = ∫( x^(t-1) * e^-x dx, 0, ∞)


transforms to


∫( tan^(t-1) Θ * e^(-tan Θ)/cos^2 Θ dΘ, 0, π/2)



Source


Mier-Jedrzejuwicz, W.A.C. Ph.D.    Tips And Programs for the HP 32S   Synthetix Publication.  Berkeley, CA.  September 1988.  ISBN 0-937637-05-X


Download the book here:  https://literature.hpcalc.org/items/1756




Happy calculating,


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Sunday, July 10, 2022

Calculus: Scaled Integration

Calculus:  Scaled Integration


Introduction


The take the integral:


∫( f(x) dx, A, B) 


The integral can be transformed to new limits C and D via linear transformation:



∫( f(x) dx, A, B) → ∫( g(y) dy, C, D)


Where the interval [ C, D ] has the smaller range than [ A, B ].


Set the transformation to:


y = m*x + β


C = m*A + β

D = m*B + β


Solving for m, β:


(C - D) = (A - B) * m

m = (C - D) / (A - B)


and


β = C - A * m = D - B * m


Solving y = m*x + β for x:


x = 1/m * (y - β)


Taking the derivative of both sides:


dx = 1/m  dy


The transformed integral:


∫( f(x) dx, A, B) → 1/m * ∫( f(1/m * (y - β)) dy, C, D)


Examples


Example 1:  


∫(x^2 - 5 dx, 10 ,16) but scale the integration interval to [1, 2].


A = 10, B = 16, C = 1, D = 2

m = (1 - 2)/(10 - 16) = 1/6,  1/m = 6

β = 1 - 10 * 1/6 = -2/3

x = 6 * (y + 2/3) = 6 * y + 4


Transformed Integral:

6 * ∫( (6*y + 4)^2 - 5 dy, 1, 2) = 1008


Example 2:


∫( e^x * ln(x + 2) dx, 0, 5) but scale the integration to [0, 1].


A = 0, B = 5, C = 0, D = 1

m = -1/-5 = 1/5,  1/m = 5

β = 0 - 0 * 1/5 = 0

x = 5 * y


Transformed Integral:

5 * ∫( e^(5 * y) * ln(5 * y + 2) dy, 0, 1) ≈ 262.8586594


Numerical integrals were calculated with the TI-36X Pro.  


When trying the Simpson's rule or Trapezoid rule, I find the smaller range does not really give better estimates.  But I am presenting the technique and if this helps in the future, great.  


Coming up:


July 11 - July 15, 2022:  TI-58 and TI-59 Week

Next Regular Blog:  July 23, 2022


Eddie  


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


The MU Key on a Four Function Calculator and Programs for the DM42/HP 42S

  The MU Key on a Four Function Calculator and Programs for the DM42/HP 42S Not too long ago, I purchased this very colorful, four funct...