You buy a $35,000 vehicle for nothing down at $8,500 per year for 7 years. Use t
ID: 3752785 • Letter: Y
Question
You buy a $35,000 vehicle for nothing down at $8,500 per year for 7 years. Use the bisect function (given) to determine the interest rate that you are paying. Use initial guesses for the interest rate of 0.01 and 0.3 and a stopping criterion of 0.00005. The formula relating present worth P, annual payments A, number of years n, and interest rate i is
A = P*(i(1+i)^n)/((1+i)n 1)
Remember, this is a root finding method, you need to have a function that is set equal to zero.
Go ahead and plot the function to be sure that intial guesses properly bracket the root.
Also, be sure to use function handle notation for the input function. As an example, if I want to find the root of x^2=52: first set equal to zero, x^2-52=0, and then to save as a function handle, f=@(x) x^2-52.
*This is what I've gotten so far. But I keep getting errors:
clear,
clc,
clf,
format short gP=35000; A=8500; n=7; f=@(irate)P*irate.*(1+irate).^n./((1+irate).^n-1)-A;
iplot=linespace(0.01,.2);fplot=f(iplot);
plot(iplot,fplot),grid[xr,fx,ea,iter]=bisect(f,0.01,.3,0.00005)
Explanation / Answer
You are getting error beacause in function f:
f=@(irate) means you are passing only 1 value i.e irate, but
your function definition has
f=@(irate)P*irate.*(1+irate).^n./((1+irate).^n-1)-A;
so you need to pass A,P,n also in funtion so correct function defenition will be:
f=@(irate,P,A,n)P*irate.*(1+irate).^n./((1+irate).^n-1)-A;
then when you are calling f then you should called it as f(irate,P,A,n ) then it will work.
Please give thumbs up, thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.