The function f is defined by

f(x) = $\displaystyle ax^3 + bx^2$ for $\displaystyle x < 1$

f(x) = $\displaystyle x^2 + x$ for $\displaystyle x \geq 1$

Both f and its derivative are continuous for all values of x. Find the values of the constants a and b.

I find the derivative for both parts as

f'(x) = $\displaystyle 3ax^2 + 2bx$ for $\displaystyle x < 1$

f'(x) = $\displaystyle 2x + 1$ for $\displaystyle x \geq 1$

I know how to find a and b if they are continuous for one particular value for x - the function and the derivative are solved by means of simultaneous equations.

I tried to do this method for this question, but found that I achieved varying answers - I tried x=1, x=2 and this resulted in different values for a and b, so I'm guessing that this question requires something a bit different? How would you attempt to solve this?

Thanks for your help