Example: dental hygienist

Minimizing & Maximizing Functions

!6!4!202!40!20020406080xx3+5*x2 Minimizing & Maximizing FunctionsExample: find the minimum of y=3x2 2x+1 Minima & maxima occur in Functions where the slope changes sign ( where the slope is zero). Local vs. Global min & max. Polynomials: we can find all min & max (global & local) General Functions : iterative procedure; may only find local Functions may have zero to many minima and , November 17, 2008 Min & Max of Functions - a cell containing the independent variable (x) a cell containing the function value at x, f(x). Tools the target cell to be f(x).

Minimizing & Maximizing Functions Example: find the minimum of y = 3x2 − 2x + 1 • Minima & maxima occur in functions where the slope changes sign (i.e. where the slope is zero). • Local vs. Global min & max. • Polynomials: we can find all min & max (global & local) • General functions: iterative procedure; may only find local min ...

Tags:

  Minimizing

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Minimizing & Maximizing Functions

1 !6!4!202!40!20020406080xx3+5*x2 Minimizing & Maximizing FunctionsExample: find the minimum of y=3x2 2x+1 Minima & maxima occur in Functions where the slope changes sign ( where the slope is zero). Local vs. Global min & max. Polynomials: we can find all min & max (global & local) General Functions : iterative procedure; may only find local Functions may have zero to many minima and , November 17, 2008 Min & Max of Functions - a cell containing the independent variable (x) a cell containing the function value at x, f(x). Tools the target cell to be f(x).

2 By Changing Cells to be either max or solve NOTE: You can also use solver to solve a nonlinear equation (choose to set target cell to a value rather than min/max).10 Monday, November 17, 2008 Min & Max of Functions - a MATLAB function to evaluate f(x) given the minimum using fmin=fminsearch(fun,x0) a MATLAB function to evaluate f(x) given the minimum using fmax=fminsearch(fun,x0) 11 Monday, November 17, 2008 Many Nonlinear Equations (uncoupled)f(t)=1 exp( at)Find when f(t)= for a=[ 1].function f = myExpFun(a,x)f=1-exp(-a*x); (t)clear; clc; close all; a = [ 1];f = ;figure; hold on; for i=1:length(a) res=@(t)( myExpFun(a(i),t) - f); tanswer = fzero(res, ); fanswer = myExpFun(a(i),tanswer); tt=linspace(0,20); plot(tt,myExpFun(a(i),tt),'b-'.)

3 Tanswer,fanswer,'ro' ); text( tanswer+ ,.. fanswer,.. strcat('a=',num2str(a(i))) );end hold off;xlabel('t'); ylabel('f(t)');12 Monday, November 17, 2008 Nonlinear Systems of EquationsExample:find the solution of the equations: Solve What condition(s) are we looking for, and how do we express these mathematically? Solve this using Excel Solve this using MATLABx= y 32y=x3+x2 6x+3!4!2024!10010203040xf1, f2y=2x2+3y=x3+x2 6x+3 Are all of these roots representative of the original system?r1=x y 32r2=y x3 x2+6x 313 Monday, November 17, 2008function res = nonlinSysDemo(X)% x=sqrt((y-3)/2)% y=x^3+x^2-6x+3%% X(1) is x% X(2) is y if ( max(size(X)) ~= 2 ) error('Invalid use of function nonlinSysDemo');end x = X(1);y = X(2);res = [ x-sqrt((y-3)/2); y-(x^3+x^2-6*x+3) ];Nonlinear Systems - MATLABx=fsolve(fun,xo) Solves for zero of fun near xo.

4 X and xo are vectors; fun takes a vector and returns the residual vector. if fun takes a scalar (vector of length 1) then this behaves like Requires the optimization toolbox - included in the student = [1 10];xy = fsolve('nonlinSysDemo',xyguess);14 Monday, November 17, 2008>> fsolve('nonlinSysDemo',[0,0])Maximum number of function evaluations reached: increase = - - >> fsolve('nonlinSysDemo',[10,30])Optimizat ion terminated: first-order optimality is less than = >> fsolve('nonlinSysDemo',[-10,3])Optimizer appears to be converging to a point which is not a root.

5 Norm of relative change in X is less than max( ^2,eps) but sum-of-squares of function values is greater than or equal to sqrt( ) Try again with a new starting = + + , November 17, 2008 Average value of =1nn i=1 i iValue predicted by the function. iObserved value (data).Regression RevisitedLinear Least-Squares Regression: solve a system of linear equations for the also formulate this as a optimization problem: pick the best value of the parameters to maximize R2 value. pick best value of the parameters to minimize sum of squared errors.

6 Works for problems where parameters enter linearly or ni=1( i i)2 ni=1( i )2 Maximize R2 or minimize by changing : These two options are entirely equivalent! =n i=1( i )2sum of squared , November 17, 2008! ! ! ! 10!4!8! !7! !6! !5! !1/RT (mol/J)log(k) (1/s) ln(A)= fitExample - Reaction Rate ConstantT (K)k (1/s) factorActivation energyTemperatureGas constantR= J/mol-KN=NClCl+ N2 Benzene diazonium chlorideChlorobenzenerate constant k=Aexp( EaRT)ln(k)=ln(A) EaRTWe rearranged this equation to get the parameters appearing linearly and solved it using the normal s solve this problem as a minimization problem for both the nonlinear and linear , November 17, 2008


Related search queries