ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 02 May 2021 21:54:48 +0200How to define functions with varying number of variableshttps://ask.sagemath.org/question/56908/how-to-define-functions-with-varying-number-of-variables/I want to compute the Frechet derivative for a vector field, and that code works perfectly for functions with two variables *x* and *t*.
var ("t x")
v = function ("v")
u = function ("u")
w1 = function ("w1")
w2 = function ("w2")
eqsys = [diff(v(x,t), x) - u(x,t), diff(v(x,t), t) - diff(u(x,t), x)/(u(x,t)**2)]
def FrechetD (support, dependVar, independVar, testfunction):
frechet = []
eps = var ("eps")
v = independVar[:] + [eps]
for j in range (len(support)):
deriv = []
for i in range (len(support)):
r0 (x, t, eps) = dependVar[i](*independVar)+ testfunction[i](*independVar) * eps
s = support[j].substitute_function (dependVar[i], r0)
deriv.append (diff(s, eps).subs ({eps: 0}))
frechet.append (deriv)
return frechet
FrechetD (eqsys, [u,v], [x,t], [w1,w2])
[[-w1(x, t), diff(w2(x, t), x)],
[2*w1(x, t)*diff(u(x, t), x)/u(x, t)^3 - diff(w1(x, t), x)/u(x, t)^2,
diff(w2(x, t), t)]]
but my problem is the line
r0 (x, t, eps) = dependVar[i](*independVar)+ testfunction[i](*independVar) * eps
because this depends on the hardcoded *x* and *t*. Without it the following derivation for *eps* always is 0. Even when I add someting like
_r0 = function('ro')(*v)
doesn't work.
What i want to do is to something like
r0 (*v) = dependVar[i](*independVar)+ testfunction[i](*independVar) * eps
to get rid of the hardcoded variables and/or the number of variables. Is that possible ?
tamanduaSun, 02 May 2021 21:54:48 +0200https://ask.sagemath.org/question/56908/Image.PNG definition degraded, in notebook viewhttps://ask.sagemath.org/question/44682/imagepng-definition-degraded-in-notebook-view/Hi
is there a way to improve the definition in Jupyter notebook ?
from PIL import Image
img=Image.open("C:\\Users\\jean-pierre\\Documents\\SageMath\\IPYNB\\"+"Satellites.png")
matrix_plot(img, origin='upper',aspect_ratio=1)
![image description](/upfiles/15449698434825793.png)
what I see in notebook is very poor in notebook !
ortolljSun, 16 Dec 2018 15:26:19 +0100https://ask.sagemath.org/question/44682/How to define the derivative of a functionhttps://ask.sagemath.org/question/28796/how-to-define-the-derivative-of-a-function/ Hello,
I want to tell Sage what expression to use for the derivative of a funtion *a*. This vould be something like this: *diff(a,t) = b^2*. But this doesn't do the trick...
**Example**
I want to define this set of differential quations:
- aDot = da/dt = b^2,
- bdot = db/da = u.
I want Sage to find the relation between *a* and *u*. For that Sage needs to differentiate *a* twice:
- diff(a,t,2)
But to be able to calculate d^2/d *t* ^2 *a* = d/d*t *b*^2 = 2 *bu*, Sage needs to to both differential equations.
How can I implemant that?
Thanks alot in advance for your replies!
JohannesjohannesK84Mon, 10 Aug 2015 07:03:28 +0200https://ask.sagemath.org/question/28796/Difference between var() commandshttps://ask.sagemath.org/question/8914/difference-between-var-commands/x,y = var('x y')
x,y = var('x, y')
What is the difference between having the comma in between variable names? As opposed to just a space separating them.daniel.e2718Thu, 10 May 2012 20:48:21 +0200https://ask.sagemath.org/question/8914/