[Date Index]
[Thread Index]
[Author Index]
Re: Mathematica can't win against Tiger Woods
*To*: mathgroup at smc.vnet.net
*Subject*: [mg19797] Re: [mg19677] Mathematica can't win against Tiger Woods
*From*: "Allan Hayes" <hay at haystack.demon.co.uk>
*Date*: Fri, 17 Sep 1999 01:36:49 -0400
*References*: <7red0n$474@smc.vnet.net> <7rnkog$emd@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Leszek,
You raise some serious points
We certainly need Mathematica to give simpler and more understandable
solutions and to have better tools for manipulating expressions. And it is
clearly important to teach abstract, conceptual skills as well as computer
skills.
I have been looking at the examples that you consider:
> 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.
Solve[{p == b^2/a, e == Sqrt[a^2 - b^2]/a}, {a, b}]
{{b -> (-I*p)/Sqrt[-1 + e^2], a -> -(p/(-1 + e^2))},
{b -> (I*p)/Sqrt[-1 + e^2], a -> -(p/(-1 + e^2))}}
The following at least gets rid of the complex numbers.
Simplify[%, a > 0 && b > 0 && p > 0 && 1 > e > 0]
{{b -> -(p/Sqrt[1 - e^2]), a -> -(p/(-1 + e^2))},
{b -> p/Sqrt[1 - e^2], a -> -(p/(-1 + e^2))}}
-----------
With regard to the differential equation problem.
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];
I would like to have a quick and general way of getting rid unnecessary
complex forms.
For this solution following does it in less than one and a half seconds. I
would be interested to know how it works in other situations.
An important feature is the use of assumptions to help simplify.
assume = {a, b} \[Element] Reals && g > 0;
(ss = Simplify[ComplexExpand[Simplify[solution, assume]
], assume]) // Timing
{1.38 Second,
{{1/(a^2 + b^2)^2*
(E^(a*t)*(a^4*C[1] + a^3*(-g*t + C[3]) +
a*b^2*(-g*t + C[3]) +
b^2*(-g + b*(b*C[1] + C[4])) +
a^2*(g + b*(2*b*C[1] + C[4]))) -
(a^2 + b^2)*(a*C[3] + b*C[4])*Cos[b*t] -
(a^2 + b^2)*(-b*C[3] + a*C[4])*Sin[b*t])/
E^(a*t), 1/(a^2 + b^2)^2*
(E^(a*t)*(a^4*C[2] + b^3*(g*t + b*C[2] - C[3]) +
a^2*b*(g*t + 2*b*C[2] - C[3]) + a^3*C[4] +
a*b*(-2*g + b*C[4])) - (a^2 + b^2)*
(-b*C[3] + a*C[4])*Cos[b*t] +
(a^2 + b^2)*(a*C[3] + b*C[4])*Sin[b*t])/
E^(a*t)}}}
Now, to simplify this by manipulation and introducing new constants - I list
the inputs.
Map[Collect[#, {C[1], C[2], C[3], C[4], t}, FullSimplify] &, ss, {2}]
% /. C[k_]/(a^2 + b^2) -> C[k]
% /. Plus[C[k_], _?(FreeQ[#, t] &)] -> C[k]
Map[Collect[#, {Sin[b t], Cos[b t], t}, FullSimplify] &, %, {2}]
% //. {C[1] + a C[3] + b C[4] -> C1,
C[2] - b C[3] + a C[4] -> C2,
(a C[3] + b C[4]) -> C3,
(b C[3] - a C[4]) -> C4}
{{C1 - (a*g*t)/(a^2 + b^2) - (C3*Cos[b*t])/E^(a*t) +
(C4*Sin[b*t])/E^(a*t), C2 + (b*g*t)/(a^2 + b^2) +
(C4*Cos[b*t])/E^(a*t) + (C3*Sin[b*t])/E^(a*t)}}
This your penultimate solution form.
The final form would need a more specific handling.
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
----- Original Message -----
From: Leszek Sczaniecki <leszek2 at home.com>
To: mathgroup at smc.vnet.net
Subject: [mg19797] Re: [mg19677] Mathematica can't win against Tiger Woods
>
>
> 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
> > >Subject: [mg19797] [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
> > >
> > >
>
>
Prev by Date:
**Re: Image-Sequence analyse with M4**
Next by Date:
**Re: Some problems with DSolve and NDSolve**
Previous by thread:
**Re: Re: Mathematica can't win against Tiger Woods**
Next by thread:
**Re: Re: Mathematica can't win against Tiger Woods**
| |