script that will calculate: roots, intercept on y axis, maxima and minima, the indefinite integral and the definite integral between -3 & 3. for g(t)=2t^2-3t-5 and f(x)=x^3-7x+6 in matlab
main.m
% define g(t) functiong_t = @(t) 2*t.^2 - 3*t - 5;
% define f(x) functionf_x = @(x) x.^3 - 7*x + 6;
% calculate roots of g(t)roots_g_t = roots([2, -3, -5]);
% calculate intercept of g(t) on y-axisintercept_g_t = g_t(0);
% calculate maxima and minima of g(t)% first derivative of g(t)g_t_prime = @(t) 4*t - 3;
% critical points of g(t)critical_points_g_t = roots([4, -3]);
% second derivative of g(t)g_t_second = @(t) 4;
% calculate maxima and minima based on second derivativeif g_t_second(critical_points_g_t(1)) > 0 maxima_g_t = g_t(critical_points_g_t(1));
minima_g_t = g_t(critical_points_g_t(2));
else maxima_g_t = g_t(critical_points_g_t(2));
minima_g_t = g_t(critical_points_g_t(1));
end% calculate indefinite integral of f(x)indefinite_integral_f_x = @(x) 0.25*x.^4 - 3.5*x.^2 + 6*x + C; % where C is constant of integration% calculate definite integral of f(x) between -3 and 3definite_integral_f_x = integral(f_x, -3, 3);
967 chars
34 lines
Note: The values of roots_g_t, intercept_g_t, maxima_g_t, minima_g_t, indefinite_integral_f_x and definite_integral_f_x can be displayed on the command window using disp() function.