View Full Version : How to simplify an expression in Mathematica
niko2000
Oct16-04, 06:06 AM
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]
graphic7
Oct17-04, 01:04 PM
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.
niko2000
Oct18-04, 04:02 AM
On Sqrt[a^2*(Cosh(x))^2*(Sin(y))^2] FullSimplify doesn't work. It returns the same expression.
graphic7
Oct18-04, 07:22 AM
Nothing's perfect. :smile:
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..
graphic7
Oct19-04, 06:03 PM
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..
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.
flexten
Oct23-04, 02:12 AM
Remember:
\[
\sqrt {a^2 } \ne a
\]
And it won't do this invalid operation.
Best
niko2000
Oct27-04, 06:53 AM
What is true if that's not true?
\[
\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?
niko2000
Oct28-04, 08:38 AM
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]
graphic7
Oct28-04, 09:15 AM
\[
\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?
I was under the impression that FullSimplify calls TrigExpand and ExpToTrig for a maximum simplification effect.
I was under the impression that FullSimplify calls TrigExpand and ExpToTrig for a maximum simplification effect.
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.
a*Sqrt[(Cos[x])^2+(Sinh[y])^2] is what i've got on paper and that is not related to the first problem.
Yes, I understand this. But you also said:
Anyway I don't know why Mathematica couldn't simplify an expression as simple as a*Sqrt[(Cos(x))^2+(Sinh(y))^2]
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.
The first problem was that mathematica couldn't simplify this:
Sqrt[a^2*(Cosh(x))^2*(Sin(y))^2]
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[].
niko2000
Oct28-04, 05:05 PM
We were calculating Lame's coeficients for some coordinate system.
We had these data:
x=a*Cosh[B]*Sin[P]*Cos[F]
y=a*Cosh[B]*Sin[P]*Sin[F]
z=a*Sinh[B]*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[B]^2]
f2=a*Cosh[B]*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]
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[B]
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[B]
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.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.