Peeter Joot's (OLD) Blog.

Math, physics, perl, and programming obscurity.

wolframalpha fails grade 11 trig.

Posted by peeterjoot on November 9, 2009

Considering the spherical pendulum I ended up with the following quadratic form

\begin{aligned} Q &= \left\langle A A^\text{T} \right\rangle \\ A &=\begin{bmatrix}\mathbf{e}_1 e^{i \phi} e^{j \theta} \\ \mathbf{e}_2 e^{i \phi} \sin\theta\end{bmatrix} \\ i &= \mathbf{e}_1 \wedge \mathbf{e}_2 \\ j &= \mathbf{e}_3 \wedge \left( \mathbf{e}_1 e^{i \phi} \right) \end{aligned}

Expanding Q or similar matrixes is a bit messy, and I thought I’d try to do it with software to avoid errors. Having written a symbol Geometric Algebra calculator, but not having any sort of trig reduction engine built into that. I haven’t had access to mathematica since leaving school a decade ago, so I made my calculator produce output that I could cut and paste into wolfram alpha’s online engine. Here’s the ones that I tried, for the Q(1,1), and Q(2,2) terms respectively

simplify sin(phi)^4 sin(theta)^2 + cos(theta)^2 sin(phi)^2 + cos(phi)^4 sin(theta)^2 + 2cos(phi)^2 sin(phi)^2 sin(theta)^2 + cos(phi)^2 cos(theta)^2 
simplify sin(phi)^2 sin(theta)^2 + cos(phi)^2 sin(theta)^2 

These both reduce manually without too much effort, and one should get 1 and \sin^2 \theta respectively. Wolfram’s engine gives for the first

(Cos[ϕ]^2 + Sin[ϕ]^2) (Cos[θ]^2 + Cos[ϕ]^2 Sin[θ]^2 + Sin[θ]^2 Sin[ϕ]^2)

It misses \sin^2 + \cos^2 = 1 three times! Mrs Sardi back at Central Technical School would have failed these guys.

For the less complex expression it does a bit better, but still misses the unit circle identity

Sin[θ]^2 (Cos[ϕ]^2 + Sin[ϕ]^2)

I hope that the real mathematica product does better. Perhaps it needs more time to do a better computation, and is giving up fast in its online version.

My intention was actually to see if the online engine would reduce the elements of a more slightly complex matrix than the one above. I’d done it manually and wanted to verify the output. If it can’t do these simple cases effectively, there’s probably not much point trying the more complex cases.

8 Responses to “wolframalpha fails grade 11 trig.”

  1. Eli said

    In[1]:= Simplify[Sin[phi]^4 Sin[theta]^2+Cos[theta]^2 Sin[phi]^2+Cos[phi]^4 Sin[theta]^2+2 Cos[phi]^2 Sin[phi]^2 Sin[theta]^2+Cos[phi]^2 Cos[theta]^2]
    Out[1]= 1

    • Eli said

      In[2]:= Simplify[Sin[phi]^2 Sin[theta]^2+Cos[phi]^2 Sin[theta]^2]
      Out[2]= Sin[theta]^2

    • peeterjoot said

      Cool. Mrs Sardi wouldn’t have flunked the real product. Can it do these ones?

      # AB11:
      Simplify[ Sin[theta_c] Sin[phi_c]^2 Sin[phi_r]^2 Sin[theta_r] + Cos[phi_r]^2 Sin[theta_c] Sin[phi_c]^2 Sin[theta_r] + Cos[phi_c]^2 Sin[theta_c] Sin[phi_r]^2 Sin[theta_r] + Cos[phi_c]^2 Cos[phi_r]^2 Sin[theta_c] Sin[theta_r] + Cos[theta_c] Cos[theta_r] Sin[phi_c] Sin[phi_r] + Cos[theta_c] Cos[phi_c] Cos[phi_r] Cos[theta_r] ]

      # AB12:
      Simplify[ – Cos[phi_r] Cos[theta_r] Sin[theta_c] Sin[phi_c] + Cos[phi_c] Cos[theta_r] Sin[theta_c] Sin[phi_r] ]

      # AB21 :
      Simplify[Cos[theta_c] Cos[phi_r] Sin[phi_c] Sin[theta_r] – Cos[theta_c] Cos[phi_c] Sin[phi_r] Sin[theta_r]]

      # AB22 :
      Simplify[ Sin[theta_c] Sin[phi_c] Sin[phi_r] Sin[theta_r] + Cos[phi_c] Cos[phi_r] Sin[theta_c] Sin[theta_r] ]

      I expect, respectively

      \cos(\phi_r - \phi_c) \cos\theta_r\cos\theta_c + \sin\theta_r\sin\theta_c

      1,2 = 2,1 = \sin(\phi_c - \phi_r) \cos\theta_c \sin\theta_r


      \cos(\phi_c - \phi_r)\sin\theta_r\sin\theta_c

      (now if it gets a different answer, maybe I’m the one who should have flunked grade 11;)

      • Eli said

        # AB11:
        In[2]:= FullSimplify[Sin[theta_c] Sin[phi_c]^2 Sin[phi_r]^2 Sin[theta_r]+Cos[phi_r]^2 Sin[theta_c] Sin[phi_c]^2 Sin[theta_r]+Cos[phi_c]^2 Sin[theta_c] Sin[phi_r]^2 Sin[theta_r]+Cos[phi_c]^2 Cos[phi_r]^2 Sin[theta_c] Sin[theta_r]+Cos[theta_c] Cos[theta_r] Sin[phi_c] Sin[phi_r]+Cos[theta_c] Cos[phi_c] Cos[phi_r] Cos[theta_r]]
        Out[2]= Cos[phi_c-phi_r] Cos[theta_c] Cos[theta_r]+Sin[theta_c] Sin[theta_r]

        # AB12:
        In[5]:= Simplify[-Cos[phi_r] Cos[theta_r] Sin[theta_c] Sin[phi_c]+Cos[phi_c] Cos[theta_r] Sin[theta_c] Sin[phi_r]]
        Out[5]= -Cos[theta_r] Sin[phi_c-phi_r] Sin[theta_c]

        # AB21: (Originally that first – in the initial expression was being interpreted as “\[Dash]” so it didn’t simplify. But then I realized what was going on.)
        In[9]:= Simplify[Cos[theta_c] Cos[phi_r] Sin[phi_c] Sin[theta_r] – Cos[theta_c] Cos[phi_c] Sin[phi_r] Sin[theta_r]]
        Out[9]= Cos[theta_c] Sin[phi_c-phi_r] Sin[theta_r]

        # AB22:
        In[10]:= Simplify[Sin[theta_c] Sin[phi_c] Sin[phi_r] Sin[theta_r]+Cos[phi_c] Cos[phi_r] Sin[theta_c] Sin[theta_r]]
        Out[10]= Cos[phi_c-phi_r] Sin[theta_c] Sin[theta_r]

        It gets these results in the blink of an eye, not like Alpha. I could not survive without Mathematica. Fantastic program.

  2. peeterjoot said

    Ah, I’m jealous — last time I looked mathematica cost ~$1000 … something I couldn’t justify for my hobbist play.

    … but good news is that I didn’t fail my grade 11 trig. Mathematica found the result I got in (22) of my recent multiPendulumSpherical2.pdf (I wrote 1,2 == 2,1 incorrectly above, and it identified that typo in these comments). I didn’t actually have to do a brute force simplification above (all my \phi_c - \phi_r angles stayed together for example making my work easier than the problem mathematica was given).

    • peeterjoot said

      UGG. I was wrong. $2500 canadian for mathematica since I don’t qualify for the student edition.

      • Eli said

        Not that I’m condoning such actions, because if anyone deserves their moolah it’s the Wolfram folks, but there are torrents of the thing floating around somewhere, I think.

        Alternately, maybe IBM has some licenses you can borrow? Or is that an incredibly naive statement on my part…

      • peeterjoot said

        I’m sure there are people in IBM research that have access to licenses for this. But in our development lab, it’s not even on the list of things we can ask for. I’d have to present a business case, and don’t have one;)

        I never noticed before that there is a home-edition, and that’s only 300 (usd I presume) — that wasn’t available when I looked last time (long long ago). That’s a whole lot more reasonable than 2500.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: