Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can define a function using the keyword function. The script below gives the answer you expect.

T=var('T')
a=function('a',T)
R=var('R')
v=var('v')
b=var('b')
p = R*T/v - a(T)/v/(v+b)
diff(p,T)

Answer from 2012. See further down for 2020 update.

You can define a function using the keyword function. function. The script below gives the answer you expect.

T=var('T')
a=function('a',T)
R=var('R')
v=var('v')
b=var('b')
T = var('T')
a = function('a', T)
R = var('R')
v = var('v')
b = var('b')
p = R*T/v - a(T)/v/(v+b)
diff(p,T)
diff(p, T)

[2020 update] Nowadays, function no longer takes the variable as an argument.

Use a = function('a') instead of a = function('a', T).

Example:

sage: version()
'SageMath version 9.0, Release Date: 2020-01-01'
sage: b, v, R, T = SR.var('b v R T')
sage: a = function('a')
sage: p = R*T/v - a(T)/v/(v+b)
sage: diff(p, T)
R/v - diff(a(T), T)/((b + v)*v)