/h1><!--introduction--><!--/introduction--><pre class="codeinput"><span class="comment">% This file is from pmtk3.googlecode.com</span>

<span class="keyword">function</span> newtonsMethodNonConvex


figure(); hold <span class="string">on</span>;
xmin   = -4;  xmax = 13;
ymin   = -50; ymax = 600;
domain = xmin:0.01:xmax;
f = @(x)-x.^3 + 15*x.^2;
Xk = 8;
f1 = @(x) -3*x.^2 + 30*x;
f2 = @(x) -6*x + 30;
t = @(x) f(Xk) + f1(Xk)*(x - Xk) + (1/2)*f2(Xk)*(x - Xk).^2;
[val, maxNDX] = max(t(domain));
maximum = domain