필터 지우기
필터 지우기

solution to a single nonlinear equation with a parameter

조회 수: 4 (최근 30일)
msh
msh 2016년 11월 10일
편집: Matt J 2016년 11월 10일
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에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by