Вы находитесь на странице: 1из 16

2/7/16

NON-LINEAR ALGEBRAIC EQUATIONS


Lec. 5.1: Nonlinear Equation in Single Variable
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-5

A Simple Example
To solve the following equation:
2.0 − % + ln % = 0

The solution is the location where the


curve intersects the X-axis

It is possible to have multiple solutions


0.1586 3.1462 (finite) to the problem

2.0 - x + ln(x) Computational Techniques: Module-4


http://nptel.ac.in/courses/103106074/9

1
2/7/16

General Setup
Let x be a variable of interest. The objective is to find the value of x
which satisfies the following nonlinear equation:
* % =0

Example: Model for a reactor


cA0
C A0 C A kC A
− − =0
τ τ (1 + KC A )2
$!!!!#!!!! "
f (C A )
cA

General Strategy of Solution

Start with initial guess(es)

Using a chosen strategy,


move in the direction of
the solution

Verify if stopping criterion


2.0 - x + ln(x) is satisfied
Yes

Solution!

2
2/7/16

Bisection Method (Single Variable Only)

• Start with two initial guesses, % + and % ,

• Verify that signs of * % + and * % , are different


• Repeat the following steps

• New guess % (./0) is the midpoint of the previous two guesses


• Calculate * % ./0
• Replace either % (+) or % (,) with based on sign of * % ./0

Related: Computational Techniques Module-4 Part-2: http://nptel.ac.in/courses/103106074/10

Methods to Solve Nonlinear Equations

• Bracketing Methods
• Bisection method
• Regula Falsi

• Open Methods
• Secant method
• Fixed-point iteration
• Newton-Raphson

• MATLAB functions fzero and fsolve

3
2/7/16

End of Lecture 5.1

NON-LINEAR ALGEBRAIC EQUATIONS


Lec. 5.2: Using MATLAB Function fzero
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-5

4
2/7/16

MATLAB Function fzero

• Solves nonlinear algebraic equation in single variable

• Uses bracketing method

• Usage:
xSol = fzero(@(x) funName(x),x0)
• xSol is the resulting solution
• funName is a function file that we provide to calculate * %
• x0=[xL;xH]; is vector of initial guesses

Problem to Solve

• Use fzero to solve the nonlinear equation:


2 − % + ln % = 0

• Modify bisection method from previous lecture

5
2/7/16

End of Lecture 5.2

NON-LINEAR ALGEBRAIC EQUATIONS


Lec. 5.3: Fixed-Point Iteration (Single Variable)
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-5

6
2/7/16

Fixed Point Iteration

• Also known as “Method of successive substitution”

• Related: Computational Techniques Module-4 Part-2:


http://nptel.ac.in/courses/103106074/10

• Used for solving equations of the type: % = 2 %

• How are 2 % and * % related è % − 2 % = 0


3 4

Fixed Point Iteration

• Also known as “Method of successive substitution”

• Related: Computational Techniques Module-4 Part-2:


http://nptel.ac.in/courses/103106074/10

567 5
% =2 %

7
2/7/16

Example

2 − % + ln % = 0

% = 2 + ln (%) % = 9 4:;

0.1586 3.1462

Example 2

5% − 9 4/; = 0

% = 0.29 4/; ???

Module-4 Part-3: http://nptel.ac.in/courses/103106074/11

8
2/7/16

End of Lecture 5.3

NON-LINEAR ALGEBRAIC EQUATIONS


Lec. 5.4: Newton-Raphson (Single Variable)
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-5

9
2/7/16

Newton Raphson

• Popular Method

• Example: Computational Techniques Module-4 Part-2:


http://nptel.ac.in/courses/103106074/10

567 5
* %5
% =% − > 5
* %

Example

• Solve the previous example using Newton-Raphson:


* % = 2 − % + ln %
7
*> % = −1 + 4

10
2/7/16

Newton Raphson

• Derivation and Analysis: Computational Techniques Module-4 Part-4:


http://nptel.ac.in/courses/103106074/12

565 5
* %5
% =% − > 5
* %
;
• Has quadratic rate of convergence è @ 567 = @ 5

• Fixed point iteration has linear rate of convergence

End of Lecture 5.4

11
2/7/16

NON-LINEAR ALGEBRAIC EQUATIONS


Lec. 5.5: Using MATLAB function fsolve
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-5

Recap and Next Steps

• Solved nonlinear equation 2 − % + ln % = 0

1. Bisection Method
2. MATLAB function fzero

3. Fixed-Point Iteration
4. Newton-Raphson

• Next: MATLAB function fsolve

• Multivariate problems using fsolve and Newton-Raphson

12
2/7/16

MATLAB Function fsolve

• Solves nonlinear algebraic equation

• Usage:
xSol = fsolve(@(x) funName(x),x0)
• xSol is the resulting solution
• funName is a function file that we provide to calculate A B
• x0 initial guess (same dimension as number of variables)

Problem to Solve

• Use fsolve to solve the nonlinear equation:


2 − % + ln % = 0

13
2/7/16

Multivariate Example: Lorenz Equation

• Wikipedia: https://en.wikipedia.org/wiki/Lorenz_system

• First example to demonstrate “Chaos”

• Observed by Edward Lorenz for atmospheric convection

• Example problem in this Module: Find steady-state solution:


% − C = 0
2% − %D − C = 0
%C − 3D = 0

End of Lecture 5.5

14
2/7/16

NON-LINEAR ALGEBRAIC EQUATIONS


Lec. 5.6: Multivariable Newton Raphson
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-5

Multivariate Example: Lorenz Equation


567 5 5 :7 5
B =B − G A
• Steady-state Lorenz Equation:
% − C = 0
2% − %D − C = 0
%C − 3D = 0
Compute the Jacobian:

1 −1 0
F= 2−D −1 −%
C % −3

15
2/7/16

End of Lecture 5.6

16

Вам также может понравиться