3
$\begingroup$

Here is a set of simple equations

W = 1/2 n^2 (x^2 + y^2) + 1/(2 r1) (1 + A/(2 r1^2) (1 - (3 z^2)/r1^2)) + 
1/(2 r2) (1 + A/(2 r2^2) (1 - (3 z^2)/r2^2));
n = Sqrt[1 + 3 A];
r1 = Sqrt[(x + m)^2 + y^2 + z^2];
r2 = Sqrt[(x - 1 + m)^2 + y^2 + z^2];
m = 1/2;
Wz = D[W, z] /. {x -> 0, y -> 0};

Now I want to print the simplified expression Wz and its numeratorfz.

Print["Wz = ", Simplify[Wz]]
Print["fz = ", Simplify[Numerator[Wz]]]

However Mathematica prints the same output in both cases! Why? Is this a bug?

I am using v9.0 in Windows XP 32.

Many thanks in advance!

$\endgroup$

1 Answer 1

3
$\begingroup$

You need to Simplify before taking the numerator,

Print["Wz = ", Simplify[Wz]]
Print["fz = ", Numerator[Simplify@Wz]]

enter image description here

The reason is that only the simplified form of Wz is a single fraction, before simplifying you have this,

Wz

and so asking for the numerator of this is the same as this simpler example

Numerator[a/b + c/b^2]
Numerator@Simplify[a/b + c/b^2]
(* a/b + c/b^2 *)
(* a b + c *)
$\endgroup$
1
  • $\begingroup$ I should have thought of it... Anyway, many thanks! $\endgroup$
    – Vaggelis_Z
    Commented Feb 16, 2016 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.