# Tema 8
08-2 Teoremas del valor medio

## Teorema de Rolle

kill(all)$

f(x):=6-(x+1)*(x-2)^2;

wxplot2d([f(x)], [x,0,3] , [y,0,9], [ylabel, ""] , [legend, "f(x)"] , [style, [lines, 2]] ,
[gnuplot_preamble, "set grid"] , [nticks, 200] )$

define (Df(x) , diff(f(x), x) );

Eq1: Df(x) = 0;       solve(Eq1, x);

kill(all)$

f(x):=1+abs(x^2 - 2*x - 8);

wxplot2d([f(x)], [x,1+sqrt(2), 5], [y,0,10], [ylabel, ""] , [legend, "f(x)"] , [style, [lines, 2]] , 
[gnuplot_preamble, "set grid"] , [nticks, 200] )$

f(1+sqrt(2)), numer;      f(5), numer;

define (Df(x) , diff(f(x), x) );

solve(Df(x)=0, x);

assume(x>1+sqrt(2), x<4)$    
is(Df(x) < 0);

forget(x>1+sqrt(2), x<4)$    
assume(x>4, x<6)$     is(Df(x) > 0);

## Teorema del valor medio

kill(all)$

f(x):=(x-1)*(x-2)*(x-3);

y - f(0) = (f(5)-f(0)) / (5-0) *(x-0);

define (y(x), 6*x - 6);

wxplot2d([f(x),y(x)], [x,0,5], [y,-10, 30], [ylabel, ""] , [legend, "f(x)" , "y(x)"] , [style, [lines, 2]] ,  
[gnuplot_preamble, "set grid"] , [nticks, 200] )$

define ( Df(x) , diff(f(x),x) );

fpprintprec : 6$

Eq1: Df(x) = 6;     solve([Eq1], [x]), numer;

x1 = x1:0.4725;   
x2 = x2:3.52753;

'f(x1) = f(x1), numer;      
'f(x2) = f(x2), numer;

y2(x):=6*(x - x1) + f(x1);      
y3(x):=6*(x - x2) + f(x2);

wxplot2d([f(x), y2(x), y3(x)], [x,0,5], [y,-10, 40],  [legend, "f(x)" ,  "y2(x)", "y3(x)"] , [style, [lines, 2]] ,   
[gnuplot_preamble, "set grid"] , [nticks, 200] )$