Optimization 
Newton's Method

Sri Harsha Garapati, Autar Kaw
University of South Florida
United States of America
kaw@eng.usf.edu

Introduction

This worksheet demonstrates the use of Mathematica to illustrate the Newton's method of solving optimization problems.

Problem Statement

Mathematica worksheet to solve the the cross-sectional area of a gutter with equal base and edge length of 2 is given by, A=4*sin(theta)*(1+cos(theta)). Use an initial interval of (0,pi/2).Use an initial interval epsilon=0.2.

Input

The following are the inputs to this problem
      a) Function to be optimized, A
      b) Lower limit of the range, xl
      c) Upper limit of the range, xu
      d) Initial guess, xi
      e) Allowable tolerance, tol

A[theta_]=4*Sin[theta]*(1+Cos[theta]);
xl=0.0;
xu=Pi/2.0;
xi=Pi/4.0;
tol=1;
Print["Lower limit of theta=",xl];
Print["Upper limit of theta =",xu];
Print["Initial guess of theta=",xi];
Print["Allowable tolerance=",tol];

Newton's Method

programming Newton's method

epsa=tol+100;
iteration=0;
xval=xi;
While[epsa>tol,
iteration=iteration+1;
dA=A'[theta];
d2A=A''[theta];
dAval=A'[xval];
d2Aval=A''[xval];
xold=xval;
xval=xval-(dAval/d2Aval);
epsa=Abs[(xval-xold)/xval]*100;
Aval=A[xval];
Print["Iteration Number=",iteration];
Print["Optimized Theta=",xval];
]