Monday, January 27, 2014

Using Wolfram Alpha

It can be a bit tricky to get Wofram Alpha to understand what you want. A couple of key tricks (and I'll give examples) to make it easier:

  1. Re-define any overall multiplying constants to be a single constant. If you have y = 2*b*c*x, just call it y=A*x and note that A=2*b*c.
  2. Call the variables x and y instead of, say, theta or phi. If you have y=sin(theta), put it in as y=sin(x). Your keyboard probably does not have a theta key, and wolfram may think "theta" = t*h*e*t*a.
  3. Realize that Wolfram is solving the most general problem possible, so it will assume that, for instance, your function can take complex numbers, or that any angle is valid (not just 0-360 or 0-90).

Say the formula is how far up the ramp the projectile lands in HW2 problem 3, the one we derived in class today:

L = 2v^2 cos(theta) sin(theta-phi) / (g cos^2(phi))

What you want is to maximize L with respect to theta, i.e., take dL/d(theta) and set it equal to zero. Typing this right into Wolfram will probably lead to a mess.

The overall factor of 2v^2/(g cos^2(phi)) has nothing to do with theta, and it is really just making things messier. Furthermore, when we do dL/d(theta)=0 it won't matter anyway. So let's define A=2v^2/(g cos^2(phi)). That gives us

L = A*cos(theta)*sin(theta-phi)   

Wolfram will also have an easier time if we use x & y, so let's let L=y and theta=x. 

y = A*cos(x)*sin(x-phi)   

Wolfram also might not like us writing out "phi", so let's substitute phi=p. Then we have 

y = A*cos(x)*sin(x-p)

This is the same formula we started with, but we lumped all the constants together (into A) and made the variable names easier to parse (no greek letters we can't easily type as a single character). Now we can ask Wolfram to find


or even d/dx A*cos(x)*sin(x-p) = 0. 

At this point, Wolfram will probably add another constant into the final result for the roots, something like 2*pi*c1. That's telling you that you can add an overall integer (c1) multiple of 2*pi to the result and it is also a zero. That's because the cos and sin functions are periodic, so to any solution for the angle you can always add 2*pi and that is also a solution. If you restrict yourself to reasonable ramps (phi between 0 and pi/2) and reasonable launch angles (theta between 0 and pi/2), you'll see that under those restrictions it must be the case that c1=0. Wolfram doesn't know you only want to consider angles between 0 and pi/2 because you never told it that ...

Hope that helps. We'll get more and more into using Wolfram as the semester progresses, and I'll try to provide examples as we go.

No comments:

Post a Comment