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 CenterFile Exchange에서 Numerical 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