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

2 visualizaciones (últimos 30 días)
Kyle Luttgeharm el 5 de Mzo. de 2015
Comentada: John D'Errico el 5 de Mzo. de 2015
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')
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (4)

Star Strider el 5 de Mzo. de 2015
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);
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

James Tursa el 5 de Mzo. de 2015
Editada: James Tursa el 5 de Mzo. de 2015
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
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Andrew Newell el 5 de Mzo. de 2015
Editada: Andrew Newell el 5 de Mzo. de 2015
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.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

John D'Errico el 5 de Mzo. de 2015
Editada: John D'Errico el 5 de Mzo. de 2015
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 comentariosMostrar NingunoOcultar Ninguno
Roger Stafford el 5 de Mzo. de 2015
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 el 5 de Mzo. de 2015
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.

Iniciar sesión para comentar.

### Categorías

Más información sobre Overflow and Precision Loss Detection en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by