But how am I supposed to know b and a were constants?

Mathematical convention. In the expression ax, a is the coefficient of x.

BTW, since a is not a function (but a constant), you use the constant multiple rule. That is, (a*f(x))′ = a * f′(x).

Hey, I've got it! That was a tricky bit of algebra.

We have (b-a)e^(bx-ax) = be^bx / ae^ax

Now, (b-a)e^(bx-ax) = (e^bx / e^ax) * (b-a)

and be^bx / ae^ax = (b/a) * (e^bx / e^ax)

Our expression is now (e^bx / e^ax) * (b-a) = (b/a) * (e^bx / e^ax)

Cancel out the e's to get b-a = b/a. Solve for b:

b = ab - a²

a² = ab - b

a² / (ab - b) = 1

a²b / (ab - b) = b

b = a² / (a-1)

The stuff you come up with, I swear...