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.Wed, 07 Nov 2018 21:17:26 +0100drawing the corners for the inner parallelogram(solved)https://ask.sagemath.org/question/44218/drawing-the-corners-for-the-inner-parallelogramsolved/Hello,
i have the following plot, how do i draw the corners of the inner parallelogram in it.
If i did something overcomplicated just improve my code ( i'm a beginner).
g = Graphics()
g += text('g1', (10,4.5))
g += plot(2/5*x + 1,(x,-4,10)) #g1
#gradient triangle
g += line([(0,1), (5,1)], rgbcolor=('#00c736'))
g += text('kw = 5', (2.5,0.5), rgbcolor=('#00c736'))
g += line([(5,1), (5,3)],rgbcolor=('#f6a200'))
g += text('ks = 2', (5.5,2), rgbcolor=('#f6a200'))
g += text('g2', (10,1.5))
g += plot(2/5*x - 2,(x,-4, 10)) #g2
g += text('h1', (10,-1.5))
g += plot(-1/2*x+1,(x,-4, 10)) #h1
g += text('h2', (10,-4.5))
g += plot(-1/2*x+4,(x,-4, 10)) #h2
#corners
g += arc((0.5,1), 1, sector=(pi*0,-pi/4+0.1))
g += arc((0.5,1), 1, sector=(pi*0,pi/4-0.2))
g.show()
can't upload a picture sorry insufficient karma :(.
and how do i change the steps at the x and y -axis to 1.
thanks in advance !neoryWed, 07 Nov 2018 21:17:26 +0100https://ask.sagemath.org/question/44218/how to plot a circle (without circle())https://ask.sagemath.org/question/38889/how-to-plot-a-circle-without-circle/ Hello,
I know you can plot a circle with circle(x,y,radius), but how do you do it with plot()?germacWed, 20 Sep 2017 22:43:54 +0200https://ask.sagemath.org/question/38889/Help with unstable codehttps://ask.sagemath.org/question/37907/help-with-unstable-code/ This basically continues from a previous post: [generation of certain matrices](https://ask.sagemath.org/question/37860/generation-of-certain-matrices/)
I'm trying to draw circles in the plane by using fractional linear transformations.
Here is my code:
K = NumberField(x^2 + 2, 's')
OK = K.ring_of_integers()
def FLT(M,z):
"""takes the fractional linear transformation/Mobius transformation of a z in CC"""
if z == 'infinity' and M[1,0] != 0:
return M[0,0]/M[1,0]
elif z == 'infinity' and M[1,0] == 0:
return 'infinity'
elif M[1,0] != 0 and z == -M[1,1]/M[1,0]:
return 'infinity'
else:
return (M[0,0]*z+M[0,1])/(M[1,0]*z + M[1,1])
Now generate circles based on 3 image points of a matrix M with entries in the ring OK via FLT:
var('a','b','r','x','y')
func_cir=(x-a)**2+(y-b)**2==r**2
circles = set()
j = 0
while j < 10:
M = random_matrix(OK,2,algorithm = 'unimodular')
if FLT(M,-1) != 'infinity' and FLT(M,0) != 'infinity' and FLT(M,1) != 'infinity':
pta=[FLT(M,-1)[0],FLT(M,-1)[1]]
ptb=[FLT(M,0)[0],FLT(M,0)[1]]
ptc=[FLT(M,1)[0],FLT(M,1)[1]]
eq1 = func_cir.subs(x==pta[0]).subs(y==pta[1])
eq2 = func_cir.subs(x==ptb[0]).subs(y==ptb[1])
eq3 = func_cir.subs(x==ptc[0]).subs(y==ptc[1])
sol = solve([eq1,eq2,eq3],a,b,r)
C = circle((sol[1][0].rhs(),sol[1][1].rhs()),sol[1][2].rhs())
circles.add(C)
j += 1
This second chunk of code throws the error "list index out of range" about 50% of the time. I thought that it may have been due to division by zero, but now I'm not so sure. I've also tried using a for loop with the exact same result.
Thank you very much for the help!
Daniel LSat, 10 Jun 2017 21:16:34 +0200https://ask.sagemath.org/question/37907/transformation to lines and circleshttps://ask.sagemath.org/question/35516/transformation-to-lines-and-circles/I'd like to take a circle and apply a transformation to it (such as a reflection or a translation).
For instance, if T1 is translation 1 unit right and
c1 = circle((0,0),1),
I'd like to be able to plot T1(c1) (the image of c1 under T1, which is the circle with new center (1,0)).
How can I do this? Daniel LFri, 11 Nov 2016 04:34:40 +0100https://ask.sagemath.org/question/35516/Plot a circle, by utilizing an equation solved for xhttps://ask.sagemath.org/question/10483/plot-a-circle-by-utilizing-an-equation-solved-for-x/The following code is an example of plotting the equation: x = y^2-3*x-5*y+7, i.e. an equation solved for x:
var('y')
f = y^2-3*x-5*y+7
Yax = x
Xax = y
p1= implicit_plot(f, (x,-4, 4), (y,-2, 6))
p3= implicit_plot(Yax, (x,-4, 4), (y,-2, 6),color='black')
p4= implicit_plot(Xax, (x,-4, 4), (y,-2, 6),color='black')
p0= p1+p3+p4
show(p0)
According to the author, he solved the following equation in terms of x: x^2+y^2 = 25
He got the following: x = sqrt(25 - y^25) and x = -sqrt(25-y^2), i.e. ± sqrt(25 - y^25).
According to him, he plotted the 2 separate results to obtain a circle plot/graph.
How can I generate such an output on Sage 5.9?
The following was my best attempt, but I received no output for the plot of: sqrt(25-y^2):
var('y')
f = sqrt(25-y^2)
Yax = x
Xax = y
p1= implicit_plot(f, (x,-50, 50), (y,-50, 50))
p3= implicit_plot(Yax, (x,-50, 50), (y,-50, 50), color='black')
p4= implicit_plot(Xax, (x,-50, 50), (y,-50, 50), color='black')
p0= p1+p3+p4
show(p0)bxdinThu, 29 Aug 2013 00:40:07 +0200https://ask.sagemath.org/question/10483/Plot circle or ellipse with equation?https://ask.sagemath.org/question/10311/plot-circle-or-ellipse-with-equation/Given the standard equation of a circle:
x^2 + y^2 + 7*x - 2*y + 6 = 0 --Simplified-to--> (x+7/2)^2 + (y-1)^2 = 29/4
Standard formula of a circle: (x + (-h))^2 + (y + (-k))^2 = r^2
The center is represented by (h, k); radius by sqrt(r^2).
So my first question is, is there are way I could insert either of the 1st 2 equations and have Sage 5.9 generate the circle?
My second question similarly deals with an ellipse that has the simplified equation:
((x+2)^2)/9 + ((y-1)^2)/25 = 1
Its major axis is: (-2,-4) (-2,6)
Minor axis is: (-5,1) (1,1)
Standard form of an ellipse is: ((x - (-h))^2)/b^2 + ((y + (-k))^2)/a^2
Center is determined by analyzing the differences between the x2/x1, y2/y1 coordinates of the major or minor axis (i.e. midpoint formula).
Could I generate an ellipse baed on the simplified equation?
In case anyone's interested, the following thread has an unanswered question:
http://ask.sagemath.org/question/2764/graph-based-on-y-value-as-the-input-and-x-as-thebxdinTue, 02 Jul 2013 14:24:51 +0200https://ask.sagemath.org/question/10311/unaccurate plot of a circlehttps://ask.sagemath.org/question/9924/unaccurate-plot-of-a-circle/Hi!
I want to plot a circle centered at the origin and radius sqrt(2). When I type:
> plot(sqrt(2-x^2),-sqrt(2),sqrt(2),aspect_ratio=1)+plot(-sqrt(2-x^2),-sqrt(2),sqrt(2))
in sage 5.4, the graph obtained is really unaccurated.
However, for the circle of radius sqrt(3) works fine. Does anybody know why?
Of course I know there are several ways to plot a circle, but i want do do like this for showing my pupils some applications of integral calculus.
I think it is important to have a "plot" command working properly, since it is extensively used in teaching.mathematicboyTue, 19 Mar 2013 13:39:36 +0100https://ask.sagemath.org/question/9924/Circle through three points (in 2D)https://ask.sagemath.org/question/8768/circle-through-three-points-in-2d/Given the coordinates of three points (in 2D), how can I plot the circle through them?GrimRippahSun, 04 Mar 2012 20:43:16 +0100https://ask.sagemath.org/question/8768/New Project Looking for Help: Plotting great circleshttps://ask.sagemath.org/question/7785/new-project-looking-for-help-plotting-great-circles/Hi,
I'm working on a project and found that sage may be the best program to help. Information can be found at [vividdynamics.com](http://vividdynamics.com). I'm not a math student but study it as a hobby(mainly geometry) and have some art backround.
I'm looking for a way to generate a sphere with great circles plotted at cumulatively smaller intervals as they get closer to axis, x and y. Like I said, I'm not a math student so, I'm not sure how to define it in mathematical terms. basically it would look like an orange but with smaller and smaller pieces at, 90º, 180º, 270º, and 0º.
---
EDIT (niles):
Are you looking for formulas to parametrize these various great circles (so that you can plot them with sage)? If so, maybe rotation matrices are one easy way to produce them. You could start with a great circle whose parametrization you know (e.g. the one in the x-z plane) and then get others by rotating about the z-axis, say 45º, 67.5º, 78.75º, etc. Is that something like what you're looking for?
If so, the Wikipedia article for [rotation matrices](http://en.wikipedia.org/wiki/Rotation_matrix#Three_dimensions) looks useful. I believe you can plot parametric curves with sage, and apply arbitrary transformation matrices to them. For starters, here's a circle:
sage: u = var('u')
sage: parametric_plot3d( (cos(u), 0, sin(u)), (u, 0, 2*pi))
---
EDIT (dividenot):
Thanks for the reply. That sounds exactly what I'm looking to do. I must say though, I'm somewhat confused about the ask/answer system here. Initially I was looking for some kind of forum where I could have a discussion or look up any needed information but ask.sagemath.org was the closest thing I could find. Is editing the message like this the best way to have a discussion?
I looked at the Wikipedia article on rotation matrices. I suspect that SAGE doesn't have a command for rotation matrices so I would have to make an array defining my own range. And call the values of each circle from the matrix. Does that sound like a good way to go about it?dividenotWed, 01 Dec 2010 11:17:24 +0100https://ask.sagemath.org/question/7785/