ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 04 Feb 2017 12:43:29 -0600Evaluating the derivative of piecewise functionshttps://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 -0600https://ask.sagemath.org/question/36451/finding the derivative of a functional w.r.t a functionhttps://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 -0500https://ask.sagemath.org/question/32876/A simple problem related to symbolic calculationhttps://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 -0500https://ask.sagemath.org/question/26982/