How to graph y = 3^x − 2x with a horizontal tangent line

Use MATLAB to find all the values of x where the graph of y = 3^x − 2x has a horizontal tangent line. Confirm solution with a plot. I have the correct code and value, I just can not get the correct tangent line to come up on the plot.

3 Comments

DGM
DGM on 28 Feb 2022
Edited: DGM on 28 Feb 2022
What have you come up with so far?
If you have found the value of the function at the critical points, then you should be able to use yline() to create the horizontal line at that y-value.
Please don't post additional information as an answer. That you actually did some work on your problem is good. So learn to use comments. I've deleted your answer, since it was not an answer. Image moved here:
Now to have been more useful, why could you not have just pasted in the actual text? Then if someone wanted to help you, they could have just copied the text directly into MATLAB, instead of having to type in the code you wrote themselves.
Is there a good reason why you want to make it more difficult to get help?
I could not paste into the actual text because I did not have internet access on my laptop at that time. This was my first post here and I did not realize I wasn't responding but instead posting it as an answer. There is no good reason I made it more difficult to get help. It was not done on purpose.

Sign in to comment.

 Accepted Answer

You can plot the tangent line by picking two x endpoints, like -1 and 1 or whatever, then compute the y values there and calling plot(). Let's say you want the tangent at xp = 0 or whatever. Then
xp = some number where you want the tangent line
yp = 3 * xp ^2 - 2 * x; % y value of the curve at the xp location
% Define left and right locations for the endpoints of the tangent line.
x1 = -1;
x2 = 1;
% Point slope formula : (y-yp) = slope * (x-xp), or yp = slope * (x-xp) + yp
% Get the y values of the tangent line at those x locations.
y1 = slope * (x1 - xp) + yp;
y2 = slope * (x2 - xp) + yp;
% Plot the line segment.
plot([x1,x2], [y1,y2], 'r-', 'LineWidth', 2);
grid on;

More Answers (0)

Categories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!