Register to reply 
Simplify in Mathematica 
Share this thread: 
#1
Feb1713, 07:35 AM

Emeritus
Sci Advisor
PF Gold
P: 9,403

Why do I keep getting output that looks like this when I use Mathematica?
$$\frac{2 b k a+b v (2 a+b v+b v \cos (t)) \sin ^2\left(\frac{t}{2}\right)}{(a+b v)^2 \sqrt{\left(\frac{1}{\sqrt{4 a^2 k^2 \sin ^4\left(\frac{t}{2}\right)+d^2 (a+b v)^2 \sin ^2(t)}}\right)^* \sqrt{4 a^2 k^2 \sin ^4\left(\frac{t}{2}\right)+d^2 (a+b v)^2 \sin ^2(t)}} \sqrt{4 a^2 k^2 \sin ^4\left(\frac{t}{2}\right)+d^2 (a+b v)^2 \sin ^2(t)}}$$ This is the output of a "Simplify" with the options



#2
Feb1713, 01:13 PM

P: 1,037

No assumptions about domain and this is the result
In[1]:= Simplify[(2b k Abs[a+b v](2a+b v+b v Cos[t]) Sin[t/2]^2)/((a+b v)^2) Sqrt[(1/Sqrt[4a^2k^2 Sin[t/2]^4+d^2(a+b v)^2 Sin[t]^2])^2 Sqrt[4a^2k^2 Sin[t/2]^4+d^2(a+b v)^2 Sin[t]^2] Sqrt[4a^2k^2 Sin[t/2]^4+d^2(a+b v)^2 Sin[t]^2]]] Out[1]= (2*b*k*Abs[a + b*v]*(2*a + b*v + b*v*Cos[t])*Sin[t/2]^2)/(a + b*v)^2 So either I'm making a mistake when I have to type all your stuff back in just to give it to Mathematica or you have a problem in your desktop publishing, like that superscript "*" I see and I guessed that was supposed to be "2", or maybe there is a version difference. What is your actual raw code without any desktop publishing? 


#3
Feb1713, 03:46 PM

Emeritus
Sci Advisor
PF Gold
P: 9,403

I should have included the full code in my post. Sorry about that. You can see it below. I should perhaps also mention that this is my first attempt to use Mathematica to do anything at all really. So it's possible that I'm doing many things wrong. I've been doing this on someone else's copy of Mathematica 7. I don't have access to the latest version at the moment.
The * superscript comes out as ^\[Conjugate] when I do a "copy as plain text".



#4
Feb1713, 09:39 PM

P: 1,037

Simplify in Mathematica
The first thing I would look at is
Norm[p] because it appears that so much of your code depends on that. Is Norm[p] supposed to be something that you are not seeing in your notebook? 


#5
Feb1713, 10:09 PM

Emeritus
Sci Advisor
PF Gold
P: 9,403

p is the 3×1 matrix
$$\begin{pmatrix} \frac{2 a v \sin ^2\left(\frac{t}{2}\right)}{a+b v} \\ \frac{d v \sin (t)}{k} \\ 0 \end{pmatrix}$$ and Norm[p] is the norm of p, i.e. ##\p\=\sqrt{(p_1)^2+(p_2)^2+(p_3)^2}##. If I just evaluate Norm[p], I get $$\sqrt{\frac{4 a v \sin ^2\left(\frac{t}{2}\right) (a v)^* \sin ^2\left(\frac{t^*}{2}\right)}{(a+b v) (a+b v)^*}+\frac{d v \sin (t) (d v \sin (t))^*}{k k^*}}$$ If I evaluate Simplify[Norm[p],{a,b,d,v,t}\[Element]Reals && k>0], I get $$\frac{v \sqrt{4 a^2 k^2 \sin ^4\left(\frac{t}{2}\right)+d^2 \sin ^2(t) (a+b v)^2}}{k a+b v}$$ So I would say that "Simplify" is doing OK so far. 


#6
Feb1813, 12:01 AM

P: 1,037

I'm not finding an explanation.
Perhaps someone else can spot something. Something that might relate, many programming languages make a big distinction between row vectors and column vectors. Mathematica doesn't, a vector will be interpreted as row or column as needed. This means you don't need to go to the trouble to try to construct column vectors. In fact in some old versions of Mathematica adding an extra layer of {} to try to force elements to be in a column could cause problems, but they may have found and fixed those by now. I do see that you have column vectors with the extra layer of {} at places in your code. Hopefully someone else can spot something that I just seem to be blind to at the moment. If you could show specific examples of where the calculations seem to be incorrect that might help someone, something more specific than "But something is already wrong with R1p." 


#7
Feb1813, 12:14 AM

Emeritus
Sci Advisor
PF Gold
P: 9,403

That's OK. Thanks for trying. I did say what the problem with R1p is. The first component is of the form
$$\frac{a+bvX}{(a+bv)^2 Y}.$$ Since all the variables are real, this can be simplified to $$\frac{X}{a+bvY},$$ but Mathematica doesn't do that, even when I explicitly tell it that all variables are real by changing the definition to
Edit 2: I think the problem with the example in the OP is that Mathematica is concerned that the things under the square roots are zero or negative. 


#8
Feb1913, 09:40 AM

Emeritus
Sci Advisor
PF Gold
P: 9,403

I could still use some help from someone who understands the Simplify feature better than I do. One of the expressions that show up in the calculation can also be generated by the following code.
$$\frac{d v \sin(t) (a+b v)}{v \sqrt{4 a^2 k^2 \sin \left(\frac{t}{2}\right) +d^2 \sin(t) (a+b v)^2} \sqrt{\sqrt{4 a^2 k^2 \sin^4\left(\frac{t}{2}\right) +d^2 \sin^4(t) (a+b v)^2} \left(\frac{1}{\sqrt{4 a^2 k^2 \sin^4\left(\frac{t}{2}\right) +d^2 (a+b v)^2 \sin ^2(t)}}\right)^*}}$$ The following Simplify does absolutely nothing.
Here's a simpler thing that Mathematica fails to simplify.



#9
Feb1913, 03:59 PM

Mentor
P: 17,307

Try using FullSimplify instead of Simplify.
FullSimplify[v^2/Abs[v], v \[Element] Reals && v != 0] gives Abs[v] FullSimplify is a lot slower than Simplify (even when it achieves the same end result) because it uses a lot more transformation rules. 


#10
Feb1913, 07:11 PM

Emeritus
Sci Advisor
PF Gold
P: 9,403

To produce the LaTeX you see, I ran the code from the code box and then did a copy as LaTeX. My latest version of the code (I did everything over from scratch) doesn't produce an output with "dv" in the numerator anywhere, but I get a similar expression in which all three of the "small" square roots are the same. They are identical to the one that's being complex conjugated in the incorrect LaTeX above. I will try to describe the problem again, since my description contains several mistakes. Consider this code.
$$\frac{d v \sin (t) (a+b v)}{v \sqrt{4 a^2 k^2 \sin ^4\left(\frac{t}{2}\right)+d^2 \sin ^2(t) (a+b v)^2} \sqrt{\sqrt{4 a^2 k^2 \sin ^4\left(\frac{t}{2}\right)+d^2 \sin ^2(t) (a+b v)^2} \left(\frac{1}{\sqrt{4 a^2 k^2 \sin ^4\left(\frac{t}{2}\right)+d^2 (a+b v)^2 \sin ^2(t)}}\right)^*}}$$ This should be accurate, since the only thing I changed manually was the complex conjugation symbol. 


#11
Feb2013, 08:45 AM

Mentor
P: 17,307

Now, if you know that the term under the square root is not just real, but positive, then it can simplify further, but putting in a condition like:
What you can do in situations like that is make a direct substitution rather than a simplifying assumption:



#12
Feb2013, 11:35 AM

Emeritus
Sci Advisor
PF Gold
P: 9,403

Wow. FullSimplify really worked much better on this expression. Thanks for the tip. That substitution thing is interesting too.



#13
Feb2013, 01:38 PM

Sci Advisor
P: 1,594

It's usually better to solve for one variable in the substitution you want to make, and write something of the form



Register to reply 
Related Discussions  
MATHEMATICA : Forcing Logarithms to Simplify  Math & Science Software  3  
Simplify this expression with Mathematica  Math & Science Software  4  
Help ly needed in Mathematica Simplify  Math & Science Software  1  
Mathematica can't simplify  Math & Science Software  4  
How to simplify an expression in Mathematica  Math & Science Software  15 