解决''在mathematica中同时存在方程

时间:2014-10-26 15:10:50

标签: wolfram-mathematica

我有alpha*xf + beta*xb = xm形式的等式,其中 xf xb xm 是来自3个单独列表的值。我想通过获取 xf xb 的连续值,同时在Mathematica中为 alpha beta 解决它们 XM ,在第一步中我解决了 i i +1 xf xb的值 xm ,接下来我解决 i +1和 i xf 的+2值, xb xm

1 个答案:

答案 0 :(得分:1)

以下是我对他要找的内容的猜测

(*Make up some example data*)
{xflist, xblist, xmlist} = RandomReal[{-3, 3}, {3, 4}];

(*Split each list into {{1,2},{2,3},{3,4}...}*)
xfl = Partition[xflist, 2, 1];
xbl = Partition[xblist, 2, 1];
xml = Partition[xmlist, 2, 1];

(*Solve two equations with two unknowns given six parameters*)
mysolve[{xf1_, xf2_}, {xb1_, xb2_}, {xm1_, xm2_}] := {alpha, beta} /. 
Solve[{alpha*xf1+beta*xb1==xm1, alpha*xf2+beta*xb2==xm2}, {alpha,beta}][[1]];

(*Use that to Solve for alpha and beta for all the sets of parameters*)
MapThread[mysolve, {xfl, xbl, xml}]