ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 22 Jul 2019 03:43:22 -0500Problem with integrating the expression of Mhttp://ask.sagemath.org/question/47240/problem-with-integrating-the-expression-of-m/ Hi. I have the following code that I want to integrate and differentiate, but I am stuck at the expression of M, where it is unable to integrate. Is my coding wrong?
c,t = var('c t')
Pi = RR.pi()
G=integrate(sqrt(1-t^2)*(t+c),t,-0.9,0.9);G
H=G.diff(c);H
L=integrate(-(t+c)/(sqrt(1-t^2)),t,-0.9,0.9);L
M=integrate(1/(sqrt(1-t^2)*(t-c)),t,-0.9,0.9);M #cannot seem to integrate this wrt to t
I=(c^2-1)*(L+(1-c^2)*M);I #equation I that involves M
P=I.diff(c);P #differentiate I wrt to c to obtain equation P
I have tried integrating M by hand which gives me a closed-form involving log function, but I can't seem to integrate it here using Sage.ShaMon, 22 Jul 2019 03:43:22 -0500http://ask.sagemath.org/question/47240/Evaluating the derivative of piecewise functionshttp://ask.sagemath.org/question/36451/evaluating-the-derivative-of-piecewise-functions/ Hi,
In Sage 7.5 you can numerically evaluate the derivative of a regular symbolic expression using:
sage: h(x) = sin(x)
sage: diff(h)(2).n()
-0.416146836547142
Old **Piecewise** functions could be treated in the same way:
sage: g = Piecewise([([0,2], sin(x)), ((2,3), cos(x))])
... DeprecationWarning ...
sage: diff(g)(1).n()
0.540302305868140
However, new **piecewise** functions don't:
sage: f = piecewise([([0,2], sin(x)), ((2,3), cos(x))])
sage: diff(f)(1).n()
... Error ...
Thanks in advance.
franpenaSat, 04 Feb 2017 12:43:29 -0600http://ask.sagemath.org/question/36451/Derivation of a sagemanifold vector (possible bug)http://ask.sagemath.org/question/33951/derivation-of-a-sagemanifold-vector-possible-bug/ I'm using sage v7.1 with sagemanifold v0.9 to calculate Lie derivatives.
<h2>The problem</h2>
I define my manifold, with a chart and the vectors which define the symmetry,
M = Manifold(4, 'M', latex_name=r"\mathcal{M}")
X.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
Lx = M.vector_field('Lx')
Lx[:] = [ 0, 0, -cos(ph), cot(th)*sin(ph) ]
Ly = M.vector_field('Ly')
Ly[:] = [ 0, 0, sin(ph), cot(th)*cos(ph) ]
Lz = M.vector_field('Lz')
Lz[:] = [ 0, 0, 0, 1]
Lt = M.vector_field('Lt')
Lt[:] = [ 1, 0, 0, 0]
However, if I call the derivative of a component of the vector like
diff( Lx[3], th )
I get a `TypeError`, because
type( Lx[3] )
<class 'sage.manifolds.coord_func_symb.CoordFunctionSymb'>
and it seems that the function `diff` only acts on SR expressions.
<h2>My bypass</h2>
Although I was able to bypass the situation, it would be nice if a solution was provided *out of the box*, but in case anyone else needs a solution:
I defined my vectors in a Sage way
xi0 = [ 1, 0, 0, 0]
xi1 = [ 0, 0, -cos(ph), cot(th)*sin(ph) ]
xi2 = [ 0, 0, sin(ph), cot(th)*cos(ph) ]
xi3 = [ 0, 0, 0, 1]
and then assigned them to the SageManifolds vector_field
Lx = M.vector_field('Lx')
Lx[:] = xi1
Ly = M.vector_field('Ly')
Ly[:] = xi2
Lz = M.vector_field('Lz')
Lz[:] = xi3
Lt = M.vector_field('Lt')
Lt[:] = xi0
So, when I need the derivative of a component of the vector, I calculate
diff(xi1[3], th)
Cheers.DoxTue, 28 Jun 2016 10:16:13 -0500http://ask.sagemath.org/question/33951/finding the derivative of a functional w.r.t a functionhttp://ask.sagemath.org/question/32876/finding-the-derivative-of-a-functional-wrt-a-function/ I've defined a system as:
var('a, t');
function('x, y');
de1 = diff(x(t),t) == y(t);
de2 = diff(y(t),t) == -a*x(t) - (a-4)/a*y(t) - y(t)^3;
I'd like to compute the derivatives of the rhs of de1 and de2 w.r.t to x(t) and y(t) (to eventually form a Jacobian matrix), i.e. the derivative of the rhs of de1 w.r.t to x(t) is Zero and w.r.t y(t) is 1. I've tried the following:
diff(de1.rhs(),y);
diff(de1.rhs(),y(t));
derivative(de1.rhs(),y(t));
I get errors on all three. I'd appreciate any help. thank you.
sophiaThu, 24 Mar 2016 01:50:20 -0500http://ask.sagemath.org/question/32876/solve a system of two equations for a derivativehttp://ask.sagemath.org/question/32859/solve-a-system-of-two-equations-for-a-derivative/ I have the following defined:
sage: var('a, t');
sage: function('x, y, v, u')
sage: de1 = diff(x(t),t) - diff(y(t),t) == x(t)
sage: de2 = diff(y(t),t) == y(t)
I'd like to solve these two equations algebraically for diff(x(t),t) and diff(y(t),t).
sage: sol = solve(de1, diff(x(t),t)); works, and i get an explicit solution for diff(x(t),t), but when i try solving both equations using:
sage: sol = solve([de1, de2],diff(x(t),t),diff(y(t),t));
i get the following error:
Traceback (most recent call last):
File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/symbolic/relation.py", line 822, in solve
variables = tuple(args[0])
TypeError: 'sage.symbolic.expression.Expression' object is not iterable
=============================
I'd appreciate any help with this. thank you.sophiaWed, 23 Mar 2016 02:03:07 -0500http://ask.sagemath.org/question/32859/A simple problem related to symbolic calculationhttp://ask.sagemath.org/question/26982/a-simple-problem-related-to-symbolic-calculation/Could anyone let me know how you can define a variable as some function of another variable without specific definition? For example, how can you define theta as some function of x and then differentiate the 'sin(theta)' by x?
The following is my code that doesn't work. I couldn't find how to fix it in reference manuals. Any help will be appreciated.
var('theta, y, f')
y=sin(theta) ; theta=f(x);
y.derivative(x)Nownuri1Sat, 30 May 2015 07:15:05 -0500http://ask.sagemath.org/question/26982/Question about sum and diffhttp://ask.sagemath.org/question/25750/question-about-sum-and-diff/Why this code :
f(x)=sum(diff(sin(x),x,n),n,1,10)
f(x)
does not work?DesruimFri, 06 Feb 2015 11:57:46 -0600http://ask.sagemath.org/question/25750/