The gradient of a curve is \(ax + b\) at all points, where \(a\) and \(b\) are constants. Find the equation of the curve, given that it passes through the points \((0,4)\) and \((1,3)\), and that the tangent at \((1,3)\) is parallel to the line \(y = x\).

Let’s say the equation of the curve is \(y = f(x)\), so \(y' = ax + b\). This means that \[ y= \int ax + b \:dx = \frac{ax^2}{2} + bx + c \] for some constant of integration, \(c\). (This is a consequence of the fundamental theorem of calculus.)

As the curve passes through the point \((0,4)\) we know that \[ \frac{a \times 0^2}{2} + b \times 0 + c = 4 \implies c = 4, \] and as it passes through the point \((1,3)\), we also have that \[ \frac{a \times 1^2}{2} + b \times 1 + c = 3 \implies \frac{a}{2} + b + 4 = 3 \implies a + 2b = -2. \] Now the tangent to the curve at \((1,3)\) is parallel to the line \(y = x\), which has gradient \(1\), so \(a + b = 4\) (since \(y' = ax + b\)).

We therefore have simultaneous equations in \(a\) and \(b\), which are \[\begin{align*} a + 2b &= -2, \\ a + b &= 1. \end{align*}\]Subtracting, we have \(b = -3\), and hence \(a = 4\). The equation of the curve is therefore \(y = 2x^2 - 3x + 4\).