Distance between two points on the curve

Solve the following problems using your quadratic class. Feel free to create new methods for your class if needed.
Notes and Code Outcome

Distance between points on the line.

Find the straight line distance between the points on the line when:
  • x = -6
  • x = 2
For the quadratic function: $$ f(x) = 0.5 x^2 + 3 x - 5 $$

Output

Fig 1. Graph showing the line connecting the points on the function y = 0.5 x² + 3x - 5 where x = -6 and x = 2

            for x = -6: point 1 = <-6, -5, 0>
            for x = 2: point 2 = <2, 3, 0>
            Distance between point 1 and 2: 11.313708498984761
          

Slope between two points on the line.

Find the slope of the line that connects two points on the curve when
  • x = 1
  • x = 2
For the quadratic function: $$ f(x) = 0.5 x^2 + x - 3 $$

Part B Complete the table below and answer the question: What happens as we bring the two points closer together (what is the limit as dx goes to zero).
x1 x2slope
12
1.52
1.752
1.92

Output

Fig 1. Graph showing the line connecting the points on the function y = 0.5 x² + x - 3 where x = 1 and x = 2

            for x = 1: point 1 = <1, -1.5, 0>
            for x = 2: point 2 = <2, 1, 0>

            Slope between x = 1 and 2 is: 2.5
          

Find the Slope of a Tangent of a Quadratic (Numerically)

Any point along a continuous curve has a slope. You can find an approximation of the slope by taking two points very close together along the curve and using the equation: $$ \text{slope} = m = \frac{y_2-y_1}{x_2-x_1} $$ The closer the points are together the better the approximation of the tangential slope, in general. However, you can get too close when you go beyond the precision of the computer, and your results will be inaccurate.

Write a program that determines the slope of the tangent to a quadratic for any given value of x.

Test using the quadratic function: $$ f(x) = x^2 $$

Complete the table below.

x slope
-2
-1
0
1
2
3

Output

Show Notes ▼