# How to simplify an expression in Mathematica

1. Oct 16, 2004

### niko2000

Hi,
I have got this expression from Mathematica:
Sqrt[a^2*(Cosh(x))^2*(Sin(y))^2]
I have tried to simplify this expression with Simplify[], but it returns the same result.
I have tried to solve some other expressions and it returned some strange forms.
For example:
I have tried to solve some equation on paper and I've got this:
a*Sqrt[(Cos(x))^2+(Sinh(y))^2]
Then I have tried to solve the same equation with Mathematica and it has returned some long expression containing combinations of double angles.
Does anyone know what to do to get the simplest expression?
Anyway I don't know why Mathematica couldn't simplify an expression as simple as a*Sqrt[(Cos(x))^2+(Sinh(y))^2]

2. Oct 17, 2004

### graphic7

Have you tried FullSimplify?

If you read the documentation, you'll see FullSimplify does quite a bit more. It has more aggressive factoring, rationalizing, and other techniques that Simplify does not.

3. Oct 18, 2004

### niko2000

On Sqrt[a^2*(Cosh(x))^2*(Sin(y))^2] FullSimplify doesn't work. It returns the same expression.

4. Oct 18, 2004

### graphic7

Nothing's perfect.

5. Oct 19, 2004

### manesh

I also found that Mathematica Simplify command doesnt work as we expect.
Your expression looks already simplified...one can make different simplifications according to the expression we want to reach, mathematica also gives one possibility.If your expression contains only terms, which doesn't contain any Sin or Cos or some other functions, Mathematica is okay....Mathematica 5.0 has more advanced features..have a look at it..

6. Oct 19, 2004

### graphic7

That's why I always try FullSimplify.

If you read the release notes, you'll see that 99% of the modifications from 4.0 to 5.0 deal with performance enhancements (specifically linear algebra functions). I've been unable to find any enhancements to FullSimplify and Simplify other than performance.

7. Oct 21, 2004

### manesh

exactly u r right..

8. Oct 23, 2004

### flexten

Remember:

$$\sqrt {a^2 } \ne a$$

And it won't do this invalid operation.

Best

9. Oct 27, 2004

### niko2000

What is true if that's not true?

10. Oct 27, 2004

### plover

$$\sqrt {a^2 } = \pm a$$​
If you want to ignore the negative root you have to explicitly indicate this.
Simplify[Sqrt[a^2]] just yields √a2
but
Simplify[Sqrt[a^2], a>=0] simplifies to a
Why are you expecting
a*Sqrt[(Cos[x])^2 + (Sinh[y])^2]
to simplify?

Just to make sure the obvious is covered: you have noticed that Sinh is shown rather than Sin? And also that Cos is applied to x while Sinh is applied to y?

Have you checked out the hints in the online documentation on getting Simplify to do what you want? Have you looked at related functions like TrigExpand and ExpToTrig?

11. Oct 28, 2004

### niko2000

a*Sqrt[(Cos[x])^2+(Sinh[y])^2] is what i've got on paper and that is not related to the first problem.
The first problem was that mathematica couldn't simplify this:
Sqrt[a^2*(Cosh(x))^2*(Sin(y))^2]

12. Oct 28, 2004

### graphic7

I was under the impression that FullSimplify calls TrigExpand and ExpToTrig for a maximum simplification effect.

13. Oct 28, 2004

### plover

I'm no expert, I was just offering suggestions of things to look at. However, when used on the expression:
a*Sqrt[(Cos[x])^2 + (Sinh[y])^2]
both Simplify[] and FullSimplify[] alone do nothing, while Simplify[TrigToExp[]], ExpToTrig[Simplify[TrigToExp[]]], and FullSimplify[TrigToExp[]] all produce different answers (though the last two are similar). I'm using version 4.1.

14. Oct 28, 2004

### plover

Yes, I understand this. But you also said:
It seems you think this expression should simplify, and that the reason it should simplify is obvious. Since I don't see any good way to simplify this and neither does Mathematica, I'm wondering why you think it simplifies, and what you would simplify it to.

At the moment, I see two possibilities, either a) your expectation is incorrect, or b) I am not understanding your expectation.
Again, I'm not sure why you think this should simplify. What form did you want it to be in? There are many functions for transforming expressions in Mathematica other thanSimplify[].

15. Oct 28, 2004

### niko2000

We were calculating Lame's coeficients for some coordinate system.
We had these data:
x=a*Cosh*Sin[P]*Cos[F]
y=a*Cosh*Sin[P]*Sin[F]
z=a*Sinh*Cos[P]

The first coeficient (let's call it f1):
f1=Sqrt[(dx/dB)^2+(dy/dB)^2+(dz/dB)^2]
The second:
f2=Sqrt[(dx/dP)^2+(dy/dP)^2+(dz/dP)^2]
The third:
Sqrt[(dx/dF)^2+(dy/dF)^2+(dz/dF)^2]

After our calculations we've got this:
f1=f2=a*Sqrt[Cos[P]^2+sinh^2]
f2=a*Cosh*Sin[P]

When I tried to get these results with Mathematica I have got much more complex results.
Instead of giving the results in the same form it gave for f1 and f2 some combination of double angles and f3 Sqrt[a^2*(Cosh(x))^2*(Sin(y))^2]

16. Oct 28, 2004

### plover

For f3 you need to give assumptions in order to simplify. Do you have constraints for the values of a, B, and P?

The most obvious assumption to provide is that a, B, and P are real numbers.
Simplify[f3, Element[{a,B,P},Reals]]
yields
Abs[a] Abs[Sin[P]] Cosh
This seems reasonable.

If you can also say that a>=0 and 0<=P<=Pi then you can simplify to the form you gave:
Simplify[f3, Element[{a,B,P},Reals] && (a>=0) && (0<=P<=Pi)]
yields
a Sin[P] Cosh

Unfortunately, I can't see any easy way to get Mathematica to simplify to the form you give for f1 and f2 rather than the double angle form. I'm not enough of an expert to be sure that none actually exists though. But, this may just be one of those things for which the human brain is still the best tool.