Find a cubic function such that `f(x)>=0` if `x<=2` , f(x)<0 for x>2, and f(0)=4:
One way to write a cubic function is f(x)=a(x-p)(x-q)(x-r) where p,q, and r are zeros of the function. Since the function is nonnegative to the left of 2 and negative to the right of 2 we can let 2 be one of the zeros so let p=2.
To have the cubic function falling from left to right we need the leading coefficient to be negative.
Since the function can be greater than or equal to 0 to the left of 2 we can introduce a double root by having q=r.
Also a(-p)(-q)(-r)=4 since f(0)=4. Since p=2 we can let q=r=-1 and a=-2.
So we have f(x)=-2(x-2)(x+1)(x+1) or `f(x)=-2x^3+6x+4`