ENGG 1801 Engineering Computing - PowerPoint PPT Presentation

About This Presentation
Title:

ENGG 1801 Engineering Computing

Description:

ENGG 1801 Engineering Computing MATLAB Lecture 7: Tutorial Weeks 11-13 Solution of nonlinear algebraic equations (II) Outline of lecture Solving sets of nonlinear ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 11
Provided by: eePdxEdu
Learn more at: http://web.cecs.pdx.edu
Category:

less

Transcript and Presenter's Notes

Title: ENGG 1801 Engineering Computing


1
ENGG 1801Engineering Computing
  • MATLAB Lecture 7 Tutorial Weeks 11-13
  • Solution of nonlinear algebraic equations (II)

2
Outline of lecture
  • Solving sets of nonlinear equations
  • Multivariable Newtons method
  • Example (2 equations in 2 unknowns)
  • Solving example problem in Matlab
  • Functions
  • Conclusions

3
Sets of Nonlinear Equations
  • Equation sets can be large
  • 100s (1000s) of equations
  • Initial solution estimate can be a challenge
  • Fewer solution options
  • Plotting and direct substitution are not options
  • Most widely used approach ?
  • Multivariable Newtons method

4
Multivariable Newtons Method
  • Single variable algorithm
  • Each iteration solves a linear approximation to
    function
  • Multivariable algorithm
  • Each function approximated by a linear equation
  • Each iteration solves a set of linear equations

Scalar equation
Vector-matrix equation
5
Example (I)
  • Solve the pair of equations
  • Elements of the Jacobian matrix

Solution is x1 4 x2 2
6
Example (II)
  • Use as initial estimate for solution (3, 3)
  • Next estimate obtained from

Functions evaluated at old point
New point (3.5714, 2.0952)
Jacobian evaluated at old point
Old point (3, 3)
7
Solution in Matlab
  • counter 1
  • error 10
  • xold 33
  • while error gt 1e-3 counter lt 10
  • fold(1) xold(1) - xold(2)2 fold(2)
    xold(1)xold(2) - 8
  • J(1,1) 1 J(1,2) -2xold(2) J(2,1)
    xold(2) J(2,2) xold(1)
  • xnew xold - inv(J)fold'
  • error max(abs(xnew(1)-xold(1)),abs(xnew(2)-xold
    (2)))
  • counter counter 1
  • xold xnew
  • end

8
Advice on Iterative Methods
  • Follow one cycle through code by hand
  • Initially use modest convergence criterion
  • Put in a counter ( to prevent infinite loop )
  • Check final solution
  • Be prepared for multiple solutions
  • Initial guess has a big impact
  • On the final solution obtained
  • On the time taken to converge to solution

9
Functions
  • Breaking up complex calculations into simpler
    blocks.
  • Main program
  • a 2 b 3
  • answer, diff my_function(a,b)
  • Separate file, my_function.m outputs calculated
    inside function using input arguments (in1 in2)
  • function answ, differ my_function(in1,in2)
  • answ in1 in2
  • differ in1 in2

One to one correspondence between inputs, outputs
in calling statement and in function
10
Conclusions
  • Solution of nonlinear equation sets ?
  • Very common problem in engineering
  • Built-in Matlab functions ( e.g. fsolve from
    MATLABs Optimization Toolbox)
  • User supplied Jacobian speeds convergence
  • If unavailable ? Matlab gets by finite
    differencing
  • User has to supply initial estimate of solution
  • Make your own functions to split up a big problem
    into simpler pieces.
Write a Comment
User Comments (0)
About PowerShow.com