Showing posts with label TI nSpire CX CAS. Show all posts
Showing posts with label TI nSpire CX CAS. Show all posts

Saturday, August 24, 2019

HP Prime and TI Nspire CX CAS: Solving Integral Equations

HP Prime and TI Nspire CX CAS:  Solving Integral Equations





Introduction

The program INTEGRALSOLVE solve the following equation:
(Format:  ∫( integrand dvar, lower, upper)

∫( f(t) dt, 0, x) = a

∫( f(t) dt, 0, x) - a = 0

It is assumed that x>0. 

We can use the Second Theorem of Calculus which takes the derivative of the integral:

d/dx  ∫( f(t) dt, a, x) = f(x)

We don't have to worry about lower limit a at all for the theorem to work. 

∫( f(t) dt, 0, x) - a

Take the derivative with respect to x on both sides (d/dx):

= d/dx ∫( f(t) dt, 0, x) - a

= d/dx ∫( f(t) dt, 0, x) - d/dx a

Let F(t) be the anti-derivative of f(t):

= d/dx (F(x) - F(0)) - 0

= d/dx F(x) -  d/dx F(0)

F(0) is a constant.

= f(x)


Newton's Method to find the roots of f(x) can be found by the iteration:

x_(n+1) = x_n - f(x_n) / f'(x_n)

Applying that to find the roots of ∫( f(t) dt, 0, x) - a:

x_(n+1) = x_n - (∫( f(t) dt, 0, x_n) - a) / f(x_n) 


HP Prime Program INTEGRALSOLVE

Enter f(X) as a string as it will be stored in Function App variable F0.  Use X as the independent variable. 

EXPORT INTEGRALSOLVE(f,a,x)
BEGIN
// f(X) as a string, area, guess
// ∫(f(X) dX,0,x) = a
// EWS 2019-07-26
// uses Function app
LOCAL x1,x2,s,i,w;
F0:=f;
s:=0;
x1:=x;
WHILE s==0 DO
i:=AREA(F0,0,x1)-a;
w:=F0(x1);
x2:=x1-i/w;
IF ABS(x1-x2)<1 font="" then="">
s:=1;
ELSE
x1:=x2;
END;
END;

RETURN approx(x2);
END;

TI NSpire CX CAS Program INTEGRALSOLVE
(Caution:  This program needs to be typed in)

Use t as the independent variable.

Define LibPub integralsolve(f,a,x)=
Func
:© f(x), area, guess: ∫(f(t) dt,0,x = a)
:Local x1,x2,s
:s:=0
:x1:=x
:While s=0
:  x2:=x1-((∫(f,t,0,x1)-a)/(f|t=x1))
:  If abs(x2-x1)≤1E−12 Then
:    s:=1
:  Else
:    x1:=x2
:  EndIf
:EndWhile
:Return approx(x2)
:EndFunc

Examples

Example 1: 

∫( 2*t^3 dt, 0, x) = 16
Guess = 2
Root ≈ 2.3784

Example 2:

∫( sin^2 t dt, 0, x) = 1.4897
Guess = 1
(Radians Mode)
Root ≈ 2.4999

Source:

Green, Larry.  "The Second Fundamental Theorem of Calculus"  Differential Calculus for Engineering and other Hard Sciences.  Lake Tahoe Community College. http://www.ltcconline.net/greenl/courses/105/Antiderivatives/SECFUND.HTM  Retrieved July 25, 2019

Happy Solving!

Eddie

All original content copyright, © 2011-2019.  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.

Monday, May 21, 2012

Arc length of sin(x) - Curve Approximation

Blog Entry #102

The Arc Length of a Sine Curve

The sine curve is one the most interesting curves in mathematics.

Let

y = a * sin x ,

Where a is the amplitude of the sine curve.

We can find the arc length of a curve between limits x1 and x2 by the integral:

x2
∫ √ (1 + (dy/dx)^2) dx
x1

For the sine curve:

y = a sin x

dy/dx = a cos x

(dy/dx)^2 = a^2 cos^x

And the arc length is:

x2
∫ √(1 + a^2 cos^x) dx
x1

There is no anti-derivative for √(1 + a^2 cos^x). Therefore, numerical methods must be used.

Finding an Approximate Curve

Using a TI nSpire CX CAS, I used the Spreadsheet, curve fitting, and graphing features to determine an approximate polynomial. The arc length is from the origin (0,0) to (π, 0).

Note: x1 = 0, x2 = π

Here is a shot summary of what I did:

1. Created a spreadsheet with the following columns:

Column A: A sequence of numbers from 0.25 to 5 in increments of 0.25. The resulting list is named amplist.

Column B: Use the nSpire's arcLen function to get the arc length of the sine curve using amplist as the values for a. This list is named arc1.

2. Pressing the menu key allowed me to access the Statistics menu. Using the Stat Calculations option, I used different types of regression, including power and quartic regression. What I was looking for was which regression had the best coefficient of determination (R^2). In general, the closer R^2 is to 1, the better the fit.

I ended up choosing the quartic regression (4th degree polynomial) with R^2 ≈ 0.9999919.

The approximate polynomial is

y = .0081196317102889 x^4 - .11577326164517 x^3 + .63914882375794 x^2 + .2071162669684 x + 3.0881429428239

This polynomial was save to the function f1(x).

3. I created a graphs page and made two plots:

* Scatter plot where x = amplist, y = arc1. (The dots in red)
* The function f1(x) (see step 2). (The curve in blue)

Setting zoom to fit the data, the curve looks like a good fit.

You can create a similar graph with the Data & Statstics module, but I thought I would be different this time.

How good of a fit is the polynomial?

4. I went back to the spreadsheet and added two more columns.

Column C: est1 = f1(amplist). (estimate arc lengths)
Column D: err1 = abs(arc1 - est1)

By scrolling down Column D, the quartic polynomial was accurate in estimating the arc length of the sine curve from 0 to π to at least two decimal places.

Conclusion

We have been looking to find the arc length of the curve y = a sin x from x = 0 to x = π.

The exact value is:

π
∫ √ (1 + a^2 cos^2 x ) dx
0

However, a good estimate can be found (to 2-3 decimal places) with the polynomial:

y = .0081196317102889 x^4 - .11577326164517 x^3 + .63914882375794 x^2 + .2071162669684 x + 3.0881429428239


Thanks as always and talk to you soon!


Eddie



This blog is property of Edward Shore. © 2012

RPN HP 12C: Fibonacci and Lucas Sequences

  RPN HP 12C: Fibonacci and Lucas Sequences Golden Ratio, Formulas, and Sequences Let φ be the Golden Ratio: φ = (1 + √5) ÷ 2...