% Funzioni anonime per f, derivata prima e seconda f = @(x) exp(-x) .* ( x.^2 + x + 1 ) ; df = @(x) exp(-x) .* ( -x.^2 + x ) ; ddf = @(x) exp(-x) .* ( x.^2 - 3*x + 1 ) ; cell_df = { f , df , ddf } ; % Plot f ab = [-1 7] ; x = linspace(ab(1), ab(2), 1000 ) ; plot( x , f(x) , 'k' , 'LineWidth' , 1 ) ; % return hold on ; % Plot tratteggiato parti estreme del grafico x_sx = linspace(ab(1)-.1, ab(1) , 100 ) ; x_dx = linspace(ab(2) , ab(2)+2 , 100 ) ; plot( x_sx , f(x_sx) , '--k' , 'LineWidth' , 1 ) ; plot( x_dx , f(x_dx) , '--k' , 'LineWidth' , 1 ) ; % Zeri derivata prima (estremi) zeri_df = zeri_completi( df , ab ) ; plot( zeri_df , f(zeri_df) , 'xr' ) ; % Plot serie taylor nei punti di estremo x_plot = linspace(-.5, .5, 100) ; for x0 = zeri_df x = x0 + x_plot ; y = serie_Taylor(cell_df, x, x0) ; plot( x , y , 'r' ) ; % plot con linea rossa end % Zeri derivata seconda (flessi) zeri_ddf = zeri_completi( ddf , ab ) ; plot( zeri_ddf , f(zeri_ddf) , 'ob' ) ; % Plot serie taylor nei punti di flesso x_plot = linspace(-1, 1, 100) ; for x0 = zeri_ddf x = x0 + x_plot ; y = serie_Taylor(cell_df, x, x0) ; plot( x , y , 'b' ) ; % plot con linea blu end % Limiti a +-Infinito f_sx = limite( f , ab(1) , -1 , 1e-8 , false ) ; f_dx = limite( f , ab(1) , 1 , 1e-8 , false ) ; % Abbellimenti grafici xlabel( '$x$' , 'Interpreter' , 'latex') ; ylabel( '$y$' , 'Interpreter' , 'latex') ; title( '$f(x)=e^{-x}(x^2+x+1)$' , 'Interpreter' , 'latex') ; assi = gca ; assi.TickLabelInterpreter = 'latex' ; assi.FontSize = 15 ; grid on ; exportgraphics( assi , 'plot.pdf' ) ;