Symbolic substitution to eliminate variables without solving for the explicit expressions

10 views (last 30 days)
Hi all,
I am trying to simplify a set of expressions (all equal to zero) by eliminating certain variables and not others. This can be explained by example with two different cases. For reference, the variables come from thermodynamic and mass balance conditions where the set of variables are [CO2g,C,SiC] and [CO2g,SiC,SiO2],respectively. (Additionally variables are all constant parameters that will be known later at run time). Essentially I only need to isolate and expression in terms of only first variable 'CO2g' and the others which will be known, because then I can generate a matlab function and setting the extra parameters at runtime and solve for the zeros in terms of 'CO2g', since they will be absent of 'SiC' and 'SiO2'.
The first set of expressions are:
Alleq1= [Ct - CO2g - C - SiC - (Keq2*Vpore*((CO2g*R*T)/Vpore)^(1/2))/(R*T)
Ot - 2*CO2g - (Keq1*Vpore*((CO2g*R*T)/Vpore)^(1/2))/(R*T) - (Keq2*Vpore*((CO2g*R*T)/Vpore)^(1/2))/(R*T)
Sit - SiC - (Keq1*Vpore*((CO2g*R*T)/Vpore)^(1/2))/(R*T) ]
and can be solved explicitly by using the solve(Alleq1,'CO2g','C','SiC') ans =
C: [1x1 sym]
CO2g: [1x1 sym]
SiC: [1x1 sym]
This is a special case because the CO2g^(1/2) is quadratic and therefore can be solved explicitly. However a more complicated example is below.
The second set of expressions are:
Alleq2 = [Ct - CO2g - SiC - (Keq2*Vpore*((CO2g*R*T)/Vpore)^(3/4))/(R*T)
Ot - 2*CO2g - 2*SiO2 - (Keq1*Vpore)/(R*T*((CO2g*R*T)/Vpore)^(1/4)) - (Keq2*Vpore*((CO2g*R*T)/Vpore)^(3/4))/(R*T)
Sit - SiO2 - SiC - (Keq1*Vpore)/(R*T*((CO2g*R*T)/Vpore)^(1/4))]
This can not be solved [CO2g,SiC,SiO2] like the previous method because the order of the expressions in terms of CO2g can not be solved explicitly. However, knowing an adequate sequence of substitutions will isolate an expression in terms of only 'CO2g', but this requires manual inspection (attempts at figuring out the logic of the substitutions for an arbitrary 'even more difficult system' has not proved fruitful). The results of the substitutions show the isolation of 'CO2g' from 'SiC' and 'SiO2', which should always be possible.
solve(Alleq2(1),'SiC') subs(Alleq2(3),'SiC',ans) solve(ans,'SiO2') subs(Alleq2(2),'SiO2',ans)=
2*Ct - 4*CO2g + Ot - 2*Sit + (Keq1*Vpore)/(R*T*((CO2g*R*T)/Vpore)^(1/4)) - (3*Keq2*Vpore*((CO2g*R*T)/Vpore)^(3/4))/(R*T)
From this example, it can be seen why it can not be solved explicitly, but can be solved for the zeros numerically at a later point, the result of which can be substituted into the original expressions, making them linear and easily solvable.
I would appreciate any help on this problem of isolating expression in only certain variables and restricting others when given an arbitrary set of expressions (that is known to be solvable).

Accepted Answer

Stefan Wehmeier
Stefan Wehmeier on 11 Aug 2011
The second system, too, can be solved. You will have to work on the MuPAD Notebook level or use feval(symengine, ...) though because you need the RootOf data structure.
In the MuPAD Notebook, the answer is
solve(Alleq2, [CO2g,SiO2,SiC], IgnoreSpecialCases, VectorFormat)
and, correspondingly, using the symengine it is
feval(symengine, 'solve', Alleq2, ' [CO2g,SiO2,SiC], IgnoreSpecialCases, VectorFormat')
You will (of course) have to substitute all of your free parameters by values before vpa can work.
  1 Comment
Christopher Creutzig
Christopher Creutzig on 12 Aug 2011
Instead of plugging in values and calling vpa, you could also interpret the output of these commands as a system of four polynomial equations in four unknowns, one of which is newly introduced.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!