solution to a single nonlinear equation with a parameter

1 次查看(过去 30 天)
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)

回答(1 个)

Matt J
Matt J 2016-11-10
编辑:Matt J 2016-11-10
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 个评论
msh
msh 2016-11-10
I just make random guess, x= should be nearly 0.5 to 1.5. So I play with values in this interval.
Matt J
Matt J 2016-11-10
编辑:Matt J 2016-11-10
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Linear Least Squares 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by