2) Suppose one invests S500 per month for 5 years. If the desired total amount a
ID: 3167484 • Letter: 2
Question
2) Suppose one invests S500 per month for 5 years. If the desired total amount after 5 years were 60,000, then the required annual interest rate I could be determined by the following equation: 60 500 1/12 -| | = 60,000 12 a) First, rewrite the equation in the form f(I) 0, where f(I) is a polynomial. b) Write and run a script m-file, called newtl.m, that performs Newton's Method. Use this script to find an estimate for I. Your script will call two function m-files, fnewt.m and fpnewt.m, which are a relevant function f(I) and its derivative, respectively. Use initial guess 2, and run the loop until the relative error estimate, for the latest root estimate, x, is less than a tolerance (TOL) of 10. Store all iterates in a vector, and display this vector as a column. c) Now, modify newtI.m to a new script, newt2.m, by adding lines to compute the ratios e/e, and e.(e2) for each iteration. Use your final estimate from part (a) (all 16 digits) for the exact root in the errors. Store each of these ratios in 2 vectors and display the ratios for all i as column vectors. Use the same initial guess x, -2 Do these ratios indicate whether this is a simple or multiple root? If so, state which one and why What are the estimated rate and order of convergence for the root? d) Using only the first 3 significant digits of your final root estimate from part (a), also theoretically determine whether or not this is a simple root. Does this confirm your results from part (b)? (b)? detstExplanation / Answer
%%% Matlab function
function [y] = fnewt(f,g)
y=subs(f,g);
%%% matlab function
function [y] = fpnewt(f,g)
y=subs(diff(f),g);
%% Main program:
clc;
clear all;
close all;
format long
% % % % % restoredefaultpath %%%%%
syms x
f=500*12/x*((1+x/12)^60-1)-60000;
i(1)=2;
for n= 1:100
l1=fnewt(f,i(n));
l2=fpnewt(f,i(n));
i(n+1)=i(n)- l1/l2;
e(n)=abs((i(n+1)-i(n))/i(n+1));
if (e(n) < 10^(-6))
break;
end
end
i'
fprintf('roots of the equation is %f : ',i(n+1));
for k=1:n-1
h(k,1)=e(k+1)/e(k);
h(k,2)=e(k+1)/(e(k))^2;
end
h
f1=subs(f,i(end)+0.001);
f2=subs(f,i(end)-0.001);
%%% if simple roots present then ane of these value should be -ve
%%% for simple roots graph should cross f(i)=0 line
if (f1*f2 < 0)
fprintf(' Simple roots present at i= %f ',i(end));
else
fprintf(' multiple roots present at i= %f ',i(end));
end
OUTPUT:
ans =
2.000000000000000
1.736386065429187
1.474146131924037
1.213253199857063
0.955298272811338
0.706768072636996
0.486144806610242
0.329917039458133
0.265981966008257
0.257662666321322
0.257540299774276
0.257540273830707
roots of the equation is 0.257540 :
h =
1.171753387176868 7.718166556429968
1.208794789621090 6.795075561498577
1.255723340566579 5.839599980755704
1.302259133557487 4.822725874197940
1.290575486509408 3.670127608447382
1.043440815065403 2.299228646119721
0.507613890010079 1.071963549327926
0.134322354539096 0.558806332914857
0.014715744395214 0.455771288504995
0.000212015232824 0.446220539326170
Simple roots present at i= 0.257540
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.