Problems with functions. I have been working on the following problem relating to functions:
"Consider a line $y=kx+b$ ($k<0$, $b>0$) which is tangent to the parabola $y=x^2−4x+4$. 
Find the maximal value of the region bounded by the lines $y=kx+b$, $y=0$ and $x=0$". 
The greatest region I found that followed such restrictions had an area of $2.25$. It was a right triangle with sides $3$ and $1.5$. However, I am uncertain whether this is the greatest value. Can anyone confirm?
 A: The equation of the tangent is:
$$y-(t^2-4t+4)=(2t-4)(x-t)$$
which is rewritten as:
$$y=(2t-4)x+4-t^2$$
From $k<0$ and $b>0$ one gets $-2<t<2$
$x$ and $y$ intercepts are $\frac{t+2}{2}$ and $4-t^2$
So you can maximize the area of triangle which is $f(t)=\frac{xy}{2}=-\frac{1}{4}(t-2)(t+2)^2$
$-2$ and $2$ cannot be maxima, as $f(2)=f(-2)=0$
Equating $f'(t)=0$ one gets $t=2/3$ and $t=-2$
So the maxima is at $t=2/3$, which is $f(2/3)=64/27$
A: Let the parabola be $f(x) = x^2 -4x + 4$.
Let's let the point of the tangent point of the parabola be $(x, y)$
The slope of the tangent line is $k = f'(x) = 2x - 4$.
Given a right triangle made be the lines $y=kx + b$ and $y = 0$ and $x=0$ the base of the triangle will be from $(0,0)$ to the $x$-intercept of the line $y=kx+b$ which is $-\frac bk$ (assuming $k\ne 0$[*]).  The height of the triangle will be from $(0,0)$ to the $y$-intecept of the line $y=kx+b$ which is $b$.
So the Area is $\frac 12 (-\frac bk)b= -\frac {b^2}{2k}$.  (Note a negative value will just mean that the triangle is under the $x$ axis or to the left of the $y$ axis.)
If $(x,y)$ is the point of tangency then $(x,y)$ is on the line and on the parabola so $y = kx + b = x^2 -4x + 4 = (x-2)^2$.
The slope of the tangent line is $y' = k = 2x -4 = 2(x-2)$.
Thus $y = 2(x-2)x + b = (x-2)^2$ and we get $b = (x-2)^2 - 2(x-2)x = (x-2)(x-2 - 2x)= -(x-2)(x+2)$ or if you prefer the long way: $y = 2x^2-4x + b = x^2 -4x + 4$ so $b=-x^2 +4$.
So  for that tangent point we have the area of the triangle is:
$A(x) = -\frac {b^2}{2k} = -\frac {(x-2)^2(x+2)^2}{4(x-2)} = -\frac 14(x-2)(x+2)^2$.
([*] Note: that the factor of $x-2$ in the denominator factored out.  At $x = 2$ it's interesting to note that the slope of the tangent line is $0$-- This is the cusp of the parabola.  But it doesn't affect the are area of our triangle as it is a removable singularity.  If the parabola didn't have a cusp at $(x, 0)$ then the "triangle" would be an open "slice" and have infinite area.  As it is at $x=2$ the area is $0$ because the tangent line is $x=0$ and our "triangle" is a line segment.)
To find the max/min of this area set $A'(x) = 0$ and solve.
$A'(x) = -\frac 14[2(x-2)(x+2) + (x+2)^2]=-\frac 14(x+2)[2(x-2) + (x+2)] = -\frac 14(x+2)(3x -2) = 0$
So either $x+2 = 0$ and $x = -2$ or $3x -2 = 0$ and $x =\frac 23$.
$x = -2$ gives as an area of $A(-2)= -\frac 14(x-2)(x+2)^2 = 0$.
(This is is because at $x = -2$ the tangent line $y = kx + b = y = 2(-2-2)x + (-(-2)^2 + 4) = 8x$ passes through the origin and the "triangle" is just a point.  This is a minimum.)
(Worth noting for $x < -2$ the triangle will occur to the left of the $y$-axis and below the $x$ axis for n positive area.[**])
$x = \frac 23$ gives us an area of $A(\frac 23) = -\frac 14(-\frac 43)(\frac 83)^2 = \frac {64}{27}$.
That's the maximum.
([*]It's worth noting that at $x = 2$ we get an area of $A(x) =0$.  If $x = 2$ then $y = 0$ and this is the cusp of the parabola.  This is not a minimum because as $x > 2$ we will have a positive slope and the triangle will be below the $x$-axis and the area will take on negative values.)
([**] Actually there is no global maximum; just a localmaximum at $x = \frac 23$.  The triangles resulting from $x < -2$ will result in increasingly large triangles in the fourth quadrant.  There is probably something in the text that rules out us having triangles in different quadrants than te parabola.  Or maybe you were told $x$ had to be positive.)

I'm embarrassed to admit my not getting $x =2$ as a minimal which I knew had to have area $0$ and not getting why I got the area of $0$ at $x=-2$ instead when it didn't seem to make sense that would have a triangle of $0$ area, took me a long time.  We never outgrow making mistakes.
