How to graph y = 3^x − 2x with a horizontal tangent line
2 views (last 30 days)
Show older comments
Renee Norcross
on 28 Feb 2022
Commented: Renee Norcross
on 1 Mar 2022
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
John D'Errico
on 28 Feb 2022
Edited: John D'Errico
on 28 Feb 2022
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?
Accepted Answer
Image Analyst
on 28 Feb 2022
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)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!