Re: Re: Mathematica can't win against TigerWoods

*To*: mathgroup at smc.vnet.net*Subject*: [mg19849] Re: [mg19765] Re: [mg19677] Mathematica can't win against TigerWoods*From*: Adam Strzebonski <adams at wolfram.com>*Date*: Sun, 19 Sep 1999 01:20:34 -0400*References*: <199909171007.TAA06723@soda1.bekkoame.ne.jp>*Sender*: owner-wri-mathgroup at wolfram.com

Andrzej Kozlowski wrote: > > When I first quickly read the message below I only paid attention to the > author's remarks about "serious mathematics and physics" and "lower middle > class scientists" and didn't read the rest. But having re-read it I found > that al the fuss was just about the fact that Adam Strzbonski omitted to add > some rules to Simplify. Here is an example of what I mean, I am sue he can > do it much better: > > In[4]:= > newsimplify[expr_, ass_] := > Simplify[expr /. Sqrt[x_ /; Simplify[x < 0, ass] == True] -> I*Sqrt[-x], > ass] > > In[5]:= > sol = Solve[{p == b^2/a, e == Sqrt[a^2 - b^2]/a}, {a, b}] > Out[5]= > {{b -> -((I*p)/Sqrt[-1 + e^2]), a -> -(p/(-1 + e^2))}, > {b -> (I*p)/Sqrt[-1 + e^2], a -> -(p/(-1 + e^2))}} > > In[6]:= > newsimplify[sol, 0 < e < 1] > Out[6]= > {{b -> -(p/Sqrt[1 - e^2]), a -> -(p/(-1 + e^2))}, {b -> p/Sqrt[1 - e^2], > a -> -(p/(-1 + e^2))}} > > Of course one can write a more general rule for all odd powers, not just > Sqrt. Actually, this particular rule, or more precisely the rule a^p -> (-1)^p (-a)^p, for a<0 is built-in in V4.0 Simplify. In[1]:= InputForm[ sol = Solve[{p == b^2/a, e == Sqrt[a^2 - b^2]/a}, {a, b}]] Out[1]//InputForm= {{b -> (-I*p)/Sqrt[-1 + e^2], a -> -(p/(-1 + e^2))}, {b -> (I*p)/Sqrt[-1 + e^2], a -> -(p/(-1 + e^2))}} In[2]:= Simplify[sol, 0 < e < 1]//InputForm Out[2]//InputForm= {{b -> -(p/Sqrt[1 - e^2]), a -> -(p/(-1 + e^2))}, {b -> p/Sqrt[1 - e^2], a -> -(p/(-1 + e^2))}} Best Regards, Adam Strzebonski Wolfram Research > -- > Andrzej Kozlowski > Toyama International University > JAPAN > http://sigma.tuins.ac.jp > http://eri2.tuins.ac.jp > > ---------- > >From: Leszek Sczaniecki <leszek2 at home.com> To: mathgroup at smc.vnet.net > >To: mathgroup at smc.vnet.net > >Subject: [mg19849] [mg19765] Re: [mg19677] Mathematica can't win against Tiger Woods > >Date: Wed, Sep 15, 1999, 4:53 PM > > > > > > > > > To many times I tried to replicate simple computations done by hand with > > Mathematica and was not able to get results that would justify the use of an > > expensive computer algebra system. Therefore, I understand very well the > > frustration of Prof. MacDonald. Here is a recent example. > > > > Consider a very simple problem from analytical geometry. There an ellipse > > with semi-latus rectum p and eccentricity e. You want to find semi-major > > axis a, and semi-minor axis b. This is clearly a high school problem. > > > > First, let's do it manually. We have p > 0, 0 < e < 1, a > b > 0. > > p = b^2/a > > e = Sqrt[a^2 - b^2]/a} > > from 0. > > > > e = Sqrt[a^2 - b^2]/a} > > => e^2 = (a^2 - b^2)/a^2 > > => b^2/a^2 = 1-e^2 > > p = b^2/a = (b^2/a^2) a = (1-e^2)a > > => a = p/(1-e^2) > > p = b^2/a > > => b^2 = p a = p^2 /(1-e^2) > > => b = p /Sqrt[1-e^2] or b = -p /Sqrt[1-e^2] > > Because b > 0, b = p /Sqrt[1-e^2]. > > > > Here is the result from Mathematica 4.0 > > In[1]:= > > Solve[{p == b^2/a, e == Sqrt[a^2 - b^2]/a}, {a, b}] // InputForm > > > > Out[2]= > > {{b -> (-I*p)/Sqrt[-1 + e^2], a -> -(p/(-1 + e^2))}, > > {b -> (I*p)/Sqrt[-1 + e^2], a -> -(p/(-1 + e^2))}} > > > > There is no way to transfer the solution to the form obtained by hand. The > form > > returned by Solve is purely developer's decision. BTW, Mathematica 3.0 > produces a > > different form of the result. Imagine yourself giving a lecture to high school > > students who are not familiar with complex numbers. How would you explain them > the > > solution? > > > > Luckily, there is a way to get the expected result by using InequalitySolve > (in > > 4.0). > > > > In[3]:= << Algebra`InequalitySolve` > > > > In[4]:= > > InequalitySolve[{p > 0, 0 < e < 1, a > b > 0, p == b^2/a, > > e == Sqrt[a^2 - b^2]/a}, {e, p, a, b}] > > > > Out[4]= > > 0 < e < 1 && p > 0 && a == -(p/(-1 + e^2)) && b == Sqrt[a^2 - a^2*e^2] > > > > In[5]:= > > Simplify[{a, b} //. ToRules[Drop[%, 2]], Take[%, 2]] // InputForm > > > > Out[5]//InputForm= > > {-(p/(-1 + e^2)), p/Sqrt[1 - e^2]} > > > > I am positive, that an average Mathematica user would not figured out to use > > InequalitySolve. Also, notice that human would rather write the first term in > the > > form: > > p/(1 - e^2). > > LeafCount for this form is 11. The Mathematica expression has LeafCount of 10. > > That clearly proves that LeafCount alone is not necessarily the best measure > of > > the simplicity (in human terms) of an expression. > > > > Let's now solve the equations posted by Prof. MacDonald with some human help. > We > > will solve first the equations for velocities (denoted by u[t] and v[t]). BTW, > I > > use InputForms to avoid expressions hard to read in ascii form. > > > > In[1]:= > > solution1 = {u[t], v[t]} /. > > DSolve[{u'[t] == -(a u[t] + b v[t]), > > v'[t] == -g - (a v[t] - b u[t])}, > > {u[t], v[t]}, t] // InputForm > > > > Out[1]//InputForm= > > {{(a^2*C[1]*Cos[b*t] + b^2*C[1]*Cos[b*t] + > > b*E^(a*t)*g*Cos[b*t]^2 - a^2*C[2]*Sin[b*t] - > > b^2*C[2]*Sin[b*t] + b*E^(a*t)*g*Sin[b*t]^2)/ > > ((a - I*b)*(a + I*b)*E^(a*t)), > > -((-(a^2*C[2]*Cos[b*t]) - b^2*C[2]*Cos[b*t] + > > a*E^(a*t)*g*Cos[b*t]^2 - a^2*C[1]*Sin[b*t] - > > b^2*C[1]*Sin[b*t] + a*E^(a*t)*g*Sin[b*t]^2)/ > > ((a - I*b)*(a + I*b)*E^(a*t)))}} > > > > At this point imagine yourself advocating Mathematica to golf players not > familiar > > with the concept of complex numbers.:-) Good luck in explaining what > ComplexExpand > > and TargetFunctions do! > > > > In[2]:= > > FullSimplify[ComplexExpand[solution1, TargetFunctions -> {Im, Re}]] > > > > Out[2]//InputForm= > > {{(b*g)/(a^2 + b^2) + (C[1]*Cos[b*t] - C[2]*Sin[b*t])/ > > E^(a*t), -((a*g)/(a^2 + b^2)) + > > (C[2]*Cos[b*t] + C[1]*Sin[b*t])/E^(a*t)}} > > > > Very good! This is a pretty simple form. Now we have to integrate both terms > and > > add a constant to each of them. > > > > In[3]:= > > solution2 = Integrate[%, t] + {{C[3], C[4]}} // InputForm > > > > Out[3]//InputForm= > > {{(b*g*t)/(a^2 + b^2) + C[3] + > > ((-(a*C[1]) + b*C[2])*Cos[b*t])/((-I*a + b)*(I*a + b)* > > E^(a*t)) + ((b*C[1] + a*C[2])*Sin[b*t])/ > > ((-I*a + b)*(I*a + b)*E^(a*t)), > > -((a*g*t)/(a^2 + b^2)) + C[4] - > > ((b*C[1] + a*C[2])*Cos[b*t])/((a - I*b)*(a + I*b)* > > E^(a*t)) - ((a*C[1] - b*C[2])*Sin[b*t])/ > > ((a - I*b)*(a + I*b)*E^(a*t))}} > > > > Well, we got complex expressions again. Simplify and FullSimplify don't help > much. > > > > In[4]:= > > FullSimplify[ComplexExpand[solution2, TargetFunctions -> {Im, Re}]] > > > > Out[4]//InputForm= > > {{(E^(a*t)*(b*g*t + (a^2 + b^2)*C[3]) + > > (-(a*C[1]) + b*C[2])*Cos[b*t] + (b*C[1] + a*C[2])* > > Sin[b*t])/((a^2 + b^2)*E^(a*t)), > > (E^(a*t)*(-(a*g*t) + (a^2 + b^2)*C[4]) - > > (b*C[1] + a*C[2])*Cos[b*t] + (-(a*C[1]) + b*C[2])* > > Sin[b*t])/((a^2 + b^2)*E^(a*t))}} > > > > Take the first term. > > > > In[5]:= > > LeafCount[(E^(a*t)*(b*g*t + (a^2 + b^2)*C[3]) + (-(a*C[1]) + b*C[2])* > > Cos[b*t] + (b*C[1] + a*C[2])*Sin[b*t])/((a^2 + b^2)*E^(a*t))] > > > > Out[5]= > > 67 > > > > Any person with decent high school education can momentarily simplify this > > expression. > > > > ((b*g*t) + E^(-a*t)((-(a*C[1]) + b*C[2])*Cos[b*t] + (b*C[1] + a*C[2])* > > Sin[b*t]))/((a^2 + b^2)) + C[3] > > > > In[6]:= > > LeafCount[((b*g*t) + > > E^(-a*t)((-(a*C[1]) + b*C[2])*Cos[b*t] + (b*C[1] + a*C[2])* > > Sin[b*t]))/((a^2 + b^2)) + C[3]] > > > > Out[6]= > > 55 > > > > In[7]:= > > ((b*g*t) + E^(-a*t)((-(a*C[1]) + b*C[2])*Cos[b*t] + (b*C[1] + a*C[2])* > > Sin[b*t]))/((a^2 + b^2)) + > > C[3] == (E^(a*t)*(b*g*t + (a^2 + b^2)*C[3]) + (-(a*C[1]) + b*C[2])* > > Cos[b*t] + (b*C[1] + a*C[2])*Sin[b*t])/((a^2 + b^2)* > > E^(a*t)) // FullSimplify > > > > Out[7]= > > True > > > > Additionally, a human can notice that appropriately choosing the constants, > one > > can further simplify the expression. > > > > b*g*t/(a^2 + b^2) + E^(-a*t)(C[1]*Cos[b*t] + C[2]*Sin[b*t]) + C[3] > > > > (LeafCount of 38) or > > > > b*g*t/(a^2 + b^2) + E^(-a*t)*C[1]*Cos[b*t + C[2]] + C[3] > > > > (LeafCount of 32). As you can see, there are simpler solutions than those > produced > > by Mathematica. > > > > 10 - 12 years ago an average mathematics, physics, or engineering student > could > > solve these equations by hand and in time much shorter I needed to get a > solution > > with help of Mathematica for just one variable. Ironically, there is well > known > > exact solution for the differential equation of the form > > > > d x > > --- = A x + B > > d t > > > > in Banach space. From there one can get a solution for the case when A is a > > matrix, and x, B are vectors. > > > > Here is my point. Mathematica can certainly do plenty of problems much better > than > > human. But, it is very, very frustrating, that in trivial cases the system > often > > produces results worse then those delivered by a human. I see this as the > > challenge for Mathematica developers. The system should always produce better > > results than human. Presently, Mathematica is a tool for some kind of > "scientific > > lower middle class". It is way to weak for people, who do serious mathematics > or > > theoretical physics, and way to complicated for pedestrians. If Wolfram > Research > > Inc. truly intents to reach "masses", it has to be more sensitive to their > needs. > > > > --Leszek > > > > Andrzej Kozlowski wrote: > > > >> I don't think of myself as a "computer algebra nerd" and I don't play golf > >> but it seems to me that Mathemaitca does this problem rather well: > >> > >> In[2]:= > >> solution = {y[t], x[t]} /. DSolve[{x''[t] == - (a x'[t] + b y'[t]), > >> y''[t] == - g - (a y'[t] - b x'[t])}, {y[t], x[t]}, t]; > >> > >> In[3]:= > >> Simplify[ComplexExpand[solution, TargetFunctions -> {Im, Re}]] > >> > >> Out[3]= > >> 1 a t 4 3 > >> {{---------- (E (a C[1] + a (-g t + C[3]) + > >> 2 2 2 > >> (a + b ) > >> > >> 2 2 > >> a b (-g t + C[3]) + b (-g + b (b C[1] + C[4])) + > >> > >> 2 > >> a (g + b (2 b C[1] + C[4]))) - > >> > >> 2 2 > >> (a + b ) (a C[3] + b C[4]) Cos[b t] - > >> > >> 2 2 a t > >> (a + b ) (-b C[3] + a C[4]) Sin[b t]) / E , > >> > >> 1 a t 4 3 > >> ---------- (E (a C[2] + b (g t + b C[2] - C[3]) + > >> 2 2 2 > >> (a + b ) > >> > >> 2 3 > >> a b (g t + 2 b C[2] - C[3]) + a C[4] + > >> > >> a b (-2 g + b C[4])) - > >> > >> 2 2 > >> (a + b ) (-b C[3] + a C[4]) Cos[b t] + > >> > >> 2 2 a t > >> (a + b ) (a C[3] + b C[4]) Sin[b t]) / E }} > >> > >> -- > >> Andrzej Kozlowski > >> Toyama International University > >> JAPAN > >> http://sigma.tuins.ac.jp > >> http://eri2.tuins.ac.jp > >> > >> ---------- > >> >From: "William M. MacDonald" <wm2 at umail.umd.edu> To: mathgroup at smc.vnet.net > > To: mathgroup at smc.vnet.net > >> >To: mathgroup at smc.vnet.net > >> >Subject: [mg19849] [mg19765] [mg19677] Mathematica can't win against Tiger Woods > >> >Date: Thu, Sep 9, 1999, 3:19 PM > >> > > >> > >> > > >> > I want to use the study of golf drives in teaching theoretical methods. An > >> > approximate pair of equations to get insight assumes that the drag force is > >> > linearly proportional to velocity, instead of the actual quadratic > >> > dependence. The equations for a ball with backspin to provide lift are > >> > x''[t]== - (a x'[t]+b y'[t]), > >> > y''[t]== - g - (a y'[t]- b x'[t]) > >> > Mathematica returns a very complicated and apparently complex expression > in > >> > about 9 seconds on my 250 MHz G3 Powerbook. Simplify takes 1min and 20 > >> > seconds and still returns an apparently complex expression. If I apply > >> > FullSimplify on the solution for say x[t], I get no answer in 6 minutes. > >> > > >> > I have a PC version of another system that I can run on my Powerbook > >> using > >> > Virtual PC. It requires 6 seconds to deliver a lengthy but obviously > real, > >> > no Exp[(a+ I b)t] terms or (a + I b)(a - I b) terms. > >> > > >> > I have never been able to learn why Mathematica is so slow in solving > >> > coupled equations and returns (as USUAL unless you use Simplify) such > >> > inelegant results. Is there any computer algebra NERD out > >> > there who knows the answer. (Don't tell me to use AlgebraicManipulation; > I > >> > am trying to sell Mathematica to users who don't want to spend time > >> > learning > >> > fancy tricks.) > >> > > >> > -- > >> > William M. MacDonald > >> > Professor of Physics > >> > University of Maryland > >> > > >> > Internet: wm2 at umail.umd.edu > >> > > >> > > > > >

**Re: Where's the Speed?**

**Re: polynomial approximation for twenty data points**

**Re: Re: Mathematica can't win against TigerWoods**

**polynomial approximation for twenty data points**