Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 48

Sage Assignment 2

Complete the following two problems (in this file) by Wednesday, 3/16, 11:59pm. (I recommend finishing it before Spring Break.)

Problem 1: Plot f(x)=3cos2(x)cos(x)+1f(x) = 3\cos^2(x) - \cos(x) + 1 together with the tangent line to the function at the point x=2x = 2 in one graph. Make the function and the tangent line different colors. So long as both graphs are clearly visible, you may choose whatever colors you like. Choose a suitable range of xx values for your graph.

Hint and Warning: Sage does not understand the notation cos2(x)\cos^2(x) like we do! Notice that entering cos^2(pi) (for example) produces an error message. As the mathematician operating Sage, it is up to you to know what cos2(x)\cos^2(x) above means, and enter the appropriate expression into Sage. (See you professor or a tutor if you are stuck.)

For ease, we will let sage compute the neccessary derivative and evaluate at the point x=2x=2 to get the slope:

var("x") f(x) = 3*cos(x)^2 - cos(x) + 1 fp = diff(f, x) m = fp(2) y0 = f(2) plot(f(x), (x, 0, 4)) + plot(y0 + m*(x-2), (x, 0, 4), color="green")
x
︠0dd3d1a1-c0f8-49d1-89bd-e29eb574659fi︠ %md **Problem 2:** For the function \[ f(x) = x^5 - 3 x^4 + x - 2 \] on the interval $[-1, 2]$, do the following: - Find all critical points of the function. State the (approximate) location of all critical points. - Find the value of the function at all critical points, and at the endpoints of the interval. - State clearly the (absolute) maximum value and the (absolute) minimum value of the function on the interval, and the x-values where these occur. You should use the Sage command `find_root` to numerically solve equations that would otherwise be too difficult to solve. In addition to appropriate Sage commands, be sure to insert some markdown cells with your text explanations. Remember that you start a markdown cell with `%md`, then on the next line, you can type your response, and then hit `[shift]-[return]`. **Hint:** You may find this problem easier if you refer to a graph, both for helping you see what is going on, and for finding an appropriate interval to use `find_root` on. Don't neglect the graphs! (But the graph is not a substitute for performing the rest of the problem.)

Problem 2: For the function [ f(x) = x^5 - 3 x^4 + x - 2 ] on the interval [1,2][-1, 2], do the following:

  • Find all critical points of the function. State the (approximate) location of all critical points.

  • Find the value of the function at all critical points, and at the endpoints of the interval.

  • State clearly the (absolute) maximum value and the (absolute) minimum value of the function on the interval, and the x-values where these occur.

You should use the Sage command find_root to numerically solve equations that would otherwise be too difficult to solve.

In addition to appropriate Sage commands, be sure to insert some markdown cells with your text explanations. Remember that you start a markdown cell with %md, then on the next line, you can type your response, and then hit [shift]-[return].

Hint: You may find this problem easier if you refer to a graph, both for helping you see what is going on, and for finding an appropriate interval to use find_root on. Don't neglect the graphs! (But the graph is not a substitute for performing the rest of the problem.)

Let's define the function and derivative, then plot the function and the derivative on [1,2][-1, 2]. For ease of recognition, I'll plot the derivative in red:

var("x") f(x) = x^5 - 3*x^4 + x-2 fp = diff(f, x) plot(f(x), (x, -1, 2)) + plot(fp(x), (x, -1, 2), color = "red")
x

There appears to be a critical point near x=0.5x= 0.5, so use find_root to locate it, and call that point x0 :

︠815b730c-e20c-44a5-8e1b-88d6dfc0bd22︠ x0 = find_root(fp(x), 0, 1) x0
0.469677835678729

Now test f at the end points and critical points:

f(-1) f(x0) f(2)
-7 -1.653455624597961 -16

The maximum appears to be about 1.653-1.653 (at x0.4696x \approx 0.4696) and the minimum is 16-16 (at x=2x = 2).