## #1197 gradef for variables: not used in diff

closed
nobody
5
2010-05-11
2007-05-22
Anonymous
No

Consider the following:

(%i14) diff(Vb);
(%o14) Sb del(R)
(%i15) diff(3*Vb);
(%o15) 3 del(Vb)

Instead of %o15 I would have expected 3*Sb*del(R).

In functional notation showing the dependency on R, things
seem to work:

(%i22) diff(Va(R));
(%o22) Sa del(R)
(%i23) diff(3*Va(R));
(%o23) 3 Sa del(R)

This behavior may be related to the fact that

On the mailing list, Robert Dodier mentioned the following:

This behavior seems to be intentional, but certainly is confusing.
The available documentation for gradef (probably derived from
the union of old documentation and what could be puzzled out
gradef(F, x, ...) although the intended effect of this distinction
is obscure.

Certainly the two cases are treated differently by the code.

=> Va(R)
:lisp (symbol-plist '|\$Va|)
=> Vb
:lisp (symbol-plist '|\$Vb|)
=> (MPROPS (NIL DEPENDS (\$r) \$ATOMGRAD ((\$r . \$Sa))))
=> [Va(R)]

An easy fix would be to cause the two forms of gradef to
assign the same properties. But I don't know what else
that would break.

## Discussion

• Robert Dodier
2007-07-03

• labels: --> Lisp Core

• Dieter Kaiser
2010-05-11

Again the problem which is a bit reformulated:

(%i1) depends(f,[x,y])\$

This is the correct total differential:

(%i2) diff(f);
(%o2) 'diff(f,y,1)*del(y)+'diff(f,x,1)*del(x)

But it does not work when we have an expression with the symbol f:

(%i3) diff(3*f);
(%o3) 3*del(f)

(%i4) diff(a*f);
(%o4) a*del(f)+f*del(a)

The problem is in the routine extractvars, which is called from the routine stotaldiff. This routine only collects the variables of the expression we have passed to the routine stotaldiff, but does not take into account the dependencies. This can be corrected and we get the expected results:

(%i6) diff(3*f);
(%o6) 3*'diff(f,y,1)*del(y)+3*'diff(f,x,1)*del(x)

(%i7) diff(a*f);
(%o7) a*'diff(f,y,1)*del(y)+a*'diff(f,x,1)*del(x)+f*del(a)

Dieter Kaiser

• Dieter Kaiser
2010-05-11

This bug has been fixed in the routine extracvars in the file comm2.lisp revision 1.34.
Closing this bug report as fixed.
Dieter Kaiser

• Dieter Kaiser
2010-05-11

• status: open --> closed