Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
calculuslab
GitHub Repository: calculuslab/Calculus_Lab
Path: blob/main/141-Labs/Lab 07 - Project - Mathematical Models, Designing a Roller Coaster.ipynb
700 views
Kernel: SageMath 9.2

Lab 07 - Project - Mathematical Models: Designing a Roller Coaster

Overview

In this lab, we will apply our knowledge of Calculus to solve a real-world problem.

Important SageMath Commands Introduced in this Lab

ParseError: KaTeX parse error: Undefined control sequence: \hfill at position 32: …|l|l|} \hline \̲h̲f̲i̲l̲l̲ ̲\textbf{Command…
Graphs, piecewise-defined functions, and properties of the first derivative.

The Problem: Designing a Roller Coaster

Suppose we are asked to design a simple ascent and drop roller coaster with an overall horizontal displacement of 200 feet. By studying pictures of our favorite roller coasters, we decide that our roller coater should begin the ascent along a line y=f1(x)y = f_1(x) of slope 1.5 for the first 20 ft horizontally. Next, it should continue the ascent and then begin the drop along a parabola y=f2(x)=ax2+bx+cy = f_2(x) = ax^2 + bx + c for the next 100 ft horizontally. Finally, we want it to begin a soft landing at 30 ft above the ground along a cubic y=f3(x)=dx3+ex2+fx+gy = f_3(x) = dx^3 + ex^2 + fx + g for the last 80 ft. The main task is to find {a,b,c,d,e,f,g}\{a,b,c,d,e,f,g\} that will ensure that the track is smooth at each transition point. We also would like to know the maximum height of the roller coaster.

We will begin by creating our functions. If we choose the origin as our starting point, then we know that f1(x)=1.5xf_1(x) = 1.5x since it is a line with slope 1.5 that passes through (0,0).(0,0).

var('a','b','c','d','e','f','g') def f1(x): return 1.5*x def f2(x): return a*x^2 + b*x + c def f3(x): return d*x^3 + e*x^2 + f*x + g

Since our roller coaster consists of three curves, it can be set up as a piecewise-defined function: F(x)={f1(x)0x20f2(x)20<x120f3(x)120<x200.F(x) = \left \{ \begin{array}{ll} f_1(x) & 0 \leq x \leq 20 \\ f_2(x) & 20 < x \leq 120 \\ f_3(x) & 120 < x \leq 200 \end{array} \right. .

Before we create the function F(x)F(x) in SageMath, we need to determine the values of {a,b,c,d,e,f,g}\{a,b,c,d,e,f,g\}. In order for our track to be connected, we need to make sure that F(x)F(x) is continuous. Therefore, we need to make sure that f1(20)=f2(20)f_1(20) = f_2(20) and f2(120)=f3(120)f_2(120) = f_3(120).

eq1 = f1(20) == f2(20) eq2 = f2(120) == f3(120)

In order for our track to be smooth, we cannot have abrupt changes in direction, so the first derivative F(x)F'(x) needs to be continuous. Therefore, we need to guarantee that f1(20)=f2(20)f_1'(20) = f_2'(20) and f2(120)=f3(120).f_2'(120) = f_3'(120).

df1(x) = diff(f1(x),x) df2(x) = diff(f2(x),x) df3(x) = diff(f3(x),x) eq3 = df1(20) == df2(20) eq4 = df2(120) == df3(120)

Since we want our roller coaster to begin a soft landing when it has traveled 120 ft horizonatally and is at a height of 30 ft, we need f3(120)=30.f_3(120) = 30.

eq5 = f3(120) == 30

Finally, in order to have a soft landing, the track should be tangent to the ground at the end of the track.

eq6 = f3(200) == 0 eq7 = df3(200) == 0

We now have a system of 7 equations in 7 unknowns which we can solve using the solve()\textbf{solve}(\cdots) command.

show(solve([eq1, eq2, eq3, eq4, eq5, eq6, eq7], a,b,c,d,e,f,g))

We have found the values for {a,b,c,d,e,f,g}\{a,b,c,d,e,f,g\} so that our roller coaster is smooth at each transition point.

a = -3/200 b = 21/10 c = -6 d = -3/25600 e = 21/320 f = -195/16 g = 750

Now that we have determined the values of {a,b,c,d,e,f,g}\{a,b,c,d,e,f,g\}, we will create F(x)F(x) in SageMath using the piecewise([(domain 1,function 1),])\textbf{piecewise}([(\textit{domain 1}, \textit{function 1}), \dots]) and then plot our roller coaster.

Note: For syntax reasons, SageMath will only except intervals of the form (x1,x2)(x_1,x_2) and [x1,x2][x_1,x_2]. So, in order to specify a function on the domain (x1,x2],(x_1, x_2], we will have to use the interval (x1,x2)(x_1, x_2) and the interval [x2,x2][x_2, x_2], which is simply the set consisting of only the point x2x_2.

F = piecewise([([0,20], f1(x)), ((20,120), f2(x)), ([120, 120], f2(x)), ((120, 200), f3(x)), ([200, 200], f3(x))])

Now that we have created F(x)F(x), we plot it.

plot(F(x), xmin = 0, xmax = 200, ymin = -50, ymax = 100)

We now want to find the maximum height of the roller coaster. Recall that absolute maxima can only occur at endpoints and critical points. We can find the critical points of a piecewise-defined function in SageMath by using the ParseError: KaTeX parse error: Expected 'EOF', got '_' at position 18: …extbf{.critical_̲points()} command.

Caution: The diff()\textbf{diff}() command does not work correctly on piecewise functions in SageMath.

F.critical_points()

It follows that the maximum height of the roller coaster could occur at the xx-values 0,70,5203,0, 70, \frac{520}{3}, and 200200. From the graph, we can see that the maximum occurs at x=70.x = 70.

F(70.0)

Therefore, the maximum height of the roller coaster is 67.5 ft.

Project

Design a larger roller coaster meeting the specifications below and prepare a neat and complete project report as specified by the Project Report Guidelines located on the lab website. The due date will be specified by your TA.

Suppose you are asked to build a roller coaster with an overall horizontal displacement of 600 feet. The coaster should ascend along a straight line y=f1(x)y = f_1(x) of slope 2.5 for the first 30ft horizontally. We continue along three cubics, f2(x)=ax3+bx2+cx+d,f3(x)=ex3+fx2+gx+h,f_2(x) = ax^3 + bx^2 + cx + d,f_3(x) = ex^3 +fx^2 +gx +h, and f4(x)=ix3+jx2+kx+lf_4(x) = ix^3 +jx^2 +kx +l for 150ft each. In addition, the coaster should be 210ft above the ground at the 120ft mark, reach a bottom of 37.5ft above the ground at the 270ft mark, and reach a peak 97.5ft above the ground at the 390ft mark. Finally, the coaster should start a soft landing 45ft above the ground along a cubic f5(x)=mx3+nx2+ox+pf_5(x) = mx^3 + nx^2 + ox + p for the last 120ft.

Your task is to:

  1. Write a system of 16 equations in 16 unknowns such that your track is both continuous and smooth. Make sure to include your equations in your report and you must explain the reasoning for your equations in your report.

  2. Solve the equations in (1) with SageMath to find the values aa-pp.

  3. Define and plot a piecewise-defined function, F(x)F(x), for your roller coaster. Include the equation for your completed piecewise-defined function (with all values aa-pp plugged in) as well as the graph of your roller coaster. Be sure to use the same scalar for both xx and yy.

  4. Find the maximum height of your roller coaster and the mark where it occurred.

Extra Credit

Design a more interesting roller coaster of your own.