solution to a single nonlinear equation with a parameter
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to get the solution to a nonlinear single equation, that carries a parameter the functional form is complicated:
the function that I want to solve is:
w = (1-alpha)*A*x^alpha;
r = alpha*A*x^(alpha-1);
xs = d2*(1+r);
d1*(w-(r-n)*b)/(1-xs)=(1+n)*(x+b); % this is the function I looking
The parameter that I want to experiment in order to find different solutions is the b,
I have created this function
function y = f(x,b)
global alpha A d1 d2 n
w = (1-alpha)*A*x^alpha;
r = alpha*A*x^(alpha-1);
xs = d2*(1+r);
y = d1*(w-(r-n)*b)/(1-xs)-(1+n)*(x+b);
end
where the other parameters of the equations are:
global alpha d1 d2 n debt
beta =0.3; % discount factor
delta =0.10; % altruism
A =9.37; % TFP
alpha =0.3; % income share of capital
n =1.81; % growth rate of population
d1 =(1+delta)*beta/(1+(1+delta)*beta); % MPS
d2 =delta/(1+n)*(1+delta); % degree affecting altruism
Can someone assist me with how to call fzero, in order to look for solutions at different values of b ? As guidance, b is between (0,0.10)
0 Kommentare
Antworten (1)
Matt J
am 10 Nov. 2016
Bearbeitet: Matt J
am 10 Nov. 2016
Get rid of the global variables (because they're just bad) and redefine the function as follows
function y = f(x,b, alpha, A, d1, d2, n)
w = (1-alpha)*A*x^alpha;
r = alpha*A*x^(alpha-1);
xs = d2*(1+r);
y = d1*(w-(r-n)*b)/(1-xs)-(1+n)*(x+b);
end
Then to use fzero,
beta =0.3; % discount factor
delta =0.10; % altruism
A =9.37; % TFP
alpha =0.3; % income share of capital
n =1.81; % growth rate of population
d1 =(1+delta)*beta/(1+(1+delta)*beta); % MPS
d2 =delta/(1+n)*(1+delta); % degree affecting altruism
xsol = fzero(@(x) f(x,b, alpha, A, d1, d2, n) , x0)
4 Kommentare
Matt J
am 10 Nov. 2016
Bearbeitet: Matt J
am 10 Nov. 2016
x= should be nearly 0.5 to 1.5. So I play with values in this interval.
Did you plot your function to verify if this is true? When I plot it, I see that it comes nowhere near zero in the interval [0.5,1.5] and in fact appears to decrease monotonically in [0.5,inf] starting from a value of about -0.8 at x=0.5.
Siehe auch
Kategorien
Mehr zu Linear Least Squares finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!