i'm looking create function takes equation , marks maxima and/or minima, , asymptotes on graph.
from calc 1, remember using second derivative test.
i started solving roots of first derivative - not sure how can plot point in vector intersect original equation.
syms x; %// f = sin(x) %// define equation function df=diff(f) %// first derivatives ddf=diff(df) %// second derivatives
i found roots x-values of these points dfroots = solve(df)
and created vector of them called dfroots_realdouble
dfroots_double = double(dfroots); dfroots_realdouble = real(dfroots_double);
dfroots_realdouble
represent x-values need, dont know how plot them points , separate minima maxima, etc
i'd able put in function, sin(6*(x^5) + 7*(x^3)+8*(x^2))
on [-1,1]
, highlight maxima 1 marker, , minima another.
if sort roots, have alternating vector of maximums , minimums. use second derivative determine if vector of roots starts maximum or minimum , split vector.
roots = sort([-3 4 2 -5]); is_max = (subs(ddf, x, roots(1)) < 0) if is_max max_points = roots(1:2:end) min_points = roots(2:2:end) else max_points = roots(2:2:end) min_points = roots(1:2:end) end % plot 2 different symbols plot(max_points, subs(f, x, max_points), 'or',... min_points, subs(f, x, min_points), '*k')
Comments
Post a Comment