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.Sun, 22 Sep 2019 08:11:10 +0200How to substitute a function in a derivativehttps://ask.sagemath.org/question/48007/how-to-substitute-a-function-in-a-derivative/ I know that if $U(x, y) = A x^\alpha y^\beta$, I have $U_x = \alpha A x^{\alpha-1} y ^\beta$. But by substitution, I can obtain $U_x = \alpha \left(\frac{U}{x}\right\)$. Is there a way to obtain this in Sagemath. I have tried
U_x= U.diff(x).subs(A*x^(alpha)*y^(beta)== U)
but this has no effect.
Sat, 21 Sep 2019 14:29:05 +0200https://ask.sagemath.org/question/48007/how-to-substitute-a-function-in-a-derivative/Answer by Emmanuel Charpentier for <p>I know that if $U(x, y) = A x^\alpha y^\beta$, I have $U_x = \alpha A x^{\alpha-1} y ^\beta$. But by substitution, I can obtain $U_x = \alpha \left(\frac{U}{x}\right)$. Is there a way to obtain this in Sagemath. I have tried</p>
<p>U_x= U.diff(x).subs(A<em>x^(alpha)</em>y^(beta)== U) </p>
<p>but this has no effect.</p>
https://ask.sagemath.org/question/48007/how-to-substitute-a-function-in-a-derivative/?answer=48016#post-id-48016If I understand you correctly, you meant that $U_x=\frac{\partial U}{\partial x}$, right ? If so, your result is a triviality, since :
- There exists some quantity $K$ such as $U(x,y)=K x^\alpha$, where $K$ doesn't depend on $x$ (in fact, it is obvious that $K=A y^\beta$).
- Therefore $\frac{\partial U}{\partial x}=K\frac{\partial x^\alpha}{\partial x}=K\alpha x^{\alpha-1}$
This can be checked in sage quite directly:
sage: U(x,y)=A*x^a*y^b;U
(x, y) |--> A*x^a*y^b
sage: bool(U(x,y).diff(x)==a*U(x,y)/x)
True
Sat, 21 Sep 2019 17:28:12 +0200https://ask.sagemath.org/question/48007/how-to-substitute-a-function-in-a-derivative/?answer=48016#post-id-48016Comment by Cyrille for <p>If I understand you correctly, you meant that $U_x=\frac{\partial U}{\partial x}$, right ? If so, your result is a triviality, since :</p>
<ul>
<li><p>There exists some quantity $K$ such as $U(x,y)=K x^\alpha$, where $K$ doesn't depend on $x$ (in fact, it is obvious that $K=A y^\beta$).</p></li>
<li><p>Therefore $\frac{\partial U}{\partial x}=K\frac{\partial x^\alpha}{\partial x}=K\alpha x^{\alpha-1}$</p></li>
</ul>
<p>This can be checked in sage quite directly:</p>
<pre><code>sage: U(x,y)=A*x^a*y^b;U
(x, y) |--> A*x^a*y^b
sage: bool(U(x,y).diff(x)==a*U(x,y)/x)
True
</code></pre>
https://ask.sagemath.org/question/48007/how-to-substitute-a-function-in-a-derivative/?comment=48018#post-id-48018Of course Emmanuel It's trivial. But for students it is not. You propose a verification not a substitution neither a demonstration.Sat, 21 Sep 2019 23:28:47 +0200https://ask.sagemath.org/question/48007/how-to-substitute-a-function-in-a-derivative/?comment=48018#post-id-48018Comment by Emmanuel Charpentier for <p>If I understand you correctly, you meant that $U_x=\frac{\partial U}{\partial x}$, right ? If so, your result is a triviality, since :</p>
<ul>
<li><p>There exists some quantity $K$ such as $U(x,y)=K x^\alpha$, where $K$ doesn't depend on $x$ (in fact, it is obvious that $K=A y^\beta$).</p></li>
<li><p>Therefore $\frac{\partial U}{\partial x}=K\frac{\partial x^\alpha}{\partial x}=K\alpha x^{\alpha-1}$</p></li>
</ul>
<p>This can be checked in sage quite directly:</p>
<pre><code>sage: U(x,y)=A*x^a*y^b;U
(x, y) |--> A*x^a*y^b
sage: bool(U(x,y).diff(x)==a*U(x,y)/x)
True
</code></pre>
https://ask.sagemath.org/question/48007/how-to-substitute-a-function-in-a-derivative/?comment=48019#post-id-48019Ah. I see what you mean. Bt that's not substitution *per se*. What you're trying to do is:
sage: var("z")
z
sage: solve(U.diff(x)(x,y)==z*U(x,y),z)
[z == alpha/x]
I can't say I find trhis especially illuminating...Sun, 22 Sep 2019 08:11:10 +0200https://ask.sagemath.org/question/48007/how-to-substitute-a-function-in-a-derivative/?comment=48019#post-id-48019