Math 300 - demo

432 days ago by jimlb

This is a short demonstration of some nice features of SAGE.  You'll get a notebook that looks like this if you use SAGE through the Clemson server as in the link I sent you.  If you download free SAGE on your laptop, you won't get this nice of an interface.  You'll still be able to do all the math, but not some of the other nice features.  If you still want the nicer features, then you have to use CoCalc, which is free if you want crappy service. Otherwise is costs money.  So basically use the Clemson service as long as it is available and complain to Oxy that you want ITS to actually install SAGE like Clemson has.

The first thing to note above is the Typeset button.  If you click that, all the outputs will be done in LaTeX and look nice.

If you want help, you type what you're trying to do with a question mark after it.  If that is a command in SAGE, it will bring up the documentation. For example, if we want to differentiate a function:

derivative?
 File: /usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/calculus/functional.py Type: Definition: derivative(f, *args, **kwds) Docstring: The derivative of f. Repeated differentiation is supported by the syntax given in the examples below. ALIAS: diff EXAMPLES: We differentiate a callable symbolic function: sage: f(x,y) = x*y + sin(x^2) + e^(-x) sage: f (x, y) |--> x*y + e^(-x) + sin(x^2) sage: derivative(f, x) (x, y) |--> 2*x*cos(x^2) + y - e^(-x) sage: derivative(f, y) (x, y) |--> x  We differentiate a polynomial: sage: t = polygen(QQ, 't') sage: f = (1-t)^5; f -t^5 + 5*t^4 - 10*t^3 + 10*t^2 - 5*t + 1 sage: derivative(f) -5*t^4 + 20*t^3 - 30*t^2 + 20*t - 5 sage: derivative(f, t) -5*t^4 + 20*t^3 - 30*t^2 + 20*t - 5 sage: derivative(f, t, t) -20*t^3 + 60*t^2 - 60*t + 20 sage: derivative(f, t, 2) -20*t^3 + 60*t^2 - 60*t + 20 sage: derivative(f, 2) -20*t^3 + 60*t^2 - 60*t + 20  We differentiate a symbolic expression: sage: var('a x') (a, x) sage: f = exp(sin(a - x^2))/x sage: derivative(f, x) -2*cos(-x^2 + a)*e^(sin(-x^2 + a)) - e^(sin(-x^2 + a))/x^2 sage: derivative(f, a) cos(-x^2 + a)*e^(sin(-x^2 + a))/x  Syntax for repeated differentiation: sage: R. = PolynomialRing(QQ) sage: f = u^4*v^5 sage: derivative(f, u) 4*u^3*v^5 sage: f.derivative(u) # can always use method notation too 4*u^3*v^5  sage: derivative(f, u, u) 12*u^2*v^5 sage: derivative(f, u, u, u) 24*u*v^5 sage: derivative(f, u, 3) 24*u*v^5  sage: derivative(f, u, v) 20*u^3*v^4 sage: derivative(f, u, 2, v) 60*u^2*v^4 sage: derivative(f, u, v, 2) 80*u^3*v^3 sage: derivative(f, [u, v, v]) 80*u^3*v^3  File: /usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/calculus/functional.py Type: Definition: derivative(f, *args, **kwds) Docstring: The derivative of f. Repeated differentiation is supported by the syntax given in the examples below. ALIAS: diff EXAMPLES: We differentiate a callable symbolic function: sage: f(x,y) = x*y + sin(x^2) + e^(-x) sage: f (x, y) |--> x*y + e^(-x) + sin(x^2) sage: derivative(f, x) (x, y) |--> 2*x*cos(x^2) + y - e^(-x) sage: derivative(f, y) (x, y) |--> x  We differentiate a polynomial: sage: t = polygen(QQ, 't') sage: f = (1-t)^5; f -t^5 + 5*t^4 - 10*t^3 + 10*t^2 - 5*t + 1 sage: derivative(f) -5*t^4 + 20*t^3 - 30*t^2 + 20*t - 5 sage: derivative(f, t) -5*t^4 + 20*t^3 - 30*t^2 + 20*t - 5 sage: derivative(f, t, t) -20*t^3 + 60*t^2 - 60*t + 20 sage: derivative(f, t, 2) -20*t^3 + 60*t^2 - 60*t + 20 sage: derivative(f, 2) -20*t^3 + 60*t^2 - 60*t + 20  We differentiate a symbolic expression: sage: var('a x') (a, x) sage: f = exp(sin(a - x^2))/x sage: derivative(f, x) -2*cos(-x^2 + a)*e^(sin(-x^2 + a)) - e^(sin(-x^2 + a))/x^2 sage: derivative(f, a) cos(-x^2 + a)*e^(sin(-x^2 + a))/x  Syntax for repeated differentiation: sage: R. = PolynomialRing(QQ) sage: f = u^4*v^5 sage: derivative(f, u) 4*u^3*v^5 sage: f.derivative(u) # can always use method notation too 4*u^3*v^5  sage: derivative(f, u, u) 12*u^2*v^5 sage: derivative(f, u, u, u) 24*u*v^5 sage: derivative(f, u, 3) 24*u*v^5  sage: derivative(f, u, v) 20*u^3*v^4 sage: derivative(f, u, 2, v) 60*u^2*v^4 sage: derivative(f, u, v, 2) 80*u^3*v^3 sage: derivative(f, [u, v, v]) 80*u^3*v^3 

Calculus 1:

2+2
 \newcommand{\Bold}[1]{\mathbf{#1}}4
f(x) = cos(x);f
 \newcommand{\Bold}[1]{\mathbf{#1}}x \ {\mapsto}\ \cos\left(x\right)
f(pi/4)
 \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2} \, \sqrt{2}
RR(f(pi/4))
 \newcommand{\Bold}[1]{\mathbf{#1}}0.707106781186548
plot(f(x), (x,-3*pi,3*pi), color='purple');
g(x) = f.derivative();g
 \newcommand{\Bold}[1]{\mathbf{#1}}x \ {\mapsto}\ -\sin\left(x\right)
P1=plot(f(x), (x,-3*pi,3*pi), color='blue'); P2=plot(g(x), (x,-3*pi,3*pi), color='red');
(P1+P2).show()

Of course, you'd like your graphs to be better labeled than this if you are going to use them in a project.

P1=plot(f(x), (x,-3*pi,3*pi), color='blue', axes_labels=['$x$','$y$']); P2=plot(g(x), (x,-3*pi,3*pi), color='red'); (P1+P2).show()

We can also put labels next to the functions, but that requires a little more work.  We have to actually create the text on the plot and tell SAGE where to position it.

P=plot(f(x), (x,-3*pi,3*pi), color='blue', axes_labels=['$x$','$y$']);
P+=plot(g(x), (x,-3*pi,3*pi), color='red')
P+=text("$y=f(x)$", (8.1,1), fontsize=15, color='black');P+=text("$y=f'(x)$", (3,1),fontsize=15, color='black');
P.show()
f(x) = 1/x;f
 x |--> 1/x x |--> 1/x

Just plotting this isn't going to be so useful because of the vertical asymptote.  We will want to limit the $y$-values.

plot(f,(x,-2,2),color='green')
P=plot(f,(x,-2,2),ymax=10,ymin=-10,color='blue');P.show()

We can also make simple things like lines, circles, etc.  We can remove axes if that is helpful, or put in a grid.

P=circle((0,0),2, thickness=1);P.show()
P=circle((0,0),8^(1/6), thickness=2, axes=false);P.show()
P=circle((1,1), 2, hue=.9, alpha=.1, fill=True);P.show()
P=line([(-1,-1),(1,1)], color='purple');P.show()

You can right click on any of these graphics and save them and then import them into LaTeX as a graphic.

We can also use the command latex(expression) to have SAGE spit out the latex code.  This can be super useful.  You must turn Typeset off for this though!

f(x) = sqrt(x-5) + 1/(x^5+5*x +3)^(1/3);f
 \newcommand{\Bold}[1]{\mathbf{#1}}x \ {\mapsto}\ \sqrt{x - 5} + \frac{1}{{\left(x^{5} + 5 \, x + 3\right)}^{\frac{1}{3}}}
f.derivative().derivative()
 \newcommand{\Bold}[1]{\mathbf{#1}}x \ {\mapsto}\ -\frac{20 \, x^{3}}{3 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{4}{3}}} + \frac{100 \, {\left(x^{4} + 1\right)}^{2}}{9 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{7}{3}}} - \frac{1}{4 \, {\left(x - 5\right)}^{\frac{3}{2}}}
derivative(f,x,2);
 \newcommand{\Bold}[1]{\mathbf{#1}}x \ {\mapsto}\ -\frac{20 \, x^{3}}{3 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{4}{3}}} + \frac{100 \, {\left(x^{4} + 1\right)}^{2}}{9 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{7}{3}}} - \frac{1}{4 \, {\left(x - 5\right)}^{\frac{3}{2}}}
g=derivative(f,x,5);g
 \newcommand{\Bold}[1]{\mathbf{#1}}x \ {\mapsto}\ -\frac{280000 \, {\left(x^{4} + 1\right)} x^{6}}{9 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{10}{3}}} + \frac{16000 \, x^{5}}{3 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{7}{3}}} + \frac{7000000 \, {\left(x^{4} + 1\right)}^{3} x^{3}}{81 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{13}{3}}} - \frac{140000 \, {\left(x^{4} + 1\right)}^{2} x^{2}}{9 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{10}{3}}} - \frac{11375000 \, {\left(x^{4} + 1\right)}^{5}}{243 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{16}{3}}} + \frac{4000 \, {\left(x^{4} + 1\right)} x}{3 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{7}{3}}} - \frac{40}{{\left(x^{5} + 5 \, x + 3\right)}^{\frac{4}{3}}} + \frac{105}{32 \, {\left(x - 5\right)}^{\frac{9}{2}}}
latex(derivative(f,x,5));
 x \ {\mapsto}\ -\frac{280000 \, {\left(x^{4} + 1\right)} x^{6}}{9 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{10}{3}}} + \frac{16000 \, x^{5}}{3 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{7}{3}}} + \frac{7000000 \, {\left(x^{4} + 1\right)}^{3} x^{3}}{81 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{13}{3}}} - \frac{140000 \, {\left(x^{4} + 1\right)}^{2} x^{2}}{9 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{10}{3}}} - \frac{11375000 \, {\left(x^{4} + 1\right)}^{5}}{243 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{16}{3}}} + \frac{4000 \, {\left(x^{4} + 1\right)} x}{3 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{7}{3}}} - \frac{40}{{\left(x^{5} + 5 \, x + 3\right)}^{\frac{4}{3}}} + \frac{105}{32 \, {\left(x - 5\right)}^{\frac{9}{2}}} x \ {\mapsto}\ -\frac{280000 \, {\left(x^{4} + 1\right)} x^{6}}{9 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{10}{3}}} + \frac{16000 \, x^{5}}{3 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{7}{3}}} + \frac{7000000 \, {\left(x^{4} + 1\right)}^{3} x^{3}}{81 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{13}{3}}} - \frac{140000 \, {\left(x^{4} + 1\right)}^{2} x^{2}}{9 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{10}{3}}} - \frac{11375000 \, {\left(x^{4} + 1\right)}^{5}}{243 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{16}{3}}} + \frac{4000 \, {\left(x^{4} + 1\right)} x}{3 \, {\left(x^{5} + 5 \, x + 3\right)}^{\frac{7}{3}}} - \frac{40}{{\left(x^{5} + 5 \, x + 3\right)}^{\frac{4}{3}}} + \frac{105}{32 \, {\left(x - 5\right)}^{\frac{9}{2}}}
f = x*(x-1)*(x-2)+1;f;
 (x - 1)*(x - 2)*x + 1 (x - 1)*(x - 2)*x + 1
P=plot(f,(x,0,2));P.show()
f.find_local_maximum(0,1)
 (1.3849001794597504, 0.42264973107517745) (1.3849001794597504, 0.42264973107517745)
P+=point((0.42264973107517745,1.3849001794597504),color='black', pointsize=20, zorder=50);P.show()

Calculus 2:

f = x*(x-1)*(x-2)+1;f
 \newcommand{\Bold}[1]{\mathbf{#1}}{\left(x - 1\right)} {\left(x - 2\right)} x + 1
p = plot(f, 0.5, 1.5, fill=True) + plot(f, 0, 2);p.show()
integrate(f,(x,0.5,1.5));
 \newcommand{\Bold}[1]{\mathbf{#1}}1.0
integrate(x,(x,0,1));
 \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2}
integral(x)
 \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2} \, x^{2}
integral(f)
 \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{4} \, x^{4} - x^{3} + x^{2} + x
integral(arctan(x))
 \newcommand{\Bold}[1]{\mathbf{#1}}x \arctan\left(x\right) - \frac{1}{2} \, \log\left(x^{2} + 1\right)

Some integrals just don't have nice closed form and you'll get some mess that you won't recognize.

integral(sin(x)/x);
 \newcommand{\Bold}[1]{\mathbf{#1}}-\frac{1}{2} i \, {\rm Ei}\left(i \, x\right) + \frac{1}{2} i \, {\rm Ei}\left(-i \, x\right)
Ei?
 File: /usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/functions/exp_integral.py Type: Definition: Ei(coerce=True, hold=False, dont_call_method_on_arg=False, *args) Docstring: The generalized complex exponential integral Ei(z) defined by \operatorname{Ei}(x) = \int_{-\infty}^x \frac{e^t}{t}\; dt for x > 0 and for complex arguments by analytic continuation, see [AS] 5.1.2. EXAMPLES: sage: Ei(10) Ei(10) sage: Ei(I) Ei(I) sage: Ei(3+I) Ei(I + 3) sage: Ei(1.3) 2.72139888023202 sage: Ei(10r) Ei(10) sage: Ei(1.3r) 2.7213988802320235  The branch cut for this function is along the negative real axis: sage: Ei(-3 + 0.1*I) -0.0129379427181693 + 3.13993830250942*I sage: Ei(-3 - 0.1*I) -0.0129379427181693 - 3.13993830250942*I  The precision for the result is deduced from the precision of the input. Convert the input to a higher precision explicitly if a result with higher precision is desired: sage: Ei(RealField(300)(1.1)) 2.16737827956340282358378734233807621497112737591639704719499002090327541763352339357795426  ALGORITHM: Uses mpmath. File: /usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/functions/exp_integral.py Type: Definition: Ei(coerce=True, hold=False, dont_call_method_on_arg=False, *args) Docstring: The generalized complex exponential integral Ei(z) defined by \operatorname{Ei}(x) = \int_{-\infty}^x \frac{e^t}{t}\; dt for x > 0 and for complex arguments by analytic continuation, see [AS] 5.1.2. EXAMPLES: sage: Ei(10) Ei(10) sage: Ei(I) Ei(I) sage: Ei(3+I) Ei(I + 3) sage: Ei(1.3) 2.72139888023202 sage: Ei(10r) Ei(10) sage: Ei(1.3r) 2.7213988802320235  The branch cut for this function is along the negative real axis: sage: Ei(-3 + 0.1*I) -0.0129379427181693 + 3.13993830250942*I sage: Ei(-3 - 0.1*I) -0.0129379427181693 - 3.13993830250942*I  The precision for the result is deduced from the precision of the input. Convert the input to a higher precision explicitly if a result with higher precision is desired: sage: Ei(RealField(300)(1.1)) 2.16737827956340282358378734233807621497112737591639704719499002090327541763352339357795426  ALGORITHM: Uses mpmath.

SAGE can do improper integrals as well.

integrate(1/x,(x,0,1));
 Traceback (click to the left of this block for traceback) ... ValueError: Integral is divergent. Traceback (most recent call last): File "", line 1, in File "_sage_input_141.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("aW50ZWdyYXRlKDEveCwoeCwwLDEpKTs="),globals())+"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in File "/tmp/tmpRSzujK/___code___.py", line 3, in exec compile(u'integrate(_sage_const_1 /x,(x,_sage_const_0 ,_sage_const_1 )); File "", line 1, in File "/usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/misc/functional.py", line 664, in integral return x.integral(*args, **kwds) File "sage/symbolic/expression.pyx", line 11352, in sage.symbolic.expression.Expression.integral (/usr/local/sage-6.10/src/build/cythonized/sage/symbolic/expression.cpp:60289) File "/usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 761, in integrate return definite_integral(expression, v, a, b, hold=hold) File "sage/symbolic/function.pyx", line 988, in sage.symbolic.function.BuiltinFunction.__call__ (/usr/local/sage-6.10/src/build/cythonized/sage/symbolic/function.cpp:11344) File "sage/symbolic/function.pyx", line 503, in sage.symbolic.function.Function.__call__ (/usr/local/sage-6.10/src/build/cythonized/sage/symbolic/function.cpp:7111) File "sage/symbolic/function.pyx", line 1059, in sage.symbolic.function.BuiltinFunction._evalf_or_eval_ (/usr/local/sage-6.10/src/build/cythonized/sage/symbolic/function.cpp:12073) File "/usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 176, in _eval_ return integrator(*args) File "/usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/symbolic/integration/external.py", line 24, in maxima_integrator result = maxima.sr_integral(expression, v, a, b) File "/usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py", line 782, in sr_integral raise ValueError("Integral is divergent.") ValueError: Integral is divergent.
integrate(1/x^3,(x,1,+infinity));
 \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2}

SAGE can quickly calculate Taylor polynomials for you as well.

P5=taylor(sin(x),x,0,5);P5
 \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{120} \, x^{5} - \frac{1}{6} \, x^{3} + x
P15=taylor(sin(x),x,0,15);P15
 \newcommand{\Bold}[1]{\mathbf{#1}}-\frac{1}{1307674368000} \, x^{15} + \frac{1}{6227020800} \, x^{13} - \frac{1}{39916800} \, x^{11} + \frac{1}{362880} \, x^{9} - \frac{1}{5040} \, x^{7} + \frac{1}{120} \, x^{5} - \frac{1}{6} \, x^{3} + x
P50=taylor(sin(x),x,0,50);
P=plot(sin(x),(x,-10*pi,10*pi),color='blue')+plot(P5,(x,-10*pi,10*pi),ymax=2, ymin=-2,color='cyan')+plot(P15,(x,-10*pi,10*pi),ymax=2, ymin=-2,color='pink')+plot(P50,(x,-10*pi,10*pi),color='red');P.show()

Multivariable Calculus: Pretty much the same as calculus. You can do a bunch of the stuff here.  I'll just highlight a couple.

v=vector([1,2,3]);v
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(1,\,2,\,3\right)
w=vector([-1,2,4]);w
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(-1,\,2,\,4\right)
v.cross_product(w)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(2,\,-7,\,4\right)
v.dot_product(w)
 \newcommand{\Bold}[1]{\mathbf{#1}}15
v.norm()
 \newcommand{\Bold}[1]{\mathbf{#1}}\sqrt{14}
var('x,y,z');
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(x, y, z\right)
f(x,y) = sin(x^2 *y);f
 \newcommand{\Bold}[1]{\mathbf{#1}}\left( x, y \right) \ {\mapsto} \ \sin\left(x^{2} y\right)
plot3d(f,(x,-5,5),(y,-5,5));
f(x,y) = 1 + x^2 + y^2;f
 \newcommand{\Bold}[1]{\mathbf{#1}}\left( x, y \right) \ {\mapsto} \ x^{2} + y^{2} + 1
plot3d(f,(x,-2,2), (y,-2,2), color='orange');

We can use SAGE to solve Lagrange multiplier problems.

var('x y t l'); f(x, y) = 8*x^2 - 2*y; g(x, y) = x^2 + y^2 ;
S = solve([diff(f(x, y), x) == l * diff(g(x, y), x), diff(f(x, y), y) == l * diff(g(x, y), y), g(x, y) == 1], [x, y, l], solution_dict = True) S
 \newcommand{\Bold}[1]{\mathbf{#1}}\left[\left\{l : 1, y : -1, x : 0\right\}, \left\{l : -1, y : 1, x : 0\right\}, \left\{l : 8, y : -\frac{1}{8}, x : \frac{3}{8} \, \sqrt{7}\right\}, \left\{l : 8, y : -\frac{1}{8}, x : -\frac{3}{8} \, \sqrt{7}\right\}\right]

We can also plot vector fields.

plot_vector_field((-y,x), (x,-3,3), (y,-3,3), color='red')
plot_vector_field3d((-y,x,z), (x,-3,3), (y,-3,3),(z,-3,3),colors='blue')

Linear Algebra:

A=matrix([[1,2,3],[4,5,6],[7,8,9]]);A
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array}\right)
A.eigenvalues()
 \newcommand{\Bold}[1]{\mathbf{#1}}\left[0, -1.116843969807043?, 16.11684396980705?\right]
B=matrix([[3,0,0],[0,6,0],[0,0,9]]);B
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 3 & 0 & 0 \\ 0 & 6 & 0 \\ 0 & 0 & 9 \end{array}\right)
A*B
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 3 & 12 & 27 \\ 12 & 30 & 54 \\ 21 & 48 & 81 \end{array}\right)
B.eigenvalues()
 \newcommand{\Bold}[1]{\mathbf{#1}}\left[9, 6, 3\right]
B.eigenspaces_right()
 \newcommand{\Bold}[1]{\mathbf{#1}}\left[\left(9, \mathrm{RowSpan}_{\Bold{Q}}\left(\begin{array}{rrr} 0 & 0 & 1 \end{array}\right)\right), \left(6, \mathrm{RowSpan}_{\Bold{Q}}\left(\begin{array}{rrr} 0 & 1 & 0 \end{array}\right)\right), \left(3, \mathrm{RowSpan}_{\Bold{Q}}\left(\begin{array}{rrr} 1 & 0 & 0 \end{array}\right)\right)\right]
A.eigenspaces_right()
 \newcommand{\Bold}[1]{\mathbf{#1}}\left[\left(0, \mathrm{RowSpan}_{\Bold{Q}}\left(\begin{array}{rrr} 1 & -2 & 1 \end{array}\right)\right), \left(-1.116843969807043?, \mathrm{RowSpan}_{\overline{\QQ}}\left(\begin{array}{rrr} 1 & 0.11039450377411963? & -0.7792109924517608? \end{array}\right)\right), \left(16.11684396980705?, \mathrm{RowSpan}_{\overline{\QQ}}\left(\begin{array}{rrr} 1 & 2.264605496225881? & 3.529210992451761? \end{array}\right)\right)\right]
B.nullity()
 \newcommand{\Bold}[1]{\mathbf{#1}}0
C=random_matrix(ZZ,7,7);C
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrrrr} 1 & 1 & 57 & -1 & -1 & -1 & 1 \\ 0 & -1 & -5 & -8 & 13 & -1 & -1 \\ -1 & -4 & -22 & -1 & 0 & 6 & 1 \\ -2 & 1 & -11 & 1 & -1 & 1 & 0 \\ -1 & -1 & 15 & 1 & -1 & 1 & 10 \\ 1 & -4 & 1 & 14 & 1 & 0 & -1 \\ 0 & 0 & 1 & -2 & 1 & 3 & -1 \end{array}\right)
C.rank()
 \newcommand{\Bold}[1]{\mathbf{#1}}7
D=random_matrix(ZZ,10,10);D.rank()
 \newcommand{\Bold}[1]{\mathbf{#1}}10
T=zero_matrix(ZZ,7,7);T
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrrrr} 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \end{array}\right)
E=block_matrix([[C,T],[T,T]]);E
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrrrr|rrrrrrr} 1 & 1 & 57 & -1 & -1 & -1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & -1 & -5 & -8 & 13 & -1 & -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ -1 & -4 & -22 & -1 & 0 & 6 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ -2 & 1 & -11 & 1 & -1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ -1 & -1 & 15 & 1 & -1 & 1 & 10 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & -4 & 1 & 14 & 1 & 0 & -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & -2 & 1 & 3 & -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \end{array}\right)
E.rank()
 \newcommand{\Bold}[1]{\mathbf{#1}}7
E.column_space()
 \newcommand{\Bold}[1]{\mathbf{#1}}\mathrm{RowSpan}_{\Bold{Z}}\left(\begin{array}{rrrr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& 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \end{array}\right)
E.is_invertible()
 \newcommand{\Bold}[1]{\mathbf{#1}}\mathrm{False}
C.det()
 \newcommand{\Bold}[1]{\mathbf{#1}}2032096
C=C.change_ring(QQ);
C.is_invertible()
 \newcommand{\Bold}[1]{\mathbf{#1}}\mathrm{True}
C.inverse()
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrrrr} -\frac{112389}{508024} & -\frac{90465}{1016048} & -\frac{208919}{1016048} & -\frac{137165}{254012} & \frac{82871}{1016048} & \frac{8729}{508024} & \frac{117005}{254012} \\ -\frac{72931}{508024} & -\frac{40343}{1016048} & -\frac{301409}{1016048} & \frac{8929}{254012} & \frac{91249}{1016048} & \frac{3567}{508024} & \frac{124607}{254012} \\ \frac{23769}{1016048} & \frac{5653}{2032096} & \frac{13347}{2032096} & \frac{5637}{508024} & -\frac{6515}{2032096} & \frac{2195}{1016048} & -\frac{3577}{508024} \\ -\frac{15067}{508024} & -\frac{10487}{1016048} & -\frac{70593}{1016048} & \frac{10437}{254012} & \frac{26465}{1016048} & \frac{34751}{508024} & \frac{26227}{254012} \\ -\frac{29057}{1016048} & \frac{133427}{2032096} & -\frac{143659}{2032096} & \frac{13435}{508024} & \frac{69819}{2032096} & \frac{45877}{1016048} & \frac{67809}{508024} \\ -\frac{20579}{508024} & -\frac{32295}{1016048} & -\frac{44257}{1016048} & -\frac{1963}{254012} & \frac{47105}{1016048} & \frac{14151}{508024} & \frac{97407}{254012} \\ -\frac{1489}{22088} & -\frac{277}{44176} & -\frac{2467}{44176} & -\frac{749}{11044} & \frac{5219}{44176} & -\frac{131}{22088} & \frac{777}{11044} \end{array}\right)