6
$\begingroup$

I'm trying to simplify an expression, and my guess would be like this:

FullSimplify[Sqrt[1 - Cos[θ]^2/sign[r Cos[ϕ] Sin[θ]]^2], sign[_]^2 == 1]

Apparently, as I get unchanged expression back, FullSimplify doesn't understand what I mean. (sign is deliberately not a system Sign function here).

I do realize that I could simply switch to a replacement like expr /. sign[_]^2 -> 1, but I suppose in general simplification with a pattern could be more useful. E.g. when sign[...]^n would have n==4 or whatever. Also in this case the rule I mentioned wouldn't work, since it should instead be sign[_]^-2 -> 1 here.

So my question is: how do I use patterns in assumptions of Simplify family of functions?

$\endgroup$

2 Answers 2

11
$\begingroup$

How about this?

Power[sign[x_], n_?EvenQ] ^= 1;
FullSimplify[Sqrt[1 - Cos[θ]^2/sign[r Cos[ϕ] Sin[θ]]^2]]
$\endgroup$
6
$\begingroup$

A combination of TranformationFunctions and UpSetDelayed (for the pattern matching) is useful here.

t[sign[x_]] ^:= 1

FullSimplify[Sqrt[1 - Cos[θ]^2/sign[r Cos[ϕ] Sin[θ]]^2], 
 TransformationFunctions :> {Automatic, t}]   
(* Sqrt[Sin[θ]^2] *)
$\endgroup$
1
  • 1
    $\begingroup$ Not exactly. You are assuming that sign[x_] is always 1, but we need only even exponents, so a slight correction is needed t[Power[sign[x_], n_?EvenQ]] := 1 $\endgroup$
    – Stitch
    Commented Nov 18, 2016 at 22:41

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.