Showing posts with label integral equations. Show all posts
Showing posts with label integral equations. Show all posts

Saturday, December 23, 2023

Swiss Micros DM32: Solving Integral Equations

Swiss Micros DM32:  Solving Integral Equations



Introduction


The programs presented today solves the following equation for X:


X

∫   F(T)  dT = C

0


Since we are not able to use an integration command in solving a program on the DM32 (and the HP 32S and 32SII), we will have to use a manual method, mainly Newton's Method:


X_n+1 = X_n - [ ∫( F(T) dT from T = 0 to T = x_n) - C ] ÷ f(x_n) 


with in tolerance D.


To see a similar program for the HP Prime, posted on April 3, 2020, please click here:

https://edspi31415.blogspot.com/2020/04/hp-prime-solving-integral-equations.html



DM32 Code:  Integral Equations


LBL H:  Help File


 LBL H

  SF 10

  EQN: L B L _ F - F ( T )

  EQN: L B L _ S - S O L V E

  EQN: S _ H A S _ R C L _ T

  EQN: C = C O N S T

  EQN: D = T O L E R

  EQN: G U E S S _ X E Q _ S

  CF 10

  RTN


Note:  Underscore is the space key.   Press R/S after each message.   


LBL F

  RCL T

  enter f(T), the integrand, here

  RTN


Note:  The variable used is T.   If you want to test out the function, store a value in the variable T first.  


 LBL S

  RAD

  STO X

  LBL A

  FN= F

  0

  RCL X

  ∫ FN d T

  RCL- C

  STO Y

  RCL X

  STO T

  XEQ F

  STO÷ Y

  RCL X

  RCL- Y

  STO Y

  RCL Y

  RCL- X

  ABS

  RCL D

  x<y?

  GTO B

  RCL Y

  RTN

  LBL B

  RCL Y

  STO X

  GTO A


Note:  This is the main program.  Enter a guess, and then key in XEQ S.  



Variables Used:


T = independent variable

C = constant

D  = tolerance (i.e. 10^-4, 10^-5, 10^-6, etc)

X = x_n

Y = x_n+1, final approximation



Download the state file here:  ntegralequ.dm32



The state file includes a sample integrand:


e^(-T ÷ 4):


LBL F

RCL T

x^2

+/-

4

÷

e^x

RTN



Examples



In the following examples, the tolerance is 10^-5  (5 +/- 10^x STO D) and FIX 5 mode is set.  


1.   ∫( e^(-T^2 ÷ 4) dT for T = 0 to X) = 1


C = 1


Guess = 2,   Result:  1.10208

Guess = 1,   Result:  1.10208

Guess = 3,   Result:  Division by 0 error


Note that initial guesses are important.  



2.  ∫( e^-sin(T + 1) dT for T = 0 to X) = 10


C = 10


LBL F

RCL T

1

+

SIN

+/-

e^x

RTN


Guess = 5;  Result:  9.10014



3.  ∫( T^3 - 2 × T dT for T = 0 to X) = 40


C = 40


LBL F

RCL T

3

y^x

RCL T

×

-

RTN


Guess = 5; Result:  3.84789



4.  ∫( sin^2 T dT for T = 0 to X) = 1.4897


C = 1.4897


LBL F

RCL T

SIN

x^2

RTN


Guess = 2;  Result:  2.49991




Eddie


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

Solving Integral Equations

Solving Integral Equations



Solving integral equations (for the variable A) of any of the following forms:


∫( f(x) dx, x = constant to x = A) = area


∫( f(x) dx, x = A to x = constant) = area


∫( f(x) dx, x = constant to x = constant) = A


is fairly easy with the solve feature on non-graphing scientific calculators such as:


Casio fx-115ES Plus 

Casio fx-991EX

Casio fx-991CW

TI-30X Pro Math Print

TI-36X Pro


The screen shots below show an example, from the Casio fx-991CW (Equation - Solver):




The function must have the variable x as the independent variable. We can designated any other variable to be limit to be solved for; I used the variable a.  


Here, we don't have to worry about the value of x when solving the equation because x is considered a dummy variable in the integral.  



Examples


Solve for A.


Example 1:


∫( e^(-x^2) dx, x = 0 to x = A) = 0.7


Casio fx-991EX:  

A = 0.8861430055,  L-R = 0


TI-30X Pro MathPrint:  

A = 0.8861430055201,  L-R = 0  (this solve took a little time)



Example 2:


∫( e^(-x^2) dx, x = A to x = 2) = 0.13


Casio fx-991EX:  

A = 1.014499933,  L-R = 0


TI-30X Pro MathPrint:  

A = 1.014499933366,  L-R = 0  



Example 3:


∫( A*x + 1 dx, x = 1 to x = 5 ) = 10


Casio fx-991EX:  

A = 0.4,  L-R = 0


TI-30X Pro MathPrint:  

A = 0.4,  L-R = 0  



Eddie 


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


Friday, April 3, 2020

HP Prime: Solving Integral Equations

HP Prime:  Solving Integral Equations

Introduction

The program INTEGRALSOLVE solves the following integral equation for x:

x
∫ f(X) dX  - a = 0
0

using Newton's method.

Big X represents the variable of f(X) to be integrated while small x is the x that needs to be solved for.

Taking the derivative of the above integral using the Second Fundamental Theorem of Calculus:

d/dx [ ∫( f(X) dX from X=0 to X=x ) - a ]
= d/dx [  F(x) - F(0) - a ]
= d/dx [ F(x) ] - d/dx [ F(0) ] - d/dx [ a ]
= d/dx [ F(x) ]
= f(x)

F(X) is the anti-derivative of f(X).  F(0) and a are numerical constants, hence the derivative of each evaluates to 0.

Newton's Method to solve for any function g(x) is:

x_n+1 = x_n - g(x_n) / g'(x_n)

Applying this to the equation, Newton's Method gives:

x_n+1 = x_n - [ ∫( f(X) dX from X=0 to X=x_n ) - a ] / f(x_n)

HP Prime Program INTEGRALSOLVE

Note:  Enter f(X) as a string and use capital X.  This program is designed to be use in Home mode.

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;

Examples



Radians angle mode is set.

Example 1:

Solve for x:

x
∫ sin(X) dX = 0.75
0

Initial guess:  1

Result:  x ≈ 1.31811607165

Example 2:

Solve for x:

x
∫ e^(X^2) dX = 0.95
0

Initial guess:  2

Result:  x ≈ 0.768032819934

Pretty powerful.

April 2020:  New Posts Every Friday, Saturday, and Sunday! 

Eddie

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

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.

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues The programs are listed for the Swiss Micros DM42 an...