Re: [math-fun] Mathematica help sought
Why Mathematica drives me up the wall: All I wanted was for it to square the expression for f[u,v] here. Finally (after the following) I tried Expand first, then Simplify, and at last it actually squared the thing. Sheesh. --Dan ****************************************************************** In[1]:= f[u_,v_] := Sqrt[5+4Cos[u]] + 2.5*Sin[(u-v)/2] + Sqrt[11-6Cos[v]-2Sin[v]] In[2]:= g[u_,v_] := f[u,v]^2 In[3]:= g[u,v] u - v Out[3]= Power[Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]], 2]
In[4]:= FullSimplify[g[u,v]] u - v Out[4]= Power[Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]], 2]
In[5]:= Clear[g] In[6]:= g[u_,v_] := f[u,v]*f[u,v] In[7]:= g[u,v] u - v Out[7]= Power[Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]], 2]
In[8]:= Simplify[%] u - v Out[8]= Power[Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]], 2]
In[9]:= In[9]:= (Sqrt[5+4Cos[u]] + 2.5*Sin[(u-v)/2] + Sqrt[11-6Cos[v]-2Sin[v]])*(Sqrt[5+4Cos[u]] + 2.5*Sin[(u-v)/2] + Sqrt[11-6Cos[v]-2Sin[v]]) u - v Out[9]= Power[Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]], 2]
In[10]:= Simplify[%] u - v Out[10]= (Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]])
****************************************************************** Sometimes the brain has a mind of its own.
(1) Why do you have a coefficient of 2.5 in f[u,v], instead of 5/2? This is making Mma do everything in terms of numerical approximations instead of exact solutions. Is that your intent? (2) "All I wanted was for it to square the expression for f[u,v] here" -- try Expand[ f[u,v]^2 ]. --Michael On Fri, May 13, 2011 at 3:34 PM, Dan Asimov <dasimov@earthlink.net> wrote:
Why Mathematica drives me up the wall:
All I wanted was for it to square the expression for f[u,v] here.
Finally (after the following) I tried Expand first, then Simplify, and at last it actually squared the thing. Sheesh.
--Dan
****************************************************************** In[1]:= f[u_,v_] := Sqrt[5+4Cos[u]] + 2.5*Sin[(u-v)/2] + Sqrt[11-6Cos[v]-2Sin[v]]
In[2]:= g[u_,v_] := f[u,v]^2
In[3]:= g[u,v]
u - v Out[3]= Power[Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]], 2]
In[4]:= FullSimplify[g[u,v]]
u - v Out[4]= Power[Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]], 2]
In[5]:= Clear[g]
In[6]:= g[u_,v_] := f[u,v]*f[u,v]
In[7]:= g[u,v]
u - v Out[7]= Power[Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]], 2]
In[8]:= Simplify[%]
u - v Out[8]= Power[Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]], 2]
In[9]:= In[9]:= (Sqrt[5+4Cos[u]] + 2.5*Sin[(u-v)/2] + Sqrt[11-6Cos[v]-2Sin[v]])*(Sqrt[5+4Cos[u]] + 2.5*Sin[(u-v)/2] + Sqrt[11-6Cos[v]-2Sin[v]])
u - v Out[9]= Power[Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]], 2]
In[10]:= Simplify[%]
u - v Out[10]= (Sqrt[5 + 4 Cos[u]] + 2.5 Sin[-----] + 2
2
Sqrt[11 - 6 Cos[v] - 2 Sin[v]])
******************************************************************
Sometimes the brain has a mind of its own.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
-- Forewarned is worth an octopus in the bush.
participants (2)
-
Dan Asimov -
Michael Kleber