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)
0 件のコメント
回答 (1 件)
  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 件のコメント
  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 Center および File Exchange で Linear Programming and Mixed-Integer Linear Programming についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

