MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mathematica syntax

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87909] Re: Mathematica syntax
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 19 Apr 2008 23:51:14 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <fuc7qs$a11$1@smc.vnet.net>

c.justin88 at gmail.com wrote:
> An error is yielded with the below segment:
> 
> l4**2*m1*phidd - l3**2*m2*psidd +
> - l1**2*m1*thdd + l4**2*m1*thdd + l2**2*m2*thdd +
> - l3**2*m2*thdd + (l1**2*mb*thdd)/3. -
> - (l1*l2*mb*thdd)/3. + (l2**2*mb*thdd)/3. -
> - l1*l4*m1*(phidd + 2*thdd)*Cos(phi) +
> - l2*l3*m2*(psidd - 2*thdd)*Cos(psi) +
> - l1*l4*m1*phid**2*Sin(phi) +
> - 2*l1*l4*m1*phid*thd*Sin(phi) -
> - l2*l3*m2*psid**2*Sin(psi) +
> - 2*l2*l3*m2*psid*thd*Sin(psi) -
> - g*l3*m2*Sin(psi - th) + g*l1*m1*Sin(th) -
> - g*l2*m2*Sin(th) + (g*l1*mb*Sin(th))/2. -
> - (g*l2*mb*Sin(th))/2. - g*l4*m1*Sin(phi + th).eq.0,
> l4*m1*(l4*phidd + l4*thdd - l1*thdd*Cos(phi) -
> - l1*thd**2*Sin(phi) - g*Sin(phi + th)).eq.0,
> l3*m2*(l3*psidd - l3*thdd + l2*thdd*Cos(psi) -
> - l2*thd**2*Sin(psi) + g*Sin(psi - th)).eq.0
> 
> (This is from a old version of Mathematica, I think v3)
> 
> It gives a syntax error and (psi) and (phi) are invalid.
> 
> What needs to be corrected? I'll post the whole notebook aftewards.

As far as I can tell, the extract of code you posted is incomplete (it 
is a list of equalities and the curly braces that must surround them are 
missing), the .eq. symbol (FORTRAN syntax?) must stand for Equal[] (also 
==, double equal sign), and the expressions are imputed in 
TraditionalForm[].

Also, the code posted contains too many minus signs (perhaps a side 
effect of copying and pasting within your newsreader client?) and the 
double star sign ** means non-commutative multiplication. Is this really 
what you want? Non-commutative multiplication between scalars such as 14 
and 2 is not really meaningful. However, some other programming 
languages , such as FORTRAN if I remember well, use ** to indicate 
exponentiation.

So, you should fix the code by adding curly braces around lists of 
equations, discard the excessive minus sings, changing .eq. to ==, and 
be sure of the meaning of the ** (otherwise, replace them by a single * 
for regular multiplication or a ^ for exponentiation).

Also, do not forger to tell Mathematica that this is TraditionalForm[] 
or use square brackets [] rather than parentheses () when passing 
arguments to a function.

Finally, your code should more or less looks like

{-(1/3) l1 l2 mb thdd - l1 l4 m1 (phidd + 2 thdd) Cos[phi] +
    l2 l3 m2 (psidd - 2 thdd) Cos[psi] + m1 thdd l1 ** 2 +
    1/3 mb thdd l1 ** 2 + m2 thdd l2 ** 2 + 1/3 mb thdd l2 ** 2 -
    m2 psidd l3 ** 2 + m2 thdd l3 ** 2 + m1 phidd l4 ** 2 +
    m1 thdd l4 ** 2 + 2 l1 l4 m1 phid thd Sin[phi] +
    l1 l4 m1 phid ** 2 Sin[phi] + 2 l2 l3 m2 psid thd Sin[psi] -
    l2 l3 m2 psid ** 2 Sin[psi] - g l3 m2 Sin[psi - th] +
    g l1 m1 Sin[th] - g l2 m2 Sin[th] + 1/2 g l1 mb Sin[th] -
    1/2 g l2 mb Sin[th] - g l4 m1 Sin[phi + th] == 0,
  l4 m1 (l4 phidd + l4 thdd - l1 thdd Cos[phi] - l1 thd ** 2 Sin[phi] -
       g Sin[phi + th]) == 0,
  l3 m2 (l3 psidd - l3 thdd + l2 thdd Cos[psi] - l2 thd ** 2 Sin[psi] +
       g Sin[psi - th]) == 0}


HTH,
-- Jean-Marc


  • Prev by Date: Re: Problems to find the local extrema of an InterpolatingFunction
  • Next by Date: Re: problem accessing notebooks
  • Previous by thread: Re: Mathematica syntax
  • Next by thread: problem accessing notebooks