ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 22 Oct 2012 17:26:34 +0200How do I make functional substitutions?https://ask.sagemath.org/question/9454/how-do-i-make-functional-substitutions/I want to substitute one function for another. Consider this:
v = function('x')
u(x) = (v(x)+v(-x))/2
delta = 10^(-90)
u(delta).subs(v=gamma(x))
The very last line is what I'm trying to accomplish. I know it's the wrong command, but I'm wanting to make the substitution $v(x)\to\Gamma(x)$.
Is there a way along these lines to do such a functional substitution?Mon, 22 Oct 2012 16:16:35 +0200https://ask.sagemath.org/question/9454/how-do-i-make-functional-substitutions/Answer by Eviatar Bach for <p>I want to substitute one function for another. Consider this:</p>
<pre><code>v = function('x')
u(x) = (v(x)+v(-x))/2
delta = 10^(-90)
u(delta).subs(v=gamma(x))
</code></pre>
<p>The very last line is what I'm trying to accomplish. I know it's the wrong command, but I'm wanting to make the substitution $v(x)\to\Gamma(x)$.</p>
<p>Is there a way along these lines to do such a functional substitution?</p>
https://ask.sagemath.org/question/9454/how-do-i-make-functional-substitutions/?answer=14169#post-id-14169I think you want `v = function('v')` for the first line; the first argument is the name of the function.
Here's the full code:
v = function('v')
u(x) = (v(x) + v(-x))/2
delta = 10^(-90)
u(delta).substitute_function(v, gamma)
I'm puzzled as to why it doesn't work if `v` is defined as `v = function('v', x)`. Anyone know?Mon, 22 Oct 2012 16:40:05 +0200https://ask.sagemath.org/question/9454/how-do-i-make-functional-substitutions/?answer=14169#post-id-14169Comment by daniel.e2718 for <p>I think you want <code>v = function('v')</code> for the first line; the first argument is the name of the function.</p>
<p>Here's the full code:</p>
<pre><code>v = function('v')
u(x) = (v(x) + v(-x))/2
delta = 10^(-90)
u(delta).substitute_function(v, gamma)
</code></pre>
<p>I'm puzzled as to why it doesn't work if <code>v</code> is defined as <code>v = function('v', x)</code>. Anyone know?</p>
https://ask.sagemath.org/question/9454/how-do-i-make-functional-substitutions/?comment=18838#post-id-18838*Exactly* what I was looking for! Thanks!
EDIT: Good question though. Why doesn't it work if you specify the variable of the function?Mon, 22 Oct 2012 17:26:34 +0200https://ask.sagemath.org/question/9454/how-do-i-make-functional-substitutions/?comment=18838#post-id-18838