I have functions of x, where x is the polar angle of spherical coordinates, i.e. 0 < x < Pi. Some of the functions are of even symmetry about the equator x = Pi/2 (such as Sin[x]), and other functions are of odd symmetry about x = Pi/2 (such as Sin[x]Cos[x] ) (Just Plot them to see.) Can one use Mathematica to eliminate odd functions from a sum of even and odd functions? For example, as a test, can one eliminate the odd function from the sum Sin[x] + Sin[x]Cos[x]?

  • $\begingroup$ Note, even symmetry about $x=\pi/2$ is equivalent to odd symmetry about $x=0$, so doesn't the standard $\frac{f(x)-f(-x)}{2}$ work? $\endgroup$ – rcollyer Feb 6 '13 at 5:00
  • $\begingroup$ No, I don't think that works. Sin[x] is even about Pi/2 and odd about 0, while Sin[x]*Cos[x] is odd about both Pi/2 and 0. But something along that reasoning should work. I guess this is probably not really a Mathematica problem. $\endgroup$ – Skybobcat Feb 6 '13 at 5:47
  • $\begingroup$ The trick works for symmetry about other $x$ than 0: antisymmetrize[expr_, {x_, x0_}] := (expr - (expr /. x -> 2 x0 - x))/2 $\endgroup$ – Xerxes Feb 6 '13 at 6:45
  • 1
    $\begingroup$ As a general group theory problem, this can be done by using projectors onto the irreducible representations of the symmetry group in question. It's certainly not specifically a Mathematica problem, but I remember discussing another example in this answer. $\endgroup$ – Jens Feb 6 '13 at 7:38
  • $\begingroup$ I think that if we have the general function F[x] for 0 < x < Pi, we can easily get the symmetric part of F[x] by using (F[x] + F[Pi - x])/2 , basically the idea of @rcollyer above. By symmetry here, I mean symmetry about x = Pi/2. I will check to see if the other ways above work. $\endgroup$ – Skybobcat Feb 6 '13 at 16:27
(* Check if f is odd/even around an interval of length d centered around c *)
evenQ[f_, c_: Pi/2, d_: Pi] := Integrate[Abs[f[c + x] - f[c - x]], {x, 0, d/2}] == 0
oddQ[f_, c_: Pi/2, d_: Pi]  := Integrate[Abs[f[c + x] + f[c - x]], {x, 0, d/2}] == 0

sum = Sin[x] + Sin[x] Cos[x] + Cos[x] + Exp[x]
(* Sum to list, elements to functions, remove odd ones, back to sum *)
Plus @@ DeleteCases[Map[Function[x, #] &, List @@ sum], _?(oddQ[#] &)]
% /. Function[x, f_] :> f

(* Function[x, E^x] + Function[x, Sin[x]] *)
(* E^x + Sin[x] *)

I wanted oddQ and evenQ to take a function as argument so there is some mucking about making the expression in the sum into functions.

If you want to keep only even functions (that is, not leave stuff like Exp in) use Cases[..., _?(evenQ[#]&)] instead.

If the functions are slow to integrate change to NIntegrate with some appropriate AccuracyGoal

| improve this answer | |
  • 1
    $\begingroup$ Thanks @ssch. That seems like a very nice general way to do this. I'll check it out. But for this limited case, wouldn't it be easier to just use the formula for F[x] above? $\endgroup$ – Skybobcat Feb 6 '13 at 16:37
  • $\begingroup$ @Skybobcat That would be way better indeed :) $\endgroup$ – ssch Feb 6 '13 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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