ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 30 Jul 2015 04:04:04 -0500Substituting derivative in equationhttp://ask.sagemath.org/question/28720/substituting-derivative-in-equation/ There is likely a simple way to solve this, but I cannot seem to find a way. Let say I have two functions, f(x,y) and g(x,y)
> var('x,y')
>f=function('f',x,y)
>g=function('g',x,y)
I want to be able to substitute a value for one of the derivatives. For example, if I have the equation x^2y+f.diff(x,1), I may want to substitute in the function g, so I have x^2y+g. I tried the following
>(x^2y+f.diff(x,1)).subs(f.diff(x,1)=g)
And get an error that a keyword can't be an expression. Is there anyway to make this substitution?Wed, 29 Jul 2015 13:21:39 -0500http://ask.sagemath.org/question/28720/substituting-derivative-in-equation/Answer by rws for <p>There is likely a simple way to solve this, but I cannot seem to find a way. Let say I have two functions, f(x,y) and g(x,y)</p>
<blockquote>
<p>var('x,y')</p>
<p>f=function('f',x,y)</p>
<p>g=function('g',x,y)</p>
</blockquote>
<p>I want to be able to substitute a value for one of the derivatives. For example, if I have the equation x^2y+f.diff(x,1), I may want to substitute in the function g, so I have x^2y+g. I tried the following</p>
<blockquote>
<p>(x^2y+f.diff(x,1)).subs(f.diff(x,1)=g)</p>
</blockquote>
<p>And get an error that a keyword can't be an expression. Is there anyway to make this substitution?</p>
http://ask.sagemath.org/question/28720/substituting-derivative-in-equation/?answer=28723#post-id-28723Multiplication needs `*`, it works for me:
sage: (x^2*y+f.diff(x,1)).subs(f.diff(x,1)==g)
x^2*y + g(x, y)
Thu, 30 Jul 2015 04:04:04 -0500http://ask.sagemath.org/question/28720/substituting-derivative-in-equation/?answer=28723#post-id-28723