Ask Your Question

jdpipe's profile - activity

2024-03-20 14:21:45 +0200 received badge  Good Question (source)
2020-01-05 19:57:32 +0200 received badge  Nice Question (source)
2017-11-08 15:11:20 +0200 received badge  Famous Question (source)
2015-12-10 19:32:30 +0200 received badge  Notable Question (source)
2015-05-03 07:44:44 +0200 received badge  Popular Question (source)
2012-03-23 18:53:03 +0200 commented answer Is there any way to define an as-yet-unknown function?

Great. seems to work fine. The output is a bit weird though, in typeset sage, the diff(a(T),T) is written as D [ 0 ] ( a ) ( T ), not particular intuitive. But it works! Thank you.

2012-03-23 18:50:38 +0200 received badge  Supporter (source)
2012-03-23 18:50:28 +0200 received badge  Scholar (source)
2012-03-23 18:50:28 +0200 marked best answer Is there any way to define an as-yet-unknown function?

Answer from 2012. See further down for 2020 update.

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)

[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)
2012-03-23 14:39:48 +0200 received badge  Student (source)
2012-03-23 14:12:29 +0200 received badge  Editor (source)
2012-03-23 14:11:38 +0200 asked a question Is there any way to define an as-yet-unknown function?

I'd like to know if there's a way of declaring functions in sage that are as-yet unknown. For example, let's say I have a function

p = R*T/v - a(T)/v/(v+b)

And I would like to be able to take a derivative like this

deriv(p,T)

and be given something back a partial derivative something like

R/v - diff(a(T),T)/v/(v+b)

However at present I can't seem to put an abstract function a(T) into my expression or find anything in the documentation that says how this is done.

As I recall there was a way to do this with wxMaxima, so maybe I just haven't found the trick in Sage yet.