Frisbee Physics: Java vs. PTC Mathcad

math frisbee flight

In a paper, V.R. Morrison discusses an interesting model of a frisbee. The author derives the equations governing the position (x, y), velocity (x’, y’) and acceleration (x’’, y’’) of a frisbee as:

V.R. Morrison derives the equations governing the position, velocity, and acceleration

CD(α) is a drag coefficient at angle of attack (AoA) α, and CL(α) is the lift coefficient at AoA α, area and mass are, you guessed, the area and the mass of the frisbee, g is the gravitational acceleration, and ρ is the density of air.

To solve these equations and compute the frisbee’s trajectory, the paper submits a Java program implementing the Euler’s method to integrate the differential equations.

to compute the frisbee’s trajectory, a Java program implementing the Euler’s method to integrate the differential equations

While Java is perfectly capable of solving these equations, let us look at a couple of issues.


In the code we see items like:

java code units

Code like this makes an assumption that the value of AoA (ALPHA) is defined in specified units – degrees. Such assumptions are implicit. Namely, there is nothing that will alert user if he/she specifies ALPHA to be radians or even kilograms!


Does the Java code look anything like the equations above? Which is easier to read?

java code equations


ptc mathcad equations

No units checking and poor readability results in hard to catch mistakes

Looking carefully at the equations above, notice that mass is missing in the dominator of cd! Consequently the results are off. However, had we checked the units, we’d see that they don’t match, leading us to review the equation and find the problem.

Here is how we address this in PTC Mathcad. Mathcad supports programming, so the same Java code can be easily transcribed into a Mathcad program. We immediately see two advantages: readability and unit checking. Making the same mistake as in the original Java code will yield a unit error.

Java code and PTC Mathcad integration

PTC Mathcad solution

Here is the complete program:

finding the solution in PTC Mathcad

Programming in PTC Mathcad! What’s up with that?

When I talk about the PTC Mathcad roadmap, I say things like “more problem solving, less programming”, etc. So, why are we talking about Mathcad programs here? Do we have to write programs to solve differential equations? Of course not! This is Mathcad after all!

I used the programming feature to contrast PTC Mathcad and Java. We can skip the Euler’s method and solve the differential equations directly. Here is how the solution looks.

solve differential equations

There is nothing to it. Equation as you would write in your notebook, units and all! By doing so, we find (again) that the results don’t match! Equation

Java calculation is incorrect

is missing a factor of ½.

Using formulas that are easy to read and closer to the problem specification, not only makes the calculations look better, but also reduces the number of errors.

See  Frisbee Physics (using programming).mcdx for PTC Mathcad solution using programming and Frisbee Physics (using solve block).mcdx for the solution using solve blocks.

Note: You can use PTC Mathcad Express to view these documents. However, to calculate, you will need a licensed version.

Stay tuned for the worksheet that solved the same problem using features only available in  PTC Mathcad Express

This entry was posted in Best Practices, Mathcad, Mathcad A to Z, The Inside Scoop, Uncategorized and tagged , , , , , , . Bookmark the permalink.

8 thoughts on “Frisbee Physics: Java vs. PTC Mathcad”

  1. yeah but this java code can be used in a larger program and run anywhere for free. It can be a part of an application. While mathcad worksheet cannot be used in a larger program and only works in Windows after you have paid thousands of dollars. Mathcad worksheets cannot be converted into an application.

    Mathcad is mostly used to do small engineering calculations like this frisbee program. Anything bigger, split between different worksheets and managing your equations becomes hell.

    This should be priority in Mathcad Prime 3 so it can be used in very large/complex calculations and simulations.

    1. Jakov Kucan says:

      Sure, Java is a powerful programming language and can do a lot more than Mathcad when you _need_ to program. However, when solving a system of ODE’s, Mathcad is a better tool. Choose the right tool for the job.

      1. John Sheehan says:

        Mathcad being able to solve the actual diffeq rather than a programing solution which is a linear approximation ic clearly a better math solution

      2. John Sheehan says:

        Mathcad being able to solve the original diifeq is cleaely better than Java solving a linear approximation.

  2. myschizobuddy says:

    you should add robust ability for mathcad to reference different worksheets (current implementation is very basic). Combine worksheets into a workbook. Show me a tree of which worksheet depends on which worksheet (like a class diagram).

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s