MATLAB Answers

0

How to solve unique positive root

Asked by Egbert Jansen on 11 Apr 2019
Latest activity Answered by Torsten
on 11 Apr 2019
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

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().

Sign in to comment.

1 Answer

Answer by 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

Sign in to comment.