數值方法 2008, Applied Mathematics NDHU 1 Nonlinear systems Newton’s method The steepest descent method.

Slides:



Advertisements
Similar presentations
Partial Differential Equations
Advertisements

Beginning Programming for Engineers
軟體實作與計算實驗 1  Roots of nonlinear functions  Nested FOR loops Lecture 5II.
Numerical Solution of Nonlinear Equations
Chapter 11: Symbolic Computing for Calculus
Functions in Maple 教授:蔡桂宏 博士 學生:柯建豪 學號: 統資軟體課程講義.
CSE 123 Symbolic Processing. Declaring Symbolic Variables and Constants To enable symbolic processing, the variables and constants involved must first.
Optimization 吳育德.
Least Squares example There are 3 mountains u,y,z that from one site have been measured as 2474 ft., 3882 ft., and 4834 ft.. But from u, y looks 1422 ft.
數值方法 2008, Applied Mathematics NDHU 1 Spline interpolation.
Cojugate Gradient Method Zhengru Zhang ( 张争茹 ) Office: Math. Building 413(West) 2010 年教学实践周
Classification and Prediction: Regression Via Gradient Descent Optimization Bamshad Mobasher DePaul University.
Methods For Nonlinear Least-Square Problems
Why Function Optimization ?
An Introduction to Optimization Theory. Outline Introduction Unconstrained optimization problem Constrained optimization problem.
9 1 Performance Optimization. 9 2 Basic Optimization Algorithm p k - Search Direction  k - Learning Rate or.
Collaborative Filtering Matrix Factorization Approach
Secant Method Another Recursive Method. Secant Method The secant method is a recursive method used to find the solution to an equation like Newton’s Method.
數值方法 2008, Applied Mathematics NDHU1  An iterative approach for root finding  Newton method Lecture 3II Root Finding.
Roots of a Polynomial: Root of a polynomial is the value of the independent variable at which the polynomial intersects the horizontal axis (the function.
First, some left-overs… Lazy languages Nesting 1.
數值方法 2008, Applied Mathematics NDHU 1 Simpson rule Composite Simpson rule.
數值方法 2008 Applied Mathematics, NDHU1  Bisection method for root finding  Binary search  fzero Lecture 4.
數值方法 2008 Applied Mathematics, NDHU1  Bisection method for root finding  Binary search  fzero Lecture 4.
84 b Unidimensional Search Methods Most algorithms for unconstrained and constrained optimisation use an efficient unidimensional optimisation technique.
Newton's Method for Functions of Several Variables Joe Castle & Megan Grywalski.
Numerical Methods Applications of Loops: The power of MATLAB Mathematics + Coding 1.
Application of Differential Applied Optimization Problems.
3.5 – Solving Systems of Equations in Three Variables.
Start Presentation October 4, 2012 Solution of Non-linear Equation Systems In this lecture, we shall look at the mixed symbolic and numerical solution.
Nonlinear least squares Given m data points (t i, y i ) i=1,2,…m, we wish to find a vector x of n parameters that gives a best fit in the least squares.
數值方法 2008, Applied Mathematics NDHU1  Looping for loop while loop  Break and return  Recursion Lecture 2 Iteration.
Techniques of Differentiation. I. Positive Integer Powers, Multiples, Sums, and Differences A.) Th: If f(x) is a constant, B.) Th: The Power Rule: If.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 31.
Multivariate Unconstrained Optimisation First we consider algorithms for functions for which derivatives are not available. Could try to extend direct.
Sec 15.6 Directional Derivatives and the Gradient Vector
數值方法 2008, Applied Mathematics NDHU 1 Numerical Integration.
Section 15.6 Directional Derivatives and the Gradient Vector.
Newton’s Method, Root Finding with MATLAB and Excel
5. Nonlinear Functions of Several Variables
數值方法 2008 Applied Mathematics, NDHU1  Lagrange polynomial  Polynomial interpolation Lecture 4II.
數值方法 2008, Applied Mathematics NDHU1 Chaos time series.
Chapter 2-OPTIMIZATION
Chapter 2-OPTIMIZATION G.Anuradha. Contents Derivative-based Optimization –Descent Methods –The Method of Steepest Descent –Classical Newton’s Method.
MA2213 Lecture 2 Interpolation.
數值方法 2008, Applied Mathematics NDHU 1 Numerical Differentiation.
Root Finding UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
The Substitution Method Objectives: To solve a system of equations by substituting for a variable.
The formulae for the roots of a 3rd degree polynomial are given below
數值方法, Applied Mathematics NDHU 1 Linear system. 數值方法, Applied Mathematics NDHU 2 Linear system.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 - Chapter 7 Optimization.
MA2213 Lecture 9 Nonlinear Systems. Midterm Test Results.
數值方法 2008, Applied Mathematics NDHU 1 Numerical Integration.
Adavanced Numerical Computation 2008, AM NDHU
Lecture 3 Taylor Series Expansion
A system of nonlinear equations
Differentiating Polynomials & Equations of Tangents & Normals
Announcements HW4 due today (11:59pm) HW5 out today (due 11/17 11:59pm)
Arithmetic Sequences and Series
ENGG 1801 Engineering Computing
Solving Nonlinear Equation
Collaborative Filtering Matrix Factorization Approach
Outline Single neuron case: Nonlinear error correcting learning
Chapter 10. Numerical Solutions of Nonlinear Systems of Equations
Opener Perform the indicated operation.
Instructor :Dr. Aamer Iqbal Bhatti
Symbolic matlab toolbox
Performance Optimization
Find the set of points (x, y) such that F(x, y) = 0 if F(x, y) = (r - 4)x, {image} , and r = |x|
Presentation transcript:

數值方法 2008, Applied Mathematics NDHU 1 Nonlinear systems Newton’s method The steepest descent method

數值方法 2008, Applied Mathematics NDHU 2 Nonlinear systems A general system of n nonlinear equations in n unknowns

數值方法 2008, Applied Mathematics NDHU 3 Example

4 myfun function F = myfun(x) F(1) = 3*x(1)-cos(x(2)*x(3))-1/2; F(2) = x(1).^2 -81*(x(2)+0.1).^2+sin(x(3))+1.06; F(3) = exp(-x(1)*x(2))+20*x(3)+1/3*(10*pi-3); return

數值方法 2008, Applied Mathematics NDHU 5

6 x0= rand(1,3)-0.5; x = y=myfun(x); sum(y.^2); Solve nonlinear systems

數值方法 2008, Applied Mathematics NDHU 7 Demo_ex1 demo_ex1.m

數值方法 2008, Applied Mathematics NDHU 8 Newton’s method -Tangent line x xnxn y=f(x) y n =f(x n ) x n+1

數值方法 2008, Applied Mathematics NDHU 9 Updating rule

數值方法 2008, Applied Mathematics NDHU 10 Newton’s method

數值方法 2008, Applied Mathematics NDHU 11 Flow Chart n=0 x 0 n=0; guess x 0 Halting condition T F

數值方法 2008, Applied Mathematics NDHU 12 Matlab coding Matlab modules: 1.3-variable function evaluation 2.Use symbolic differentiation to determine partial derivatives 3.Evaluate partial derivatives 4.Main program: use a while loop to update x iteratively

數值方法 2008, Applied Mathematics NDHU 13 Function evaluation s1='3*x1-cos(x2*x3)-1/2'; f=inline(s1); x=rand(1,3); y=f(x(1),x(2),x(3));

數值方法 2008, Applied Mathematics NDHU 14 Evaluation of vector function s1='3*x1-cos(x2*x3)-1/2'; s2='x1.^2 -81*(x2+0.1).^2+sin(x3)+1.06'; s3='exp(-x1*x2)+20*x3+1/3*(10*pi-3)'; f1=inline(s1); f2=inline(s2);f3=inline(s3); x=rand(1,3); Y=f1(x(1),x(2),x(3)); Y=[Y f2(x(1),x(2),x(3))]; Y=[Y f3(x(1),x(2),x(3))];

數值方法 2008, Applied Mathematics NDHU 15 Variant function form s='x1+x2'; f=inline(s); x=rand(1,3); y=f(x(1),x(2),x(3)); Error message: Too many input to inline function s='x1+x2'; f=inline(s); x=rand(1,3); y=f(x(1),x(2)); Correct codes

數值方法 2008, Applied Mathematics NDHU 16 s='x1+x3'; f=inline(s); x=rand(1,3); y=f(x(1),x(3)); Correct codes s='x2+x3'; f=inline(s); x=rand(1,3); y=f(x(2),x(3)); Correct codes

數值方法 2008, Applied Mathematics NDHU 17 s='1'; f=inline(s); x=rand(1,3); y=f(0); Correct codes s='x1+x2+x3'; f=inline(s); x=rand(1,3); y=f(x(1),x(2),x(3)); Correct codes

數值方法 2008, Applied Mathematics NDHU 18 symvar sc=symvar(f); f denotes an inline function f denotes an inline function sc is a cell structure sc is a cell structure Symbols in f Symbols in f

數值方法 2008, Applied Mathematics NDHU 19 Symbols in an inline function s='x1+x2'; f=inline(s); s='x1+x3'; f=inline(s); s='x2+x3'; f=inline(s); s='1'; f=inline(s); s='x1+x2+x3'; f=inline(s); sc=symvar(f); sc = 'x1' 'x2' sc = 'x1' 'x3' sc = 'x2' 'x3' sc = 'x' sc = 'x1' 'x2' 'x3' y=f(x(1),x(2)); y=f(x(1),x(3));y=f(x(2),x(3));y=f(0);y=f(x(1),x(2),x(3));

數值方法 2008, Applied Mathematics NDHU 20 3-variable function evaluation f: an inline function f: an inline function xx: a string for 3-variable function evaluation xx: a string for 3-variable function evaluation xx=fun3v(f)

數值方法 2008, Applied Mathematics NDHU 21 function xx=fun3v(f) s=symvar(f);xx=[]; for i=1:size(s,1) if i>1 xx=[xx ',']; end arg=char(s(i)); switch arg case 'x' xx=[xx '0']; case 'x1' xx=[xx 'x(1)']; case 'x2' xx=[xx 'x(2)']; case 'x3' xx=[xx 'x(3)']; end xx=['f(' xx ')']; return Newton\fun3v.m

數值方法 2008, Applied Mathematics NDHU 22 example s='x1+x2'; f=inline(s); s='x1+x3'; f=inline(s); s='x2+x3'; f=inline(s); s='1'; f=inline(s); s='x1+x2+x3'; f=inline(s); xx=fun3v(f) x=[1 2 3] eval(xx)

數值方法 2008, Applied Mathematics NDHU 23 3-variable function evaluation function v=feval3v(f,x) xx=fun3v(f); eval(xx) return

數值方法 2008, Applied Mathematics NDHU 24 Matlab codes function v=feva(f,x) s=symvar(f); xx=[]; for i=1:size(s,1) ss=char(s(i)); switch ss case 'x' xx=[xx 0]; case 'x1' xx=[xx x(1)]; case 'x2' xx=[xx x(2)]; case 'x3' xx=[xx x(3)]; end xx=['f(' xx ')']; v=eval([sprintf(xx)]); return feva.m

數值方法 2008, Applied Mathematics NDHU 25 Partial derivation s='3*x1-cos(x2*x3)-1/2';fx=inline(s);x1=sym('x1');x2=sym('x2');x3=sym('x3');J1=inline(diff(s,x1))J2=inline(diff(s,x2))J3=inline(diff(s,x3))

數值方法 2008, Applied Mathematics NDHU 26 function [J1,J2,J3]=pdiff(s) Newton\pdiff.m

數值方法 2008, Applied Mathematics NDHU 27 Example s='3*x1-cos(x2*x3)-1/2'; [J1 J2 J3]=pdiff(s) J1 = Inline function: J1(x) = 3 J2 = Inline function: J2(x2,x3) = sin(x2.*x3).*x3 J3 = Inline function: J3(x2,x3) = sin(x2.*x3).*x2

數值方法 2008, Applied Mathematics NDHU 28 Partial derivatives s1='3*x1-cos(x2*x3)-1/2'; s2='x1^2 -81*(x2+0.1)^2+sin(x3)+1.06'; s3='exp(-x1*x2)+20*x3+1/3*(10*pi-3)'; [J1 J2 J3]=pdiff(s1); [J4 J5 J6]=pdiff(s2); [J7 J8 J9]=pdiff(s3);

數值方法 2008, Applied Mathematics NDHU 29 Newton\demo.m

數值方法 2008, Applied Mathematics NDHU 30 Function x=Newton(s1,s2,s3,x0) s1: string of function f1 s2: string of function f2 s3: string of function f3 x0: initial guess

數值方法 2008, Applied Mathematics NDHU 31 % % Determine F(1), F(2), F(3) by substituting x to f1, f2 and f3 % % Determine J by substituting x to J1, J2,…, J9 % % Update x

數值方法 2008, Applied Mathematics NDHU 32 Exercise Write matlab codes to implement the Newton’s method for solving a three- variable nonlinear system Write matlab codes to implement the Newton’s method for solving a three- variable nonlinear system Test your matlab function with the following nonlinear system Test your matlab function with the following nonlinear system

數值方法 2008, Applied Mathematics NDHU 33 The steepest descent method is translated to minimize

數值方法 2008, Applied Mathematics NDHU 34 Gradient

數值方法 2008, Applied Mathematics NDHU 35 Iterative process

數值方法 2008, Applied Mathematics NDHU 36

數值方法 2008, Applied Mathematics NDHU 37 Newton’s method Steepest gradient descent method

數值方法 2008, Applied Mathematics NDHU 38 Steepest descent Choose to minimize Choose to minimize

數值方法 2008, Applied Mathematics NDHU 39

數值方法 2008, Applied Mathematics NDHU 40 Quadratic polynomial:

數值方法 2008, Applied Mathematics NDHU 41

數值方法 2008, Applied Mathematics NDHU Create three nonlinear inline functions 2. Create nine inline functions for partial derivatives of the three nonlinear functions 3. Set x to x0 4. While the halting condition is not satisfied  Substitute x to all partial derivatives to form a 3x3 matrix J  Substitute x to the three nonlinear functions  Find optimal  Update x by the steepest descent method 5. Return x Function x=Steepest(s1,s2,s3,x0)