楼主: chenxinxiaolang
4192 3

求kmv模型非线性方程组的求解方法…… [推广有奖]

  • 0关注
  • 0粉丝

已卖:102份资源

讲师

6%

还不是VIP/贵宾

-

威望
0
论坛币
1610 个
通用积分
0.0001
学术水平
13 点
热心指数
23 点
信用等级
12 点
经验
4153 点
帖子
484
精华
0
在线时间
186 小时
注册时间
2008-11-3
最后登录
2016-4-5

楼主
chenxinxiaolang 发表于 2009-12-25 22:47:22 |AI写论文
10论坛币
matlab和eviews哪个上手比较快 或者比较简单,希望懂的朋友能较详细地告诉我解决方法……
谢谢啦…………

关键词:非线性方程组 线性方程组 KMV模型 非线性方程 线性方程 方程 模型 求解 非线性 KMV

回帖推荐

firewarpk 发表于2楼  查看完整内容

我更喜欢用matlab, 参考help: Symbolic Math Toolbox™ Linear Algebra Integral Transforms and Z-Transforms Provide feedback about this page Solving Equations On this page… Solving Algebraic Equations Several Algebraic Equations Single Differential Equation Several Differential Equations Solving Algebraic Equations If S is a symbolic expression, solve(S) attempt ...

本帖被以下文库推荐

不解释……

沙发
firewarpk 发表于 2009-12-25 23:01:08
我更喜欢用matlab, 参考help:

Symbolic Math Toolbox™        Linear Algebra   Integral Transforms and Z-Transforms
        Provide feedback about this page
Solving Equations
On this page…

Solving Algebraic Equations

Several Algebraic Equations

Single Differential Equation

Several Differential Equations
Solving Algebraic Equations

If S is a symbolic expression,

solve(S)

attempts to find values of the symbolic variable in S (as determined by symvar) for which S is zero. For example,

syms a b c x
S = a*x^2 + b*x + c;
solve(S)

uses the familiar quadratic formula to produce

ans =
-(b + (b^2 - 4*a*c)^(1/2))/(2*a)
-(b - (b^2 - 4*a*c)^(1/2))/(2*a)

This is a symbolic vector whose elements are the two solutions.

If you want to solve for a specific variable, you must specify that variable as an additional argument. For example, if you want to solve S for b, use the command

b = solve(S,b)

which returns

b =
-(a*x^2 + c)/x

Note that these examples assume equations of the form f(x)  =  0. If you need to solve equations of the form f(x)  =  q(x), you must use quoted strings. In particular, the command

s = solve('cos(2*x)+sin(x)=1')

returns a vector with three solutions.

s =
         0
     pi/6
(5*pi)/6

There are also solutions at each of these results plus kπ for integer k, as you can see in the MuPAD solution:

Back to Top of Page Back to Top
Several Algebraic Equations

This section explains how to solve systems of equations using Symbolic Math Toolbox software. As an example, suppose you have the system

and you want to solve for x and y. First, create the necessary symbolic objects.

syms x y alpha

There are several ways to address the output of solve. One is to use a two-output call

[x,y] = solve(x^2*y^2, x-y/2-alpha)

which returns

x =
alpha
     0

y =
          0
(-2)*alpha

Modify the first equation to x2y2 = 1 and there are more solutions.

eqs1 = 'x^2*y^2=1, x-y/2-alpha';
[x,y] = solve(eqs1)

produces four distinct solutions:

x =
alpha/2 + (alpha^2 + 2)^(1/2)/2
alpha/2 + (alpha^2 - 2)^(1/2)/2
alpha/2 - (alpha^2 + 2)^(1/2)/2
alpha/2 - (alpha^2 - 2)^(1/2)/2

y =
   (alpha^2 + 2)^(1/2) - alpha
   (alpha^2 - 2)^(1/2) - alpha
- alpha - (alpha^2 + 2)^(1/2)
- alpha - (alpha^2 - 2)^(1/2)

Since you did not specify the dependent variables, solve uses symvar to determine the variables.

This way of assigning output from solve is quite successful for "small" systems. Plainly, if you had, say, a 10-by-10 system of equations, typing

[x1,x2,x3,x4,x5,x6,x7,x8,x9,x10] = solve(...)

is both awkward and time consuming. To circumvent this difficulty, solve can return a structure whose fields are the solutions. In particular, consider the system u^2-v^2 = a^2, u + v = 1, a^2-2*a = 3. The command

S = solve('u^2-v^2 = a^2','u + v = 1','a^2-2*a = 3')

returns

S =
    a: [2x1 sym]
    u: [2x1 sym]
    v: [2x1 sym]

The solutions for a reside in the "a-field" of S. That is,

S.a

produces

ans =
-1
  3

Similar comments apply to the solutions for u and v. The structure S can now be manipulated by field and index to access a particular portion of the solution. For example, if you want to examine the second solution, you can use the following statement

s2 = [S.a(2), S.u(2), S.v(2)]

to extract the second component of each field.

s2 =
[  3,  5, -4]

The following statement

M = [S.a, S.u, S.v]

creates the solution matrix M

M =
[ -1, 1,  0]
[  3, 5, -4]

whose rows comprise the distinct solutions of the system.

Linear systems of simultaneous equations can also be solved using matrix division. For example,

clear u v x y
syms u v x y
S = solve(x+2*y-u, 4*x+5*y-v);
sol = [S.x;S.y]

and

A = [1 2; 4 5];
b = [u; v];
z = A\b

result in

sol =

(2*v)/3 - (5*u)/3
     (4*u)/3 - v/3

z =
(2*v)/3 - (5*u)/3
     (4*u)/3 - v/3

Thus s and z produce the same solution, although the results are assigned to different variables.

Back to Top of Page Back to Top
Single Differential Equation

The function dsolve computes symbolic solutions to ordinary differential equations. The equations are specified by symbolic expressions containing the letter D to denote differentiation. The symbols D2, D3, ... DN, correspond to the second, third, ..., Nth derivative, respectively. Thus, D2y is the toolbox equivalent of d2y/dt2. The dependent variables are those preceded by D and the default independent variable is t. Note that names of symbolic variables should not contain D. The independent variable can be changed from t to some other symbolic variable by including that variable as the last input argument.

Initial conditions can be specified by additional equations. If initial conditions are not specified, the solutions contain constants of integration, C1, C2, etc.

The output from dsolve parallels the output from solve. That is, you can call dsolve with the number of output variables equal to the number of dependent variables or place the output in a structure whose fields contain the solutions of the differential equations.
Example 1

The following call to dsolve

dsolve('Dy=t*y')

uses y as the dependent variable and t as the default independent variable.

The output of this command is

ans =
C2*exp(t^2/2)

y = C*exp(t^2/2) is a solution to the equation for any constant C.

To specify an initial condition, use

y = dsolve('Dy=t*y', 'y(0)=2')

This produces

y =
2*exp(t^2/2)

Notice that y is in the MATLAB workspace, but the independent variable t is not. Thus, the command diff(y,t) returns an error. To place t in the workspace, enter syms t.
Example 2

Nonlinear equations may have multiple solutions, even when initial conditions are given:

x = dsolve('(Dx+x)^2=1','x(0)=0')

results in

x =
1/exp(t) - 1
1 - 1/exp(t)

Example 3

Here is a second-order differential equation with two initial conditions, and the default independent variable changed to x. The commands

y = dsolve('D2y=cos(2*x)-y','y(0)=1','Dy(0)=0', 'x');
simplify(y)

produce

ans =
(4*cos(x))/3 - (2*cos(x)^2)/3 + 1/3

Example 4

The key issues in this example are the order of the equation and the initial conditions. To solve the ordinary differential equation

with x as the independent variable, type

u = dsolve('D3u=u','u(0)=1','Du(0)=-1','D2u(0) = pi','x')

Use D3u to represent d3u/dx3 and D2u(0) for .

u =
(pi*exp(x))/3 - (cos((3^(1/2)*x)/2)*(pi/3 - 1))/exp(x/2) ...
- (3^(1/2)*sin((3^(1/2)*x)/2)*(pi + 1))/(3*exp(x/2))

Further ODE Examples

This table shows a few more examples of differential equations and their Symbolic Math Toolbox syntax. The final entry in the table is the Airy differential equation, whose solution is referred to as the Airy function.

Differential Equation
       

MATLAB Command

y(0) = 1
       

y = dsolve('Dy+4*y = exp(-t)', 'y(0) = 1')

2x2y′′ + 3xy′ – y = 0
( ′ = d/dx)
       

y = dsolve('2*x^2*D2y + 3*x*Dy - y = 0','x')

(The Airy equation)
       

y = dsolve('D2y = x*y','y(0) = 0', 'y(3) = besselk(1/3, 2*sqrt(3))/pi', 'x')

Back to Top of Page Back to Top
Several Differential Equations

The function dsolve can also handle several ordinary differential equations in several variables, with or without initial conditions. For example, here is a pair of linear, first-order equations.

S = dsolve('Df = 3*f+4*g', 'Dg = -4*f+3*g')

The computed solutions are returned in the structure S. You can determine the values of f and g by typing

f = S.f
f =
(C2*i)/exp(t*(4*i - 3)) - C1*i*exp(t*(4*i + 3))

g = S.g
g =
C1*exp(t*(4*i + 3)) + C2/exp(t*(4*i - 3))

If you prefer to recover f and g directly as well as include initial conditions, type

[f,g] = dsolve('Df=3*f+4*g, Dg =-4*f+3*g', 'f(0) = 0, g(0) = 1')

f =
i/(2*exp(t*(4*i - 3))) - (i*exp(t*(4*i + 3)))/2

g =
exp(t*(4*i + 3))/2 + 1/(2*exp(t*(4*i - 3)))

f = simplify(f)

f =
sin(4*t)*exp(3*t)

g = simplify(g)

g =
cos(4*t)*exp(3*t)

Back to Top of Page Back to Top
        Provide feedback about this page

Linear Algebra         Linear Algebra                 Integral Transforms and Z-Transforms        Integral Transforms and Z-Transforms

© 1984-2009 The MathWorks, Inc. • Terms of Use • Patents • Trademarks • Acknowledgments
已有 2 人评分经验 论坛币 热心指数 收起 理由
胖胖小龟宝 + 10 + 10 热心帮助其他会员
chenxinxiaolang + 1 谢谢

总评分: 经验 + 10  论坛币 + 10  热心指数 + 1   查看全部评分

藤椅
chenxinxiaolang 发表于 2009-12-25 23:12:30
这是四个例子吗?都是英文的看得好晕哦…… 2# firewarpk
不解释……

板凳
firewarpk 发表于 2009-12-26 10:05:58
你打开matlab,对照着例子运行一下就完全明白了

3# chenxinxiaolang

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-29 00:30