# HG changeset patch
# User Burcin Erocal <burcin@erocal.org>
# Date 1274956635 -7200
# Node ID d3bb1a7a0ac49eccad3ea4053f938a3518c403ed
# Parent f32a14699e32bb046acd4c1789e0d83d4b0c8a17
trac 8568: fix conversion of derivatives to maxima.
Corresponding method sage.symbolic.expression_conversions.InterfaceInit.diff()
was calling "args()" on an expression to fetch the operands. Changing this to
operands() fixes the problem.
diff --git a/sage/symbolic/expression_conversions.py b/sage/symbolic/expression_conversions.py
a
|
b
|
|
463 | 463 | """ |
464 | 464 | EXAMPLES:: |
465 | 465 | |
466 | | sage: import operator |
467 | 466 | sage: from sage.symbolic.expression_conversions import InterfaceInit |
468 | 467 | sage: m = InterfaceInit(maxima) |
469 | | sage: a = function('f', x).diff(x); a |
| 468 | sage: f = function('f') |
| 469 | sage: a = f(x).diff(x); a |
470 | 470 | D[0](f)(x) |
471 | 471 | sage: print m.derivative(a, a.operator()) |
472 | 472 | diff('f(x), x, 1) |
473 | | sage: b = function('f', x).diff(x).diff(x) |
| 473 | sage: b = f(x).diff(x, x) |
474 | 474 | sage: print m.derivative(b, b.operator()) |
475 | 475 | diff('f(x), x, 2) |
| 476 | |
| 477 | We can only convert to Maxima derivatives if the corresponding operand |
| 478 | of the function is a variable:: |
| 479 | |
| 480 | sage: y = var('y') |
| 481 | sage: t = f(x*y).diff(x) |
| 482 | sage: m.derivative(t, t.operator()) |
| 483 | Traceback (most recent call last): |
| 484 | ... |
| 485 | NotImplementedError: arguments must be distinct variables |
| 486 | |
| 487 | TESTS:: |
| 488 | |
| 489 | Check if #8568 is fixed:: |
| 490 | |
| 491 | sage: var('c,x') |
| 492 | (c, x) |
| 493 | sage: erf(c*x).diff(x)._maxima_init_() |
| 494 | Traceback (most recent call last): |
| 495 | ... |
| 496 | NotImplementedError: arguments must be distinct variables |
476 | 497 | """ |
477 | 498 | #This code should probably be moved into the interface |
478 | 499 | #object in a nice way. |
479 | 500 | from sage.symbolic.ring import is_SymbolicVariable |
480 | 501 | if self.name_init != "_maxima_init_": |
481 | 502 | raise NotImplementedError |
482 | | args = ex.args() |
| 503 | args = ex.operands() |
483 | 504 | if (not all(is_SymbolicVariable(v) for v in args) or |
484 | 505 | len(args) != len(set(args))): |
485 | 506 | raise NotImplementedError, "arguments must be distinct variables" |