There is no need to declare alpha
, beta
, gamma
as symbolic variables
before defining them as symbolic functions. So you could simplify the
declaration of variables and functions as follows.
sage: t = SR.var('t')
sage: alpha(t) = function('alpha')(t)
sage: beta(t) = function('beta')(t)
sage: gamma(t) = function('gamma')(t)
Then you define:
sage: mi(t) = sin(beta)^2*diff(alpha(t), t) + (cos(beta)*diff(alpha(t), t) +diff(gamma(t), t))*cos(beta)
sage: mi(t)
sin(beta(t))^2*diff(alpha(t), t) + (cos(beta(t))*diff(alpha(t), t) + diff(gamma(t), t))*cos(beta(t))
Then you expand and apply trig_simplify
:
sage: mi_e = mi(t).expand()
sage: mi_e_ts = mi_e.trig_simplify()
This is what you get:
sage: mi_e
cos(beta(t))^2*diff(alpha(t), t) + sin(beta(t))^2*diff(alpha(t), t) + cos(beta(t))*diff(gamma(t), t)
sage: mi_e_ts
cos(beta(t))*gamma(t)*psi(t) + diff(alpha(t), t)
The result involves psi
, so we investigate what it is. Sage allows you
to use blah?
to get the documentation of blah
. Use this as follows:
sage: psi?
Signature: psi(x, *args, **kwds)
Docstring:
The digamma function, psi(x), is the logarithmic derivative of the
gamma function.
psi(x) = frac{d}{dx} log(Gamma(x)) =
frac{Gamma'(x)}{Gamma(x)}
We represent the n-th derivative of the digamma function with
psi(n, x) or psi(n, x).
EXAMPLES:
sage: psi(x)
psi(x)
sage: psi(.5)
-1.96351002602142
sage: psi(3)
-euler_gamma + 3/2
sage: psi(1, 5)
1/6*pi^2 - 205/144
sage: psi(1, x)
psi(1, x)
sage: psi(1, x).derivative(x)
psi(2, x)
sage: psi(3, hold=True)
psi(3)
sage: psi(1, 5, hold=True)
psi(1, 5)
Init docstring: x.__init__(...) initializes x; see help(type(x)) for signature
File: /path/to/sage-8.1/local/lib/python2.7/site-packages/sage/functions/other.py
Type: function
have you tried
psi?
? It will tell you what thepsi
function is.Notebook tells it is psi(t). But it is amazing!! It is not defined. And seems to susbtitute 'diff(gamma(t),t)' that it is supposed to be the right answer.
Right answer must be: cos(beta(t))*diff(gamma(t), t) + diff(alpha(t), t)
Sage just prefers writing out the differential in terms of the digamma function, which is documented to be the logarithmic derivative of the gamma function:
I'm not sure what you mean by "it is not defined". Are you using a very old version of Sage? In 8.1, the symbol psi in the global scope is bound to the digamma function.
I did not want to use mathematical function gamma. I only wanted to define an angle variable. I have just used another name for the symbolic angle variable 'rho' and now it works.
Here it is the code:
And the expected result:
Thanks Nbruin
@ceiar: what version of Sage are you using? (What do you get if you type
version()
in Sage?)