I am trying to write a program in Mathematica that will perform basic uncertainty analysis for me and "show the work," so to speak. One of the pieces of this program will involve taking in an expression and list of variables, say,
myexpr = w == 2 y Cos[x] + z^2
myvaris = {x, y, z, w}
and solving the expressions for the first variable in the list, e.g.
Solve[myexpr, myvaris[[1]]]
which outputs
{{x -> ConditionalExpression[-ArcCos[(w - z^2)/(2*y)] + 2*Pi*C[1],
Element[C[1], Integers]]},
{x -> ConditionalExpression[ArcCos[(w - z^2)/(2*y)] + 2*Pi*C[1],
Element[C[1], Integers]]}}
which is all good and correct. But what I would like to obtain is just something like
{x -> ArcCos[(w - z^2)/(2*y)]}
without all the conditional expression business, because its presence wrecks the form of the output I'd like. In particular, what I want in the end is something I can pass to TeXForm
which will go into a StringForm
to output a chunk of LaTeX. Is it possible to construct something like this (and if so how), or am I asking a question which cannot be solved in pure generality?
To be clear, I'm not asking how to eliminate the particular occurrences of ConditionalExpression
in the output above, but to eliminate all instances of such a ConditionalExpression
and arbitrary constants in general, without having to manipulate by hand any intermediate results. I'm not really concerned with the output being reliably correct or complete in the end; I just want the expression that a naive high school algebra student would write down.
Normal
. $\endgroup$Normal
is the recommended way. $\endgroup$