I am trying to write a problem that asks for the particular solution to a non-homogeneous DE like:

y''-8y'+16y=g(x)

In my pg file, I define the solution (e.g. $yp = Formula("e^(4x)")) and use the derivative functionality of the formula package to generate g(x) like so

$dyp = $yp->D('x');

$ddyp = $dyp->D('x');

$g = Formula("$ddyp-8*$dyp+16*$yp")->reduce;

Everything works, however, g(x) is displayed to the students as

16e

^{-4x }ln(e) ln(e) + 8*4e^{-4x }ln(e)+16e^{-4x}Is it possible to code the problem so that this expression would be displayed to the students in its simplified form of

64e

^{-4x}^{}

^{Note: I know that, in this case, I can get the coefficient by evaluating g at x=0, but I was hoping to find a general way to simplify g for any predefined yp.}

Any help would be much appreciated!

Geoff