Is it possible to solve a pair of two equations for four unknowns

2 ビュー (過去 30 日間)
Kyle Luttgeharm
Kyle Luttgeharm 2015 年 3 月 5 日
コメント済み: John D'Errico 2015 年 3 月 5 日
I have a paired set of equations that has four unknowns and was wondering if it is possible using matlab to solve for the four unknowns. My equations are where I need to know what values of A, B, x, and y make both equations true.
'A*(12.12)^x + B*(2.35)^y = 6.20'
'A*(8.55)^x + B*(6.44)^y = 34.52')

回答 (4 件)

Star Strider
Star Strider 2015 年 3 月 5 日
If you have the Optimization Toolbox (so you can use the fsolve function), you can get a set of parameters that will satisfy your equations. They will not be unique.
% A = b(1), B = b(2), x = b(3), y = b(4)
f = @(b) [b(1)*(12.12)^b(3) + b(2)*(2.35)^b(4) - 6.20; b(1)*(8.55)^b(3) + b(2)*(6.44)^b(4) - 34.52];
B0 = ones(4,1);
B = fsolve(f, B0);

James Tursa
James Tursa 2015 年 3 月 5 日
編集済み: James Tursa 2015 年 3 月 5 日
A brute force method to get a single solution:
% Equations (pick x and y both not 0 and not too big)
disp('Numbers')
x = randn % pick
y = randn % pick
C = [12.12^x 2.35^y;8.55^x 6.44^y];
D = C\[6.20;34.52];
A = D(1)
B = D(2)
disp('Check')
[A*12.12^x + B*2.35^y, 6.20]
[A* 8.55^x + B*6.44^y,34.52]
disp('Difference')
A*12.12^x + B*2.35^y - 6.20
A* 8.55^x + B*6.44^y -34.52
Answer is not unique.

Andrew Newell
Andrew Newell 2015 年 3 月 5 日
編集済み: Andrew Newell 2015 年 3 月 5 日
Since the answer is not unique, just pick x=y=1 and solve the linear equation to get A and B:
[12.12 2.35; 8.55 6.44]\[6.20; 34.52]
ans =
-0.7107
6.3038
You can choose just about any values for x and y and get a valid answer using the same method. See mldivide for why the backslash does the job for you.

John D'Errico
John D'Errico 2015 年 3 月 5 日
編集済み: John D'Errico 2015 年 3 月 5 日
There are infinitely many solutions to this problem, a 2-dimensional locus of points embedded in the 4 parameter space defined by (A,B,x,y).
syms A B x y
E1 = A*(12.12)^x + B*(2.35)^y == 6.20;
E2 = A*(8.55)^x + B*(6.44)^y == 34.52;
sol = solve(E1,E2,{A,B});
sol.A
ans =
(863*(47/20)^y - 155*(161/25)^y)/(25*((47/20)^y*(171/20)^x - (161/25)^y*(303/25)^x))
sol.B
ans =
(155*(171/20)^x - 863*(303/25)^x)/(25*((47/20)^y*(171/20)^x - (161/25)^y*(303/25)^x))
Here I've solved for A and B, given general values for x and y.
  2 件のコメント
Roger Stafford
Roger Stafford 2015 年 3 月 5 日
For every pair of coordinates, x and y, there will be a unique solution for A and B except along a certain line through the origin. For all x/y pairs along this line there will be no solutions for A and B except at a certain point where there will be infinitely many A, B solutions.
John D'Errico
John D'Errico 2015 年 3 月 5 日
As Roger points out, if we can find a value of K such that
K*2.35^y == 6.44^y
AND
K*12.12^x == 8.55^x
then we will find infinitely many solutions. Taking logs...
log(K) + y*log(2.35) == y*log(6.44)
log(K) + x*log(12.12) == x*log(8.55)
So
log(K) = y*(log(6.44) - log(2.35))
log(K) = x*(log(8.55) - log(12.12))
So the line that Roger has indicated is
y = x * (log(8.55) - log(12.12))/(log(6.44) - log(2.35))
Along that line, the linear system for A and B is singular.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by