How to solve unique positive root
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
madhan ravi
le 11 Avr 2019
Modifié(e) : madhan ravi
le 11 Avr 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().
Réponses (1)
Torsten
le 11 Avr 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 commentaires
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!