1
$\begingroup$

I am still learning how to use Mathematica more efficiently, but something that I keep bumping into is problems with it reducing formulas. Often, I'll ask it to compute a certain formula (take a derivative, Fourier transform, etc.) and the output is sometimes very messy, but could easily be reduced to something much neater.

It's usually not a big deal, because I can carry the simplification on my own, but it would still be convenient to have a systematic way of reducing everything, and not have to little tricks on a case by case basis. In some cases, I have tried, FullSimplify or TrigReduce without much success, or even using certain assumptions. For example, this should reduce

Cos[\[Theta]] ((Sqrt[-((g H)/(-1 + Sin[\[Theta]]))]Sqrt[-g H (-1 + Sin[\[Theta]])])/g - (H Sin[\[Theta]])/(-1 + Sin[\[Theta]]))

$\cos (\theta ) \left(\frac{\sqrt{-\frac{g H}{\sin (\theta )-1}} \sqrt{-g H (\sin (\theta )-1)}}{g}-\frac{H \sin (\theta )}{\sin (\theta )-1}\right)$

to this

Cos[\[Theta]] (H-(H Sin[\[Theta]])/(-1+Sin[\[Theta]]))

$\cos (\theta ) \left(H-\frac{H \sin (\theta )}{\sin (\theta )-1}\right)$

But even when doing FullSimplify on it, it just outputs the same expression. I don't have examples on top of my head, but I have been in similar situations before, where I want to reduce something, but I jut can't seem to do anything to reduce it.

Are there extra ways of forcing it into 'seeing' the possible simplifications? Or is it possible that from its perspective the expression is reduced enough? To be honest, I am not asking for a specific case of simplification, but more on the general approaches one would take to simplify/reduce an expression.

Thanks in advance.

$\endgroup$
2
  • 3
    $\begingroup$ This might require assumptions so that the sine is never unity. Refine and Simplify in tandem seem to manage it then. In[76]:= ee = Cos[\[Theta]] ((Sqrt[-((g H)/(-1 + Sin[\[Theta]]))] Sqrt[-g H (-1 + Sin[\[Theta]])])/ g - (H Sin[\[Theta]])/(-1 + Sin[\[Theta]])); Simplify[Refine[ee, Assumptions -> {g > 0, H > 0, 0 < \[Theta] < Pi/2}], Assumptions -> {g > 0, H > 0, 0 < \[Theta] < Pi/2}] Out[77]= (H Cos[\[Theta]])/(1 - Sin[\[Theta]]) $\endgroup$ Commented Jan 17, 2021 at 15:55
  • 1
    $\begingroup$ I share your dismay. Yes there is Assumptions but there is also TransformationFunctions. However, in some cases, Simplify is really stubborn, so you will need to apply a rule directly with ReplaceAll. See also MultiplySides and the like. $\endgroup$ Commented Jan 17, 2021 at 23:47

2 Answers 2

3
$\begingroup$

Try this:

expr = Cos[\[Theta]] ((Sqrt[-((g H)/(-1 + 
             Sin[\[Theta]]))] Sqrt[-g H (-1 + Sin[\[Theta]])])/
     g - (H Sin[\[Theta]])/(-1 + Sin[\[Theta]]));

Simplify[expr /. Sqrt[a_]*Sqrt[b_] :> Sqrt[a*b], {g > 0, H > 0}]

(* (H Cos[\[Theta]])/(1 - Sin[\[Theta]])   *)  

Have fun!

$\endgroup$
5
$\begingroup$
$Version

(* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *)

Clear["Global`*"]

expr1 = Cos[θ] ((Sqrt[-((g H)/(-1 + Sin[θ]))] Sqrt[-g H (-1 + 
            Sin[θ])])/g - (H Sin[θ])/(-1 + Sin[θ]));

expr2 = Cos[θ] (H - (H Sin[θ])/(-1 + Sin[θ]));

The two expressions are not generally equal. To find instances where they are not equal,

FindInstance[expr1 != expr2, {g, H, θ}, 3]

(* {{g -> 619/10 + (141 I)/10, 
  H -> -(391/10) + (26 I)/5, θ -> 
   71/5 - (627 I)/10}, {g -> -49 + (31 I)/2, 
  H -> -(65/2) + (471 I)/10, θ -> 232/5 + (89 I)/2}, {g -> 
   31/10 - 26 I, H -> 35 + (46 I)/5, θ -> 326/5 - (7 I)/2}} *)

Mathematica assumes that all variables can be complex. However, if you restrict the variables to being real,

Assuming[Element[{g, H, θ}, Reals], expr1 == expr2 // Simplify]

(* True *)

Consequently,

Assuming[Element[{g, H, θ}, Reals], expr1 // Simplify]

(* (H Cos[θ])/(1 - Sin[θ]) *)
$\endgroup$

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.