Solving Nonlinear Systems of Equations and Optimization

Zeros and Minimums (fzero, fminsearch, fminbnd)
 fzero  Find root of continuous function of one variable.
 fminsearch  finds the minimum of a scalar function of several variables, starting at an initial estimate.
 fminbnd  Find minimum of singlevariable function on fixed interval.
Find root, local minimum, and local maximum for y = 4x^{3}  15x^{2} + 0.3x + 50.
File(s):
fzero_fmin_example.m  fzero  Find root of continuous function of one variable.

NonLinear Systems (fsolve)
fsolve  Solve system of nonlinear equations.
Solves a problem specified by
F(x) = 0
for x, where x is a vector and F(x) is a function that returns a vector value.Example:
 Find the intersection of a line y=2x5 and a parabola y=2x^{2}3x+15
 Find the intersections of a circle x^{2} + y^{2} = 8 and an ellipse (x^{2})/15 + (y^{2})/2 = 1
File(s):
nonlin_systems.mPractice:
Find a solution to this system of equations:x^{3} + 3y = 1/sin^{2}(2θ) y = e^{x} y = x + ln(θ)
This system of equations has multiple solutions  one is
X = 1.679 Y = 0.187 θ = 0.225 radians
File(s):
fsolve_practice.m 
Optimization (fmincon)
Matlab's method for solving optimization problems if part of the optimization toolbox. The documentation on fmincon is very long and complicated. The intent of this example is to provide a starting point on a general way of using this feature. Matlab also provides an interactive tool, accessible by the command optimtool, that provides a frontend interface. However, using the fmincon function from a program is much better if you want/need to document the solution and/or want to try the solution with several different parameters.
You are a radiologist planning a program of radiation therapy for a cancer patient. Your beam treatment machine can pass two beams of ionizing radiation through the patient's body. Your mission is to select the radiation dose from the two beams so as to minimize damage to healthy tissue, while subjecting the tumor to a large enough dose to kill cancer cells, and without overdosing sensitive tissues. The radiation dose received by various tissues as a result of a 1sec exposure from each beam is listed in the table below.
Area Beam 1 dose
(krad/sec)Beam 2 dose
(krad/sec)Constraint Healthy tissue 0.70.3minimize Sensitive tissues 0.50.2no more than 1.5 kilorads of radiation Tumor center 3.00.6at least 6 kilorads of radiation Tumor edge 1.02.0at least 4 kilorads of radiation Use Matlab's optimization command  fmincon  to determine the optimal time required for each beam of radiation.
Answer: Beam 1 = 1.78 sec, Beam 2 = 1.11 sec

Another Optimization Example
This example comes from the Matlab help file. It is under the section "Example: Nonlinear Inequality Constraints".
Find the minimum z and corresponding values for x and y for this equation and constraints:
It turns out this set of equation and constraints has two local minimums. The one that Matlab will find depends upon the starting values you use.
Using starting values of x=1, y=1, you should get the answer
z=0.0236 at x=9.5474, y=1.0474Using other starting values might you give the answer
z=3.0608 at x=1.1825, y=1.7398Obviously, the first z value is smaller, so you would use that as the 'better' answer. You should always try several different combinations of starting values and compare the results when you are evaluating your solution. Be careful to watch the results in the command window. Clicking on the links that fmincon displays will help you determine if you have a 'good' answer or not.
For the two solutions posted, the opt2.m is a basic solution to this problem. The opt2plot.m solution tries to show visually what is happening with different starting points. Running this solution will show a surface plot that is filtered based on the constraints.
 Graded Items
 References