关于solve解方程的问题
使用solve解两个方程,为何第一个方程就能得到正确的解,而第二个方程就得了一个奇怪的解呢?后来用fortran解得第二个方程的解为13.5847,符合正常结果。是不是matlab出问题了?过程如下:
>> solve(exp(14.717-1886.79/(x+273.16))-1022.246591*x-3424.252273)
ans = -.9992732762476688948977989063277
这个结果是正确的;
>> solve(exp(38.98-8533.8/(x+273.16))-490.5*x-3424.252273)
ans = 173045333758471.02892809561791336
这个结果就完全不对劲了....正确的解应该是13.5847左右啊....
各位高手给帮忙看看吧(我都要被折腾疯了),感激不尽啊 第二个方程的解:x = -4.05900180421605
回复:(atos)关于solve解方程的问题
fzero('exp(38.98-8533.8/(x+273.16))-490.5*x-3424.252273',13) 问题重点不在上述两位所解答之处,而是用solve求解,只能找到一个根。function SolveP
clc
syms x
A1=solve('exp(14.717-1886.79/(x+273.16))-1022.246591*x-3424.252273','x')
f1=inline('exp(14.717-1886.79./(x1+273.16))-1022.246591*x1-3424.252273','x1');
A2=solve('exp(38.98-8533.8/(x+273.16))-490.5*x-3424.252273','x')
A22=subs('exp(38.98-8533.8/(x+273.16))-490.5*x-3424.252273',x,-4.05900180421605)
ezplot('exp(38.98-8533.8/(x+273.16))-490.5*x-3424.252273',)
f2=inline('exp(38.98-8533.8./(x2+273.16))-490.5*x2-3424.252273','x2')
x11=fsolve(f1,5)
x12=fsolve(f2,17304533375847)
x13=fsolve(f2,-10)
=================================================
A1 =
-.99927327624766913280894926374491
A2 =
173045333758471.02892812172842794
A22 =
-9.0949e-013
f2 =
Inline function:
f2(x2) = exp(38.98-8533.8./(x2+273.16))-490.5*x2-3424.252273
Optimization terminated: first-order optimality is less than options.TolFun.
x11 =
-0.9993
Optimizer appears to be converging to a point which is not a root.
Norm of relative change in X is less than max(options.TolX^2,eps) but
sum-of-squares of function values is greater than or equal to sqrt(options.TolFun)
Try again with a new starting guess.
x12 =
1.7305e+013
Optimization terminated: first-order optimality is less than options.TolFun.
x13 =
-4.0590
程序明显可以看出在之间同样存在一个根,因此不能说solve算错了,只能说没算全,至于为什么没算全,暂时没找到原因。而且从最后一个语句所得结果可以看出,fsolve在此处同样能得到这个结果。
附件图中可以看出问题是出自maple的计算引擎,在maple中不加任何干预得到的是同样 的结果。而更有意思的是,用maple中的浮点方式求解方程命令fsolve得到的是-4.0590
页:
[1]