# Solving a system of two equations

I have a system of two equations with the variables T and X that I tried to solve:

Solve[{-(8.314)*T*Log[X] == 8.3*(1400 - T), -(8.314)*T*Log[1 - X] == 8.3*(1200 - T)}, {T, X}]


but I get the error

Solve::svars: Equations may not give solutions for all "solve" variables.

I'm not sure what I'm doing wrong or what else I should do instead.

• Do you really have two different constants, 8.3 and 8.314 or are they supposed to be the same? – JEP Jan 15 '15 at 23:35

I'm not sure if this is solvable. However, there appears to be one and only one solution (assuming you want real values for X and T), available by the following kludgy means:

First, solve the individual equations for T:

s1 = Solve[-(8.314)*T*Log[X] == 8.3*(1400 - T), T]
s2 = Solve[-(8.314)*T*Log[1 - X] == 8.3*(1200 - T), T]


giving

{{T -> 11620./(8.3 - 8.314 Log[X])}}
{{T -> 9960./(8.3 - 8.314 Log[1. - 1. X])}}


Solve[s1[[1, 1, 2]] == s2[[1, 1, 2]], X]


giving a numerical method warning and the answer,

{{X -> 0.434986}}


from which T can be obtained:

s1[[1, 1, 2]] /. X -> 0.4349859661954613
s2[[1, 1, 2]] /. X -> 0.4349859661954613


giving

763.423
763.423


Plotting the regions where the equations hold true in the $(X,T)$ plane suggests that this is the only solution. The red curve is the support of the first equations's validity, and the blue curve is the support of the second equation's validity:

ImageAdd @@ (ColorConvert[
ComplexPlotR2[
CCompileR2[10 #], {-2 + 10^-6 RandomReal[], 3,
0.005}, {-0 + 10^-6 RandomReal[], 6000, 10}], "RGB"] & /@ {1/
Abs[-8.3 (1400 - y) - 8.314 y Log[x]]^(1/2), -1/
Abs[-8.3 (1200 - y) - 8.314 y Log[1 - x]]^(1/2)})


producing the following colorful image:

where the following helper functions have been defined:

hue = Compile[{{z, _Complex}}, {(1.0 Arg[-z] + \[Pi])/(2 \[Pi]),
Exp[1 - Max[Abs[z], 1]], Min[Abs[z], 1]},
CompilationTarget -> "C", RuntimeAttributes -> {Listable}];
ComplexPlotR2[f_, {x0_, x1_, \[Delta]x_}, {y0_, y1_, \[Delta]y_}] :=
Image[hue[
f[#[[All, All, 1]], #[[All, All, 2]]] &@
Outer[List, Range[x0, x1, \[Delta]x],
Range[y0, y1, \[Delta]y]]]\[Transpose], ColorSpace -> Hue,
Magnification -> 1];
CCompileR2[expr_] :=
Compile[{{x, _Real}, {y, _Real}}, Evaluate[expr],
CompilationTarget -> "C", RuntimeAttributes -> {Listable}];


There appears to only one intersection, which as mentioned before is at X -> 0.434986, T -> 763.423.

In[1]:= (* YOU NEED TO ADD THE Reals OPTION TO SPECIFY THE DOMAIN *)

In[2]:= Solve[{-(8.314)*T*Log[X] == 8.3*(1400 - T), -(8.314)*T*Log[1 - X] == 8.3*(1200 - T)}, {T, X}, Reals]

During evaluation of In[19]:= Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.

Out[2]= {{T -> 763.423, X -> 0.434986}}

In[3]:= (* THE ABOVE IS EQUIVALENT TO CONVERTING ALL FLOATING-POINT NUMBERS TO RATIONAL NUMBERS AND USING NSolve AS FOLLOWS: *)

In[4]:= R1 = Rationalize[8.314]; R2 = Rationalize[8.3]; NSolve[{-(R1)*T*Log[X] == R2*(1400 - T), -(R1)*T*Log[1 - X] == R2*(1200 - T)}, {T, X}, Reals]

Out[4]= {{T -> 763.423, X -> 0.434986}}


This is not exactly the answer, maybe someone can improve it.....the output has imaginary components. Minor modifications to the input eqns.

FindRoot[{T*Log[X] - (8.3*T)/8.314 == (-(8.3/8.314))*1400,
T*Log[1 - X]*(-((8.3*T)/8.314)) == (-8.3/8.314)*1200}, {{T,
500}, {X, 450}}]


OUTPUT: {T -> 231.958 + 105.976 I, X -> -0.0120535 + 0.0141176 I}