I was trying to use Mathematica for some simple algebra deduction, but it didnt work. code:
TrueQ@(Sqrt[(e0 u0)/(e1 u1)] == Sqrt[e0 u0]/Sqrt[e1 u1])
Any ideas how to make Mathematica know these equations are the same?
You need to assume e1,u1
are positive
Assuming[e1 > 0 && u1 > 0, Simplify[Sqrt[(e0 u0)/(e1 u1)] - Sqrt[e0 u0]/Sqrt[e1 u1]]]
Let look and see why. Consider the simple example
Clear[x]
expr = Sqrt[1/x] - 1/Sqrt[x];
Simplify[expr]
If x
is negative, then Sqrt[1/x]
is Sqrt[-1/Abs[x]]
which is I*Sqrt[1/Abs[x]]
which is not the same as 1/Sqrt[x]
. But if x>0
then Sqrt[1/x]=1/Sqrt[x]
Assuming[x > 0, Simplify[expr]]
(* 0 *)
And that is what happened in your expression.
False
$\endgroup$
TrueQ
is really meant for structural sameness. Not Math-wise sameness. i.e. when both sides are exactly the same structurally. Any way, I normally just use Simplify when Assuming.
$\endgroup$
TrueQ[Exp[I x] == Cos[x] + I*Sin[x]]
gives False
but Simplify[Exp[I x] == Cos[x] + I*Sin[x]]
gives True
$\endgroup$
TrueQ
is not usually used this way. Suppose you have a condition (e.g.,A == B
as in your case). There are three possibilities: it computes toTrue
, it computes toFalse
, and its value cannot be computed. The functionIf[]
for instance does different things in each case.TrueQ
is used to force the last case to beFalse
. It is used for programming and not for mathematics. If you have a procedure that should not be executed unless it is known that the condition is true, thenTrueQ
is convenient to combine theFalse
and the undecided cases together. $\endgroup$