Miniproject : The Mean value Theorem;

Name : Jin You
E-mail: puretomato@gmail.com

Have you heard about Mean Value Theorem?
In calculus, the mean value theorem means given a section of a differentiable curve, there is a point between two points that represent average value of the two points. Then, the slope of the curve of the point is same as the slope of the line that connects the two points.

Create Function
First, I needed to create a differentiable and continuous function. I created a third degree polynomial function, y = (x + 2) (x - 1) (x - 3) . This fuction should be  differentiable and continuous to not allow the average point between the two points disappear. In fact, the function is differentiable and continuous as you can see in the graph below. I made two different fuctions f(x), and f'(x) with a different style of plot. The gray line represents f(x), and the dash-line represents f'(x). (The graph shows f(x), and f'(x) is also continuous and differentiable, Since f'(x) exist.)

f[x_]:=(x+2)(x-1)(x-3)

f'[x]

Plot[{f[x],f'[x]},{x,-5,7}, PlotRange->{-10,15},
PlotStyle->{GrayLevel[0],Dashing[{.015}]}]

After I created a fuctions, I needed two points on the curves. I call the two points 'a' and 'b'. These two points are defind (a, f(a)), (b,f(b)), and 'a' and 'b' are located on the same line, and the two points exist at each end of the line. Additionaly, I need a point 'c' that resides between 'a' and 'b'.

a=-2;

a=-2;
Point[{a,f[a]}];
Point[{b,f[b]}];
Manipulate[Graphics[Point[{b,f[b]}]],{b,-2.1,3.0}];
Point[{c,f[c]}/.First[Solve[f'[x]==((f[-2]-f[b])/(-2-b)),x]]];
Manipulate[First[Solve[f'[c]==((f[-2]-f[b])/(-2-b)),c]]
,{b,-2.1,6.0}]

We can easily see 'c' is moving as 'b' moves on last part of manipulate. A slope of 'c' value is f'(c), and it is defind as f'(c)= ((f(a)-f(b))/(a-b)) when there are two points on given function (a, f(a)), (b, f(b)). I checked every single part of the work of 'a' 'b' and 'c' by manipulate, and I got tons of results. However, I decided not to put the results here, because it will only create confusion. So far, we set up points 'a', 'b', and 'c.'

a=-2;

Manipulate[Show[
Plot[f[x],{x,-2,3},PlotRange->{-5,10}],
Graphics[Line[{{-2,f[-2]},{b,f[b]}}]],
Graphics[Point[{b,f[b]}]],
Graphics[Point[{a,f[a]}]],
Graphics[Point[{c,f[c]}/.First[Solve[f'[c]==((f[-2]-f[b])/(-2-b)),c]]]],
Graphics[Point[{c,f[c]}/.Last[Solve[f'[c]==((f[-2]-f[b])/(-2-b)),c]]]]
],{b,-2.1,3.0}]

(*:( -> This is Not exactly she want to do*)

This is what I have done up to now, but the point 'c' is kind of hard to see. Moreover, we can't clearly see that a slope of 'c' is changing as the line that conncets 'a' and 'b' changes. So, I want to create tangent line to see a slope of the 'c' clearly.

Needed Tangent line.
-How to draw tangent line?
 A: LT means line of tangent, we need to make it as a function. When we create a function, we need to be careful, because both x,c are variable. (we need to decide intervals of x and c separately to avoid error)
-Need a formula to find a slope of a point? 
 A: Yes. Each slope of a point has its own formula. (it's in the text book:))
-How to determine 'c' range.
 A: 'c' has to be between 'a' and 'b' thus 'c' range is also between 'b' and 'c' easy!!!

LT[x_,c_]:=f[c]+f'[c](x-c)
Manipulate[Plot[{f[x],LT[x,c]},{x,-5,7}, PlotRange->{-5,15}],{c,-2.1,3.0}]

Let's Draw the Grpagh!!!!!!!
-Does she know how to draw the tangent line?
-Yes, she does.

Manipulate[
If[d≠b,
Show[
Plot[f[x],{x,-2.5,3},AxesLabel->"f[x]=(x+2)(x-1)(x-3)",PlotRange->{-10,10},PlotStyle->{Thick,Blue}],(*Plot orioginal fuction*)
Graphics[Point[{d,f[d]}]], (* To display the point (a,f(a) *)
Graphics[Text[Style[{"a=",d},Medium,Italic,Orange],{d,f[d]}]], (*To display the 'a' vlues as a text *)
Graphics[Point[{b,f[b]}]], (* To display the point (b,f(b)) *)
Graphics[Text[Style[{"b=",b},Medium,Italic,Orange],{b,f[b]}]], (*To display the 'b' values as a text*)
Graphics[{Thick,Green,Dashed,Line[{{d,f[d]},{b,f[b]}}]}],(*To display line between point 'a' and 'b'*)
Graphics[Point[{c,f[c]}]/.First[Solve[f'[ c]==((f[d]-f[b])/(d-b)),c]]],(*To display the point (c,f(c))*)
Graphics[Text[Style[{"c=",c},Medium,Bold,Red],{c, f[c]}]/.First[Solve[f'[ c]==((f[d]-f[b])/(d-b)),c]]],(*To display 'c' values in given formular*)
Plot[LT[x,c]/.First[Solve[f'[c]==((f[d]-f[b])/(d-b)),c]],{x,-2,3},PlotRange->{-10,10},PlotStyle->{Thick,Pink,Dashed}],(*To display the tangent line*)
Graphics[Point[{e,f[e]}]/.Last[Solve[f'[ e]==((f[d]-f[b])/(d-b)),e]]],(*To display another point (c,f(c))*)
Graphics[Text[Style[{"d=",e},Medium,Bold,Red],{e, f[e]}]/.Last[Solve[f'[e]==((f[d]-f[b])/(d-b)),e]]],(*Change plotstyle*)
Plot[LT[x,e]/.Last[Solve[f'[e]==((f[d]-f[b])/(d-b)),e]],{x,-2,3},PlotRange->{-10,10},PlotStyle->{Thick,Pink,Dashed}](*To display the tangent line*)
],
"Error! a=b!"],(*To show the error message when a=b*)
{{d,-2,"a"},-2,3},{{b,2.5},-2,3},ControlPlacement->Left](*Make Manipulate Controlplacement to the Left.*)

?Circle

Manipulate[Rotate[Graphics[Text[Style["End",Large,Bold,Red],{0,0}]],theta],{theta,0,2Pi}]