【问题标题】:Writing a system of general equilibrium function编写一个一般均衡函数系统
【发布时间】:2020-10-08 05:45:34
【问题描述】:

我正在尝试创建一个方程组,它在理论上代表下面看到的函数(我们知道 Kt、alpha 和 beta,但不知道 Kt+q) - 非常感谢任何帮助:

我应该如何表示并将其传递到我的 newton raphson 代码中(这里的任何输入也值得赞赏):

% newton raphson 
function I = NR(f,x0) 
    x=x0; %starting point 
    fx=f(x);  
    J = CDJac(f,x); 
    I = x - fx/J;     
end 

% the jacobian below is validated;

function [DCD] = CDJac(f,xbar)%the jacobian 
    jk=length(xbar); %find the dimension of x
    hstar=eps^(1/3); %choose value of h based upon Heer and Maussner machine eps
    e=zeros(1,jk); %1 x j vector of zeros; j coresspond to the derivative 
    %with respect to the jth varibale. If j=1, I am taking the derivative of
    %this multivraite function with respect to x1. Creates a bunch of zeros. AS
    %we go through and evlaute everything. We replace that zeros with a one. 
    for j=1:length(xbar) %if j is 1:10. xbar is the vector of 
        %10 different points. you have 10 differetn x s. 
        e(j)=1; %replace the jth entry to 1 in the zero vector. (1,0). In a 
        %of loop, j become 2 after it is done with 1. We then take the second
        %element of it and change it to a 1- (0,1). 
        fxbarph=f([xbar+e.*hstar]); %function evaluated at point xbar plus h
        fxbarmh=f([xbar-e.*hstar]); %function evaluated at point xbar minus h
        DCD(:,j)=(fxbarph-fxbarmh)./(2*hstar);
        e=zeros(1,jk); %create the ej row vector of zeros. For instance, when j
        %goes to 2, you need to have 0s everywhere except the second column. 
    end
end

【问题讨论】:

    标签: matlab math newtons-method


    【解决方案1】:

    我认为您需要执行以下步骤:

    1. 将每个函数表示为 f(k) = 0:从每个方程的两边减去 RHS。
    2. 计算线性增量的雅可比:J*dk = f
    3. 对未知的 k 向量进行初步猜测
    4. 求解未知增量向量 dk
    5. 更新向量 k:k(new) = k(old) + dk
    6. 迭代收敛

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-17
      • 1970-01-01
      相关资源
      最近更新 更多