The general formula for deriving a power makes use of the logarithm,
which often disappears at simplification. However, replacing the symbol
before simplifying can lead to applying an invalid argument to the
logarithm, making the whole expression invalid.
e.g. diff(1/x,x,-2)
If x is replaced by -2 before reducing the power derivative, ln(-2)
will reduce to Unreal, as will the rest of the expression.
New tests compute derivatives while replacing symbols with their definitions or undefined, as the device does.
Change-Id: I99179bf6540182ff929938fb96a00a1ed2fbcf49
Derivation now computes as expected on logarithms, as long as their base is not a function of the derivation variable.
Change-Id: Ia56da1c1151c0ddf3887be84ddb4bd02664c5188
Added a method unaryFunctionDifferential to ExpressionNode and Expression, to be implemented by subclasses representing unary functions.
Added a function derivateUnaryFunction to Derivative, to factor (f°g)' -> g' * f'°g.
Change-Id: Id1780f1082ccd001f1282fe4ddfff2b7055d3a27
Derivation now propagates to powers as expected, whether the base, the exponent, or both are functions of the variable. This also makes division derive as intended.
Change-Id: I51cbd5f7ec9f6aaa1df068625bbda1437941fa08
Derivation propagates as expected on multiplications (but not power). Some tests involving diff had to be updated to reflect that behaviour.
Change-Id: Ifa32031bc37a156c18d296757bcdd6ccdb0ea43e
Number's subclasses, with the exception of Undefined and Unreal, derive as zero. Symbols derive as expected. Derivation propagates as expected on additions.
Change-Id: Icedbb1dfac8099347a19c14bf2537011b2e8b199
This method is to be implemented by derivable expression subclasses, for use in Derivative::shallowReduce. It performs the calculation for the derivative, and returns whether calculations happened.
Change-Id: I13cdb131e2044578392f5178a9f389314c1c4c8a