{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture17

# Lecture17 - MATLAB Function optimset The function optimset...

This preview shows pages 1–9. Sign up to view the full content.

The function optimset creates an options structure that you can pass as an input argument to the following four MATLAB optimization functions: fminbnd (single variable) fminsearch (multi-variables) fzero lsqnonneg Example: options = optimset('Display','iter','TolFun',1e-8) This statement creates an optimization options structure in which the Display parameter is set to 'iter' and the TolFun parameter is set to 1e-8. MATLAB Function: optimset

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
>> options =optimset( 'display','iter' ); >> [x fx]=fzero(@x x^10-1,0.5, options ) >> [x fx]=fzero('manning',50,options) Func-count x f(x) Procedure 1 50 -14569.8 initial 2 48.5858 -14062 search 3 51.4142 -15078.3 search 4 48 -13851.9 search ... ... ... 19 72.6274 -22769.2 search 20 18 -3457.1 search 21 82 -26192.5 search 22 4.74517 319.67 search Looking for a zero in the interval [4.7452, 82] 23 5.67666 110.575 interpolation 24 6.16719 -5.33648 interpolation 25 6.14461 0.0804104 interpolation 26 6.14494 5.51498e-005 interpolation 27 6.14494 -1.47793e-012 interpolation 28 6.14494 3.41061e-013 interpolation 29 6.14494 -5.68434e-013 interpolation Zero found in the interval: [4.7452, 82]. x = 6.14494463443476 fx = 3.410605131648481e-013 fzero and optimset functions Find sign change after 22 iterations Switch to secant (linear) or inverse quadratic interpolation to find root Search in both directions x 0 ± x for sign change
Root of Polynomials Bisection, false-position, Newton-Raphson, secant methods cannot be easily used to determine all roots of higher-order polynomials MATLAB function: roots for polynomials; recast root finding in terms of an eigenvalue problem;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
MATLAB Function: roots Recast the root evaluation task as an eigenvalue problem (Chapter 20) x = roots(c) - roots c = poly(r) - inverse function [ ] 0 1 2 1 n n 0 1 2 2 1 n 1 n n n c c c c c c vector t coefficien c x c x c x c x c x p , , , , , ) ( - - - = + + + + + =
i 3 2 3 2 2 1 x 0 156 x 56 x 111 x 10 x 14 x 6 x x f r 2 3 4 5 6 ± - - = = + + - + + - = , , , , ) ( Roots of Polynomial Consider the 6 th -order polynomial >> c = [1 -6 14 10 -111 56 156]; >> r = roots(c) r = 2.0000 + 3.0000i 2.0000 - 3.0000i 3.0000 2.0000 -2.0000 -1.0000 >> polyval(c, r), format long g ans = 1.0e-011 * 0.204636307898909 + 0.025579538487364i 0.204636307898909 - 0.025579538487364i 0.090949470177293 0 0.090949470177293 -0.008526512829121 (4 real and 2 complex roots) Verify f ( x r ) =0

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
f ( x ) = x 5 - 11x 4 + 46x 3 - 90x 2 + 81x - 27 = ( x - 1 ) 2 ( x - 3 ) 3 >> c = [1 -11 46 -90 81 -27]; r = roots(c) r = 3.00003015641971 2.99998492179015 + 2.61163002529051e-005i 2.99998492179015 - 2.61163002529051e-005i 0.999999999999997 + 2.5458867322843e-008i 0.999999999999997 - 2.5458867322843e-008i
Chapter 7 Linear Algebraic Equations and Matrices

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Three individuals connected by bungee cords
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 31

Lecture17 - MATLAB Function optimset The function optimset...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online