ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 11 Mar 2019 10:15:59 -0500Evaluating a derivative of an unknown functionhttp://ask.sagemath.org/question/45758/evaluating-a-derivative-of-an-unknown-function/I need to evaluate the derivative of a certain unknown function, but instead of doing this what I get is the expression with a change in the name of the variable.
My example
z,l = var('z,l')
g = function('g', nargs=1)(z)
g_prime = g.derivative(z)(z)
g_prime(l)
So the output for that code is \frac{\partial}{\partial l} g (l) .
Instead, I would like \frac{\partial}{\partial z} g(l)Luis EscuderoMon, 11 Mar 2019 10:15:59 -0500http://ask.sagemath.org/question/45758/Lazy evaluation of derivatives of an unknown functionhttp://ask.sagemath.org/question/10215/lazy-evaluation-of-derivatives-of-an-unknown-function/Hi,
I am using Sage to check some solutions to partial differential equations. I am wondering if a have an unknown function f, can I somehow form the PDE in terms of its derivatives and then substitute in the assumed solution and evaluate the derivatives after the fact?
Here is what I tried so far:
var('x y')
f = function('f', x, y)
g = derivative(f, x, y)
print(g)
D[0, 1](f)(x, y)
h = D[0, 1](f)(x, y)
print(h)
Traceback (click to the left of this block for traceback)
...
TypeError: 'sage.symbolic.expression.Expression' object has no
attribute '__getitem__'
I figured out that D[0, 1] represents the derivatives with respect to the ith indepent variable of the function (is this a Maxima expression?), but I'm not sure then how to use these types of expressions when I finally want to substitute in the known form of f. I.e., since the output of the expression for g is in terms of D[], and when I try to reuse that expression as h, I get an error (since D is actually some other type of object). Any help would be appreciated. Let me know if my question is not clear.
Many thanks!nosnerosMon, 10 Jun 2013 05:27:40 -0500http://ask.sagemath.org/question/10215/