#17445: Missing documentation of derivative operator/notation
-------------------------------+------------------------
Reporter: schymans | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.5
Component: symbolics | Resolution:
Keywords: | Merged in:
Authors: schymans | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-------------------------------+------------------------
Comment (by schymans):
Thanks, Nils, I didn't see that. However, I am still not able to achieve
what I was hoping for. Let me give a pratical example. I define an
expression for pressure following the ideal gas law:
{{{
sage: var('R t p n T V')
sage: eq_p = p == n*R*T/V
}}}
At some point, I would like to differentiate this equation for an open
system, i.e. where p, n, T and V are functions of time. I re-defined the
respective variables as functions of and time tried taking the derivative,
but:
{{{
sage: function('p',t)
sage: function('n', t)
sage: function('T', t)
sage: function('V', t)
sage: diff(eq_p,t)
p == R*T*n/V
0 == 0
}}}
I also didn't find a way to get FderivativeOperator to do the trick:
{{{
sage: D = sage.symbolic.operators.FDerivativeOperator
sage: D(eq_p,[0])
D[0](p == R*T*n/V)
}}}
The only way to get the desired outcome seems to be to re-write the whole
equation:
{{{
sage: eq_p = p(t) == n(t)*R*T(t)/V(t)
sage: diff(eq_p,t)
D[0](p)(t) == R*n(t)*D[0](T)(t)/V(t) - R*T(t)*n(t)*D[0](V)(t)/V(t)^2 +
R*T(t)*D[0](n)(t)/V(t)
}}}
Alright, I thought, what about a system with constant volume?
{{{
sage: eq_p = p(t) == n(t)*R*T(t)/V
sage: diff(eq_p,t)
Boom!
}}}
Pity, would have been too easy. Interestingly, this works instead:
{{{
sage: eq_p = p(t) == n(t)*R*T(t)/V(x)
sage: diff(eq_p,t)
D[0](p)(t) == R*n(t)*D[0](T)(t)/V(x) + R*T(t)*D[0](n)(t)/V(x)
}}}
I'm still confused. What I want to express by function('V', t) is that V
is a function of t and hence needs to be treated as such when taking the
derivative with respect to t. By writing V(t) above, I turn the function
into an expression again, which does lead to the desired functionality,
but you mentioned earlier that V(t) means "Function V evaluated at t",
which to me means something different. I don't see the utility of defining
function('V', t) in the above at all. I could have equally defined
function('V', x), right?
What would be the correct way to do the above consistently?
--
Ticket URL: <http://trac.sagemath.org/ticket/17445#comment:20>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.