Waldek Hebisch
unread,Jan 23, 2019, 9:49:30 AM1/23/19Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to fricas...@googlegroups.com
ATM formal derivatives can give wrong InputForm:
(3) -> f := operator 'f
(3) f
Type: BasicOperator
(4) -> di2 := D(f(x, y^2), [x, y], [2, 1])
2
(4) 2yf (x,y )
,1,1,2
Type: Expression(Integer)
(5) -> di2::InputForm
(5)
(* (* 2 y)
(D (D (D (f x (^ y 2)) (:: x Symbol)) (:: x Symbol)) (:: (^ y 2) Symbol)))
Type: InputForm
(6) -> unparse(di2::InputForm)
(6) "2*y*D(D(D(f(x,y^2),x::Symbol),x::Symbol),(y^2)::Symbol)"
Type: String
That is we are trying to differentiate with respect to something
which is not a symbol. I have a patch that fixes this. But
test showed that patch breaks assumption that some people make
that given expression have unique InputForm. Namely, to get
correct value we need to differentiate with respect to a dummy
variable and than substitute argument in place of dummy.
To avoid accidental clashes we need to introduce fresh dummy
each time we create InputForm. That is computing InputForm
second time gives new dummy. This is a drawback, but I see
no other way to get correct InputForm. In the patch I
introduce dummy only when argument is not a symbol (that
is when old code would produce wrong value). In principle
we could avoid dummies in some other cases, but correct
coditions seem to be complicated and it is not clear if
gain justifies effort.
Anyway, patch in attachement. I am going to apply it
unless sombody thinks that it will break something
important.
--
Waldek Hebisch