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.Fri, 18 Mar 2022 08:50:46 +0100plot_vector_field : unitshttps://ask.sagemath.org/question/61543/plot_vector_field-units/hi
i try this code :
y=var('y')#x l'est déjà par défaut
coef=10
g = plot_vector_field((x*coef, 2*y*coef), (x,-4,4), (y,-3,3),
gridlines=True, gridlinesstyle=dict(color="blue", linestyle=":"),
frame=False, axes=True)
show(g)
As my student discovery vector fields,
first we have drawn, by hand on the paper, this vector field :
they have understood that from the point (1,1) they have to draw the vector (1,2), they have counted on the grid to do this precisely
but now on the result :
![image description](/upfiles/16475897574216923.png)
you can see that Sagemath have converted the units in some way, maybe for lisibility, so that the vecteur on (1,1) is only colinear to (1,2) but IS not (1,2).
how can i understand where to customize the factor of conversion that Sagemath uses. Or, at least, to understand how it is calculated ?ErWinzFri, 18 Mar 2022 08:50:46 +0100https://ask.sagemath.org/question/61543/Restriction of domain of vector fieldhttps://ask.sagemath.org/question/44207/restriction-of-domain-of-vector-field/I was trying to plot a field of normal vectors to a given implicit graph. What I got so far is:
x, y = var('x y')
f(x,y) = 2*x*y^3
g(x,y) = x^2*3*y^2
d = plot_vector_field((f(x,y)/sqrt(f(x,y)^2+g(x,y)^2),g(x,y)/sqrt(f(x,y)^2+g(x,y)^2)), (x,-5,5), (y,-5,5))
s = implicit_plot(x^2*y^3-1 , (x,-5,5), (y,-5,5))
show(s+d)
And it works like a charm, however, is there a way to "restrict" a domain of plot_vector_field so it doesn't plot all the vectors in a given range, but only for point (x,y) lying on my graph? That is such points that x^2*y^3=1. I tried to just put it instead (y,-5,5) (in a y=(1/x^2)^(1/3) form), but it obviously doesn't work.
Thx for any help as I'm new to Sage.Michał_FabisiakTue, 06 Nov 2018 21:04:40 +0100https://ask.sagemath.org/question/44207/plot_vector_field3d and three.js viewerhttps://ask.sagemath.org/question/41091/plot_vector_field3d-and-threejs-viewer/ I guess there might be some mistake in my code, but I cannot use `plot_vector_field3d` and show the result with `three.js` viewer. The code is
var('x y z')
f = (x, y, z)
show(plot_vector_field3d(f, (x,-3,3), (y,-3,3), (z,-3,3), aspect_ratio=1), viewer='threejs')
and it only shows an empty box. How to explain this behaviour?jepstraTue, 13 Feb 2018 12:56:22 +0100https://ask.sagemath.org/question/41091/Vector Field example failshttps://ask.sagemath.org/question/40693/vector-field-example-fails/The following example fails with an error message in the last line.
This is an example taken from the "manifold.pdf" reference file, Page 337
I'm using SageMath 8.1 on Windows Native.
sage: S2 = Manifold(2, 'S^2')
sage: U = S2.open_subset('U') # the open set covered by spherical coord.
sage: XS.<th,ph> = U.chart(r'th:(0,pi):\theta ph:(0,2*pi):\phi')
sage: R3 = Manifold(3, 'R^3')
sage: X3.<x,y,z> = R3.chart()
sage: F = S2.diff_map(R3, {(XS, X3): [sin(th)*cos(ph),sin(th)*sin(ph), cos(th)]}, name='F')
sage: F.display() # the standard embedding of S^2 into R^3
sage: v = XS.frame()[1] ; v # the coordinate vector d/dphi
sage: graph_v = v.plot(chart=X3, mapping=F, label_axes=False)
sage: graph_S2 = XS.plot(chart=X3, mapping=F, number_values=9)
sage: graph_v + graph_S2
Moreover, each individual plot does not generate an error, but I don't see any plot, just an empty space!
danielvolinskiFri, 19 Jan 2018 18:02:38 +0100https://ask.sagemath.org/question/40693/Log scale in vector fieldhttps://ask.sagemath.org/question/33889/log-scale-in-vector-field/Is there a way to plot a 2D vector field with log scale in the x-axix? I was using plot_vector_field, but I can't find a way to use log with that.vitorThu, 23 Jun 2016 03:36:07 +0200https://ask.sagemath.org/question/33889/Variable not found while trying to plot a parametric phase portraithttps://ask.sagemath.org/question/30230/variable-not-found-while-trying-to-plot-a-parametric-phase-portrait/ I'm trying to plot a parametric phase portrait of a differential equations system, but i get the following error:
> ValueError: Variable 't' not found
Here's what I'm trying to do:
@interact
def _(a1 = slider(-30, 30, 0.001, default=0, label='a1'),
b1 = slider(-30, 30, 0.001, default=0, label='b1'),
a2 = slider(-30, 30, 0.001, default=0, label='a2'),
b2 = slider(-30, 30, 0.001, default=0, label='b2'),
g1 = slider(-30, 30, 0.001, default=0, label='g1'),
g2 = slider(-30, 30, 0.001, default=0, label='g2'),
auto_update=True):
discriminant = b2^2-2*b1*b2+b1^2+4*a1*a2
pretty_print("discriminant = " + str(discriminant))
if discriminant >= 0:
t = var('t')
M1 = function('M_1', t)
M2 = function('M_2', t)
de1 = diff(M1,t) == a1 * M2 - b1 * M1 + g1
de2 = diff(M2,t) == a2 * M1 - b2 * M2 + g2
plot_vector_field((de1.rhs(),de2.rhs()),(M1,-3,3),(M2,-3,3))
else:
pretty_print("discriminant is negative. adjust parameters")
Can't really figure out why is t not found and how to fix itdnoskovFri, 23 Oct 2015 02:38:10 +0200https://ask.sagemath.org/question/30230/