## WeBWorK Problems

### Simplifying derivatives and suppressing ln(e) in formulas ### Simplifying derivatives and suppressing ln(e) in formulas

by Geoff Cox -
Number of replies: 2
Hello,

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 ### Re: Simplifying derivatives and suppressing ln(e) in formulas

by Davide Cervone -
The MathObject library is not a computer algebra system (CAS), and so it doesn't have very sophisticated reduction rules. It was designed mainly to get rid of things like coefficients of 1 or 0, or to change "a + -b" to "a - b" and other such things that show up when you use randomly generated values in a problem. It was never intended to be a system for general manipulation of formulas.

A reduction rule could be added easily enough for ln(e) (and I will make a pull request for that), but combining like terms is beyond the current capabilities of the MathObjects library.

If you want to be able to do real CAS work, you might want to look into the AskSage module. Others here can tell you more about that than I can. 