F. Advanced: Building a Roller Coaster using Cubic Polynomials
In this Maple worksheet, we build a roller coaster using n peak and valley points. Our approach is to determine (n-1) cubic polynomials that connect these points and then to calculate the angle of steepest descent/ascent of each hill and resulting thrill factor for the coaster..
I. Getting Started
We clear all variables. To avoid multiple solutions, we set the maximum number of solutions variable equal to 1.
> | restart: |
> | _MaxSols:=1: |
II. Data Points
We enter the number of peak and valley points (n) and the x coordinates (xdata), y coordinates (ydata) and slope conditions (slopes) for these points.
In this example, the first peak is at (0,75) then a vally at (50,0), then another peak at (100,50) and the last valley is at (200,0).
In your work, you should use the collected peak and valley data points for Greyhound (The Devil, Steel Dragon II).
> | n:=4: |
> | xdata:=[0,50,100,200]: |
> | ydata:=[75,0,50,0]: |
> | slopes:=[0,0,0,0]: |
III. Connecting Cubic Polynomials
In this example, we have 4 peak and valley data points. So we must determine 3 connecting cubic polynomials. We do this by simply repeating the approach taken in part C) three times. .
We determine cubic polynomials of the form f(x) = that connect consecutive peak and valley points. Note that n peak and valley points will determine (n-1) hill pieces. The "do" loop below is a generalization of the technique for determining one hill (from a previous Maple worksheet)
> | for i from 1 to (n-1) do |
> | f:=x->a[i]*x^3+b[i]*x^2+c[i]*x+d[i]: |
> | fp:=D(f): |
> | s[i]:=fsolve({f(xdata[i])=ydata[i],fp(xdata[i])=slopes[i],f(xdata[i+1])=ydata[i+1],fp(xdata[i+1])=slopes[i+1]},{a[i],b[i]=Pi/(xdata[i+1]-xdata[i]),c[i],d[i]}): |
> | assign(s[i]): |
> | f:=x->a[i]*x^3+b[i]*x^2+c[i]*x+d[i]: |
> | tplot[i]:=plot(f(x),x=xdata[i]..xdata[i+1]): |
> | od: |
And, we display the (n-1) hill pieces.
> | with(plots): |
Warning, the name changecoords has been redefined
> | display(tplot[k] $k=1..(n-1)); |
The coaster plot looks good. It matches the peak and valley points.
IV. Calculation of Angle of Steepest Descent/Ascent
We need to determine the angles of steepest ascent/descent. We use what we learned from part VI of module C. That is, for these functions the x-coordinate of the point of steepest ascent/descent is the x-coordinate of the midpoint between the peak and valley points.
> | for i from 1 to (n-1) do |
> | f[i]:=x->a[i]*x^3+b[i]*x^2+c[i]*x+d[i]: |
> | fp[i]:=D(f[i]): |
> | mdpt[i]:=.5*xdata[i]+.5*xdata[i+1]; |
> | slope[i]:=abs(fp[i](mdpt[i])); |
> | rangle[i]:=arctan(slope[i]): |
> | dangle[i]:=evalf(rangle[i]*180/Pi): |
> | od: |
The angles of steepest descent/ascent or shown (in order) below.
> | print(dangle[k] $k=1..(n-1)); |
V. Safety Restrictions and Thrill Factor
Safety Criteria
For this coaster, the maximum angle of steepest descent/ascent is given by
> | maxhill:=max(dangle[k] $k=1..(n-1)); |
which is less than 80 degrees and so the coaster is SAFE.
We display a more complete picture of the coaster below. Numbers indicate degree measures of the angles of steepest descent/ascent.
> |
> | warning:="SAFE": |
> | for i from 1 to (n-1) do |
> | if dangle[i] > 80 then warning:="NOT SAFE" end if; |
> | infoplot[i]:=textplot([mdpt[i],f[i](mdpt[i]),round(dangle[i])]); |
> | od: |
> | wplot:=textplot([40,70,warning]): |
> | display(wplot,infoplot[k] $k=1..(n-1), tplot[j] $j=1..(n-1),scaling=constrained); |
Thrill Factor
Now we calculate the thrill of each drop (not of each hill) and the thrill of the coaster
> | thrill:=0.0: |
> | for i from 1 by 2 to (n-1) do |
> | thrill:=thrill+rangle[i]*(ydata[i]-ydata[i+1]); |
> | od: |
And the total thrill is
> | print(thrill); |
> |
VI. Coaster Design
Now, the FUN part...
A. Design your own cubic polynomial coaster by modifying the Maple code given above. Your design should be creative, interesting, and as thrilling as possible.
B. Can you design a cubic polynomial coaster with maximum thrill factor?