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.Thu, 25 Feb 2016 07:49:39 -0600- Is it possible to define (or assume) the derivative of a functionhttp://ask.sagemath.org/question/32669/is-it-possible-to-define-or-assume-the-derivative-of-a-function/ What i would like to do is define formal symbolic functions
`f1 = function('f1',latex_name = 'f_1')(x)`
and set their derivative or at least be able to substitute their derivative. As an example assume I defined f1,f2,f3,f4 then I would set dx f1 = f2+f3 and what I would expect is
f1.derivative(x)
to output
f2(x)+ f3(x)ywidmeThu, 25 Feb 2016 07:49:39 -0600http://ask.sagemath.org/question/32669/
- Has ticket #6480 been fixed?http://ask.sagemath.org/question/27217/has-ticket-6480-been-fixed/The ticket is:
>.subs_expr() method doesn't work for argument of D derivative operator
Here is an example (from Sage 6.2, which I'm currently using):
var('x,y,f,F,Fx,Fy')
y = function('y',x)
f = function('f',x,y)
d1 = diff(f,x,1)
d1.subs_expr(diff(y,x,1)==F)
F*D[1](f)(x, y(x)) + D[0](f)(x, y(x))
So far, all good. But when I try:
d1.subs_expr(diff(y,x,1)==F,diff(f,x,1)==Fx,diff(f,y,1)==Fy)
I receive the error:
TypeError: argument symb must be a symbol
Maybe my syntax is wrong, so either my question is moot, in which case what am I doing wrong? Or maybe my syntax is correct and the fault is still a ticket for `subs_expr`. Advice as always would be very welcome!AlasdairSat, 27 Jun 2015 19:47:35 -0500http://ask.sagemath.org/question/27217/
- How to substitute a function within derivatives?http://ask.sagemath.org/question/9932/how-to-substitute-a-function-within-derivatives/I want to simplify an ODE by making a substitution, say g(x) -> h(x)*x, but can't get it to work. I tried:
g=function('g', x)
h=function('h', x)
dg = g.diff(x)
dg
sage output: D[0](g)(x)
dg.subs(g==h*x)
sage output: D[0](g)(x)
The substitution is not done for the g function within derivatives. I tried dg.subs(g(x)==h(x)*x) too, got deprecation warnings and the same results. How can I make this work? This is a simplified example, in reality, instead of dg, I have the lhs of an ODE defined interms of g(x).
Thanks
sgiaThu, 21 Mar 2013 17:59:28 -0500http://ask.sagemath.org/question/9932/
- Substitute formal function by an expression in a differential equationhttp://ask.sagemath.org/question/8293/substitute-formal-function-by-an-expression-in-a-differential-equation/This is a follow up to [substitute expression instead of formal function symbol](http://ask.sagemath.org/question/541/substitute-expression-instead-of-formal-function). I tried to no avail to apply the workaround proposed there for the following application where I build a differential equation involving a formal function P:
sage: x,y = var('x,y')
sage: P = function('P',x,y)
sage: z = var('z')
sage: C = function('C',z)
sage: equation = P(x=z,y=C) == 0
sage: dequation = diff(equation, z)
and then I would want to substitute P by a specific expression:
sage: Q(x,y) = y^2 - y + x
sage: dequation.substitute_function(P,Q)
But whatever I tried, I got:
D[0](C)(z)*D[1](P)(z, C(z)) + D[0](P)(z, C(z)) == 0
Is there a natural syntax to achieve this? If not, should this be a ticket?
Thanks!Nicolas M ThiĆ©ryThu, 25 Aug 2011 03:24:25 -0500http://ask.sagemath.org/question/8293/
- substitute expression instead of formal function symbolhttp://ask.sagemath.org/question/8110/substitute-expression-instead-of-formal-function-symbol/Hi, everyone.
The question seems to be basic, but I cannot find out any simple answer for it...
So, the case is as follows. Let's assume, we have some formal function symbol (which is intended later to be replaced by actual expression)
x = var('x'); f = function('f', x)
and some function, which uses 'f(x)' in its definition:
a, b = var('a b')
g(x) = a*f(x) + b*f(x)^2
now we would like to compute derivative of 'g(x)' (and possibly make some other manipulations)
h(x) = diff(g, x)
as a result we have h(x), which includes symbols like 'D[0]f(x)'. This can be answer for some problem in general form. But now we would like to evaluate this expression for particular 'f(x)' (and possibly multiple times with different expressinos), e. g. for 'f(x) = a*x + b'.
It is desirable to have this with something like
answer = h.subs({f:a*x + b}) # do not work :(
but this substitution do not work inside derivatives...
So, the question is: is there some simple solution (like simple subs() function) for the case I've described above? Or may be there is some standard tricks/patterns to solve this issue?
Thanks in advance for any suggestions.Dmitry SemikinWed, 11 May 2011 08:53:09 -0500http://ask.sagemath.org/question/8110/