In: Advanced Math
Write The MATLAB SCRIPT for:
An open-top box is constructed from a rectangular piece of sheet
metal measuring 10 by 16 inches. Square of what size (accurate to
10-9 inch) should be cut from the corners if the volume
of the box is to be 100 cubic inches?
Notes: to roughly estimate the locations of the
roots of the equation and then approximate the roots to this
equation using Newton Iteration
method.
Please don't give me the Matlab Commands for this. I need "Matlab Script" as its solution.



%%Matlab code for finding root using Newton method
clear all
close all
%Function for which root have to find
fun=@(x) x.*(10-2.*x).*(16-2.*x)-100;
%plotting of the function
xx=linspace(0,4,1001);
yy=fun(xx);
plot(xx,yy)
xlabel('x')
ylabel('y')
title('f(x) vs x plot')
%displaying the function
fprintf('For the function\n')
disp(fun)
[root]=newton_method(fun,0,1000);
fprintf('Value of x =%f.\n',root)
%Matlab function for Newton Method
function [root]=newton_method(fun,x0,maxit)
syms x
g1(x) =diff(fun,x);   %1st Derivative of this
function
xx=x0;           
%initial guess]
%Loop for all intial guesses
    n=eps; %error limit for close itteration
    for i=1:maxit
       
x2=double(xx-(fun(xx)./g1(xx))); %Newton Raphson Formula
       
cc=abs(fun(x2));                
%Error
        err(i)=cc;
        xx=x2;
        if cc<=n
           
break
        end
      
    end
    root=xx;
end
%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%