<jupyter_start><jupyter_text>cf. ["Ellipses", Sage Math Documentation](http://doc.sagemath.org/html/en/reference/plotting/sage/plot/ellipse.html)<jupyter_code>from sage.plot.ellipse import Ellipse
Ellipse(0, 0, 2, 1, pi/4, {})<jupyter_output><empty_output><jupyter_text>`get_minmax_data()` - return a dictionary with bounding box data<jupyter_code># An example without an angle
p = ellipse((-2, 3), 1, 2)
d = p.get_minmax_data()
print(d['xmin'])
print(d['xmax'])
print(d['ymin'])
print(d['ymax'])
# Same example with rotation of angle pi / 2
p = ellipse((-2, 3), 1, 2, pi/2)
d = p.get_minmax_data()
print(d['xmin'])
print(d['xmax'])
print(d['ymin'])
print(d['ymax'])<jupyter_output>-4.0
0.0
2.0
4.0<jupyter_text>```sage.plot.ellipse.ellipse(center, r1, r2, angle=0, edgecolor='blue',legend_color=None,facecolor='blue',linestyle='solid',thickness=1,zorder=5,aspect_ratio=1.0,alpha=1,legend_label=None,fill=False,**options)```Type `ellipse.options` to see all options.<jupyter_code>ellipse((0,0),2,1)
ellipse((0,0),3,1,pi/6,fill=True,alpha=0.3,linestyle="dashed")
ellipse((0,0),3,1,pi/6,fill=True,alpha=0.3,linestyle="--")
ellipse((0,0),3,1,pi/6,fill=True,edgecolor='black',facecolor='red')
ellipse((0,0),3,1,pi/6,fill=True,edgecolor='black',facecolor='red',rgbcolor='green')
ellipse((0,0),2,1).aspect_ratio()
# One cannot yet plot ellipses in 3D
ellipse((0,0,0),2,1)
# We can also give ellipses a legend
ellipse((0,0),2,1,legend_label="My ellipse", legend_color='green')<jupyter_output><empty_output><jupyter_text>Projective Curvescf. ["Projective curves", Sage Math documentation](http://doc.sagemath.org/html/en/reference/curves/sage/schemes/curves/projective_curve.html)  Projective Plane<jupyter_code>P.<x, y> = ProjectiveSpace(RR, 1)
print(type(P))
#print(type(P.algebra())) # TypeError
#print(P.algebra())
print(type(P.category()))
print(P.category())
print(type(P.categories()))
print(P.categories())
# https://ask.sagemath.org/question/29422/forcing-symbolic-variables-to-always-be-real/
var('a b', domain='real')
C_general_ellipse = Curve([x^2 + y^2],P); C_general_ellipse
Proj2.<x, y, z> = ProjectiveSpace(RR, 2)
print(type(Proj2))
C_general_ellipse = Curve([x^2/(1.0)^2 + y^2/(1.01)^2],Proj2);
C_general_ellipse<jupyter_output><empty_output><jupyter_text>Affine path<jupyter_code>C_general_ellipse.plane_projection()
C_general_ellipse.degree()
C_general_ellipse.is_singular()
C_general_ellipse.quadratic_transform()<jupyter_output><empty_output><jupyter_text>`Quadratic Form`cf. ["Quadratic Form", Sage Math](http://doc.sagemath.org/html/en/reference/quadratic_forms/sage/quadratic_forms/quadratic_form.html)<jupyter_code>Q2_RR = QuadraticForm(RR, 2, [1,2,3])
print(type(Q2_RR))
print(Q2_RR)<jupyter_output><class 'sage.quadratic_forms.quadratic_form.QuadraticForm'>
Quadratic form in 2 variables over Real Field with 53 bits of precision with coefficients: 
[ 1.00000000000000 2.00000000000000 ]
[ * 3.00000000000000 ]<jupyter_text>Plane Conics<jupyter_code>R_Poly_QQ_3 = PolynomialRing(QQ, 3, names=('X', 'Y', 'Z'))
print(R_Poly_QQ_3)
print(type(R_Poly_QQ_3))
#print(dir(R_Poly_QQ_3));
print(R_Poly_QQ_3.gens())
print(R_Poly_QQ_3.objgens())
print(R_Poly_QQ_3.ideal())
R_QQ_3.<X, Y, Z> = PolynomialRing(QQ, 3)
PythagorasThm = X^2 + Y^2 == Z^2
R_QQ_2.<x, y> = PolynomialRing(QQ, 2)
PythagorasThm.operator()<jupyter_output><empty_output><jupyter_text>[Symbolic Equations, Sage Math](http://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/relation.html)<jupyter_code>X, Y, Z = var('X Y Z', domain="real")
PythagorasThm = X^2 + Y^2 == Z^2
PythagorasThm.subs(X == x*Z).subs(Y == y *Z)
(PythagorasThm.subs(X == x*Z).subs(Y == y *Z) / Z^2).full_simplify()
var('l', latex_name='\lambda', domain='real')
x_subbed = 2*l/(l^2 + 1)
y_subbed = (l^2 - 1)/ (l^2 + 1)
(x_subbed / (1 - y_subbed)).full_simplify()
(PythagorasThm.subs(X == x*Z).subs(Y == y *Z) / Z^2).subs(x == x_subbed).subs(y == y_subbed).full_simplify()
m = var('m', domain='real')
PythagorasThm.subs(X == 2*l*m).subs(Y == l^2 - m^2).subs(Z == l^2 + m^2).full_simplify()<jupyter_output><empty_output><jupyter_text>cf. [<NAME>, **Undergraduate Algebraic Geometry**](https://homepages.warwick.ac.uk/staff/Miles.Reid/MA4A5/UAG.pdf) October 20, 2013. cf. Ch. 1, *Plane Conics*, Reid (2013).<jupyter_code>x_0, y_0 = var('x_0 y_0', domain="real")
P = vector([x_0, y_0])
k = var('k', domain="real")
lamb = var('lamb', domain="real")
#assume(lamb > 0)
X_lambda = vector([1., lamb])
Q_lambda = P + k* X_lambda
print(Q_lambda)
EllipsePolynomial = (x^2 / a^2 + y^2 / b^2 - 1)
print(EllipsePolynomial)
print(type(EllipsePolynomial))
EllipsePolynomial.subs(x == Q_lambda[0]).subs(y == Q_lambda[1])
k_solutions = solve(EllipsePolynomial.subs(x == Q_lambda[0]).subs(y == Q_lambda[1]), k)
k_solutions[0].full_simplify()
Q_lambda[0].subs(k == k_solutions[0].rhs())
Q_lambda[1].subs(k == k_solutions[0].rhs())<jupyter_output><empty_output><jupyter_text>Check the solutions against `P = (0, 1)` and `a = b = 1`<jupyter_code>Q_lambda[0].subs(k == k_solutions[0].rhs()).subs(a == 1).subs(b == 1).subs(x_0 == 0).subs(y_0 == 1)
Q_lambda[1].subs(k == k_solutions[0].rhs()).subs(a == 1).subs(b == 1).subs(x_0 == 0).subs(y_0 == 1)
Q_lambda[0].subs(k == k_solutions[1].rhs()).subs(a == 1).subs(b == 1).subs(x_0 == 0).subs(y_0 == 1)
Q_lambda[1].subs(k == k_solutions[1].rhs()).subs(a == 1).subs(b == 1).subs(x_0 == 0).subs(y_0 == 1)<jupyter_output><empty_output><jupyter_text>Indeed, check the slope:<jupyter_code>(Q_lambda[1].subs(k == k_solutions[0].rhs()).subs(a == 1).subs(b == 1).subs(x_0 == 0).subs(y_0 == 1) - 1)/ \
Q_lambda[0].subs(k == k_solutions[0].rhs()).subs(a == 1).subs(b == 1).subs(x_0 == 0).subs(y_0 == 1)<jupyter_output><empty_output><jupyter_text>cf. 1.2 Similar example, Reid (2013)<jupyter_code>Q_lambda[0].subs(k == k_solutions[0].rhs()).subs(x_0 == 0).subs(y_0 == 1)
Q_lambda[1].subs(k == k_solutions[0].rhs()).subs(x_0 == 0).subs(y_0 == 1)
Q_lambda[0].subs(k == k_solutions[1].rhs()).subs(x_0 == 0).subs(y_0 == 1)
Q_lambda[1].subs(k == k_solutions[1].rhs()).subs(x_0 == 0).subs(y_0 == 1)<jupyter_output><empty_output><jupyter_text>cf. Sec. 2.1. "Examples of parametrized cubics" in Ch. 2, *Cubics and the group law*, Reid (2013).<jupyter_code>R_QQ_2.<x, y> = PolynomialRing(QQ, 2)
R_QQ_2.gens()
R_QQ_2.gens_dict()
nodal_cubic_polynomial = y^2 - (x^3 + x^2)
cuspidal_cubic_polynomial = y^2 - x^3
#print(nodal_cubic_polynomial.additive_order()) # NotImplementedError
print(nodal_cubic_polynomial.args())
print(nodal_cubic_polynomial.base_ring())
print(nodal_cubic_polynomial.exponents())
# print(nodal_cubic_polynomial.coefficient()) # TypeError
print(nodal_cubic_polynomial.coefficients())
print(nodal_cubic_polynomial.constant_coefficient())
#print(nodal_cubic_polynomial.gcd())
print(nodal_cubic_polynomial.monomials())
#nodal_cubic_polynomial.truncate() # TypeError: truncate() takes exactly 2 positional arguments
#nodal_cubic_polynomial.univariate_polynomial() # TypeError: polynomial must involve at most one variable
print(nodal_cubic_polynomial.variable())
print(nodal_cubic_polynomial.variables())
#print(nodal_cubic_polynomial.weighted_degree())
#print(dir(nodal_cubic_polynomial))
print(factor(nodal_cubic_polynomial))
print(factor(cuspidal_cubic_polynomial))
with localvars(R_QQ_2, ['x_1','x_2']):
     print(cuspidal_cubic_polynomial)
        
print(cuspidal_cubic_polynomial)
# cf. http://doc.sagemath.org/pdf/en/constructions/constructions.pdf
print(nodal_cubic_polynomial * R_QQ_2)
print(type(nodal_cubic_polynomial * R_QQ_2))
print((nodal_cubic_polynomial * R_QQ_2).complete_primary_decomposition())
print((nodal_cubic_polynomial * R_QQ_2).gens())
print((nodal_cubic_polynomial * R_QQ_2).groebner_basis())
# print((nodal_cubic_polynomial * R_QQ_2).is_maximal()) # NotImplementedError
print((nodal_cubic_polynomial * R_QQ_2).primary_decomposition())

# cf. http://doc.sagemath.org/pdf/en/constructions/constructions.pdf
print(cuspidal_cubic_polynomial * R_QQ_2)
print(type(cuspidal_cubic_polynomial * R_QQ_2))
print((cuspidal_cubic_polynomial * R_QQ_2).complete_primary_decomposition())
print((cuspidal_cubic_polynomial * R_QQ_2).gens())
print((cuspidal_cubic_polynomial * R_QQ_2).groebner_basis())
# print((nodal_cubic_polynomial * R_QQ_2).is_maximal()) # NotImplementedError
print((cuspidal_cubic_polynomial * R_QQ_2).primary_decomposition())<jupyter_output>Ideal (-x^3 + y^2) of Multivariate Polynomial Ring in x, y over Rational Field
<class 'sage.rings.polynomial.multi_polynomial_ideal.MPolynomialIdeal'>
[(Ideal (x^3 - y^2) of Multivariate Polynomial Ring in x, y over Rational Field, Ideal (x^3 - y^2) of Multivariate Polynomial Ring in x, y over Rational Field)]
[-x^3 + y^2]
[x^3 - y^2]
[Ideal (x^3 - y^2) of Multivariate Polynomial Ring in x, y over Rational Field]<jupyter_text>cf. [Curves, Sage Math doc](http://doc.sagemath.org/pdf/en/reference/curves/curves.pdf)<jupyter_code>nodal_cubic_curve = Curve(y^2 - (x^3 + x^2))
cuspidal_cubic_curve = Curve(y^2 - x^3)
print(nodal_cubic_curve)
print(cuspidal_cubic_curve)
print(nodal_cubic_curve.genus())
print(cuspidal_cubic_curve.genus())

#nodal_cubic_curve.blowup((0,0))
nodal_cubic_curve.blowup()
#cuspidal_cubic_curve.blowup((0,0))
cuspidal_cubic_curve.blowup()<jupyter_output><empty_output><jupyter_text>Conic sections playground<jupyter_code>Proj_RR_2.<X, Y, Z> = ProjectiveSpace(RR, 2)
a = 2.0; b = 5.0
C_ellipse = Curve([X^2/a^2 + Y^2/b^2], Proj_RR_2);
print(C_ellipse.Jacobian())
print(C_ellipse.Jacobian_matrix())
C_ellipse.ambient_space()
C_ellipse.base()
C_ellipse.categories()
C_ellipse.category()
C_ellipse.codimension()
C_ellipse.defining_ideal()
C_ellipse.defining_polynomial()
C_ellipse.defining_polynomials()
C_ellipse.degree()
C_ellipse.dimension()
C_ellipse.embedding_morphism()
C_ellipse.identity_morphism()
C_ellipse.singular_subscheme()
C_ellipse.singular_points()
C_ellipse.is_smooth()
dir(C_ellipse)
C_ellipse.Jacobian()
C_parabola = Curve([a*X^2 - Y * Z], Proj_RR_2);
print(C_parabola)
print(type(C_parabola))
C_parabola.singular_points()
C_parabola.singular_subscheme()
C_parabola.ngens()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18082680678100527, 'fraction_numerical': 0.03638346386437989, 'mean_word_length': 7.999107939339875, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 68, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 3, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '371443', 'license': 'MIT', 'n_tokens_mistral': 4730, 'n_tokens_neox': 4455, 'n_words': 587, 'path': 'ConicSections.ipynb', 'repo_name': 'URenko/mathphysics', 'size': '10091'}