How to solve unique positive root
3 views (last 30 days)
Show older comments
I want to find the unique positive root. This is my current code. The result that i get contains imaginary numbers, that is not what i want.
Is there a solution for this?
------------------------------------------------------------------------------------------------------
d(1) = 0.95;
e(1) = 0.65;
interest = 0.05;
y = 0.02;
r = 0.37;
alpha = ((interest - y)/(1 + interest)) + 1;
%Calculating gamma, constant
syms gamma i x;
S1 = symsum((gamma^i)*(alpha^i), i, 1, 15); %Summation 1
S2 = symsum((alpha^i), i, 0, 15-1); %Summation 2
eqn = (S1 - ((0.6 - d(1)*(alpha^15) + r*S2) / e(1))) == 0;
solgamma = solve(eqn,gamma);
solgamma
vpa(solgamma)
1 Comment
madhan ravi
on 11 Apr 2019
Edited: madhan ravi
on 11 Apr 2019
Trying adding an assumption to the variable that your trying to solve. Also don’t name a variable gamma it may shadow the in-built function gamma().
Answers (1)
Torsten
on 11 Apr 2019
d(1) = 0.95;
e(1) = 0.65;
interest = 0.05;
y = 0.02;
r = 0.37;
alpha = ((interest - y)/(1 + interest)) + 1;
fun = @(gamma)alpha*gamma.*((alpha*gamma).^15-1)./(alpha*gamma-1)-(0.6-d(1)*alpha^15+r*(alpha^15-1)/(alpha-1))/e(1);
x0 = [0.9,0.95];
sol = fzero(fun,x0)
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!