1
$\begingroup$

I'm making a sort of symbolic derivator, which needs to take its formulas in unevaluated form.

SetAttributes[derDer, HoldAll]
...
derDer[Plus[a_, b_], aux_] := Plus[ derDer[a, aux] , derDer[b, aux] ]
derDer[Times[a_, b_], aux_] := Plus[ Times[a, derDer[b, aux]], Times[derDer[a, aux] , b] ]
derDer[a_, aux_] := Condition[derDer[Evaluate[a], aux], Hold[a] != Hold[Evaluate[a]]]

The last line doesn't work well. I want the expression to see if its first (held) argument is equal to its own evaluation, and if it isn't so, run itself again with the evaluated argument. I don't understand how Hold , Eval and HoldAll work well enough to do this.

$\endgroup$
1
$\begingroup$

I've solved the problem by replacing the last expression with

derDer[a_, aux_] := Condition[derDer[Evaluate[a], aux], Not[Hold[a] === Hold[Evaluate[a]]]]

The problem was == returning unevaluated cases.

Related question.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.