go to uw.sagenb.org
You can click evaluate or press [shift]+[enter]
{{{id=129| /// }}} {{{id=125| 2+2 /// 4 }}} {{{id=5| 2*2 /// 4 }}}If you are familiar with Python, Sage does a bit of preparsing to make the syntaxed more "math friendly".
So 2^4 does mean $2^4$.
{{{id=6| 2^3 /// 8 }}} {{{id=126| 2*(4-5)^5-3 /// -5 }}}x is predefined to be a variable
{{{id=7| x^2 /// x^2 }}} {{{id=127| y /// y }}} {{{id=9| y = var('y') /// }}} {{{id=10| x+y /// x + y }}}Even though x is a predefined variable, you can assign objects to it.
But then it's no longer a variable, so be careful.
{{{id=11| x = 2 /// }}} {{{id=12| x+y /// y + 2 }}} {{{id=13| x = var('x') /// }}} {{{id=14| x+y /// x + y }}} {{{id=15| f = x^3+x-2 /// }}} {{{id=130| f /// x^3 + x - 2 }}} {{{id=16| f(x=2) /// 8 }}} {{{id=131| x /// x }}} {{{id=17| g = x*y+y /// }}} {{{id=18| g(y=3) /// 3*x + 3 }}} {{{id=132| plot(f,(-10,10),color = 'purple') ///Python indeces start at 0! (Not 1!)
{{{id=109| l = [i for i in range(10)] l /// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] }}} {{{id=116| len(l) /// 10 }}} {{{id=111| for i in range(10,15): print i /// 10 11 12 13 14 }}} {{{id=134| fac = [(next_prime(10^i)+1).factor() for i in range(10,15)] /// }}} {{{id=112| for i in l: if i%2 == 0: print i else: print 'not even' /// 0 not even 2 not even 4 not even 6 not even 8 not even }}} {{{id=117| m = [i for i in range(10,14)] print m /// [10, 11, 12, 13] }}} {{{id=118| m = [i for i in range(1,15)] /// }}} {{{id=119| m[0], m[-1] /// (1, 14) }}} {{{id=120| m[1],m[-2] /// (2, 13) }}}tab completion
?
??
search_src('stuff to look for')
{{{id=142| /// }}} {{{id=123| search_src('number field') /// }}}Basic examples, $\mathbb{Z}$ and $\mathbb{Q}$
{{{id=143| QQ.zero_element() /// 0 }}} {{{id=144| QQbar.ideal(7) /// Principal ideal (1) of Algebraic Field }}} {{{id=30| ZZ.is_noetherian() /// True }}} {{{id=99| /// }}} {{{id=40| I = ZZ.ideal(18) J = ZZ.ideal(5) I,J,I+J /// (Principal ideal (18) of Integer Ring, Principal ideal (5) of Integer Ring, Principal ideal (1) of Integer Ring) }}} {{{id=37| I.gens(),J.gens(), (I+J).gens() /// ((18,), (5,), (1,)) }}}Everyone's favorite number field:
{{{id=39| x = var('x') F. = NumberField(x^2-x-1) print F OF = F.ring_of_integers() OF.gens() /// Number Field in a with defining polynomial x^2 - x - 1 [1, a] }}} {{{id=149| OF.basis() /// [1, a] }}} {{{id=150| F.gens() /// (a,) }}} {{{id=45| a in OF /// True }}} {{{id=46| a+2 in OF /// True }}} {{{id=47| a/2 in OF /// False }}} {{{id=151| a/2 in F /// True }}} {{{id=48| (a+2).minpoly() /// x^2 - 5*x + 5 }}}Can create and work with ideals as before.
{{{id=54| I = F.ideal(5) print I print I.factor() /// Fractional ideal (5) (Fractional ideal (-2*a + 1))^2 }}} {{{id=55| J = F.ideal(5).factor()[0][0]; J /// Fractional ideal (-2*a + 1) }}} {{{id=152| F.ideal(5).factor()[0] /// (Fractional ideal (-2*a + 1), 2) }}} {{{id=56| F.ideal((7-21*a)*5*(3*a+13)).factor() /// (Fractional ideal (-3*a + 1)) * (Fractional ideal (3*a + 13)) * (Fractional ideal (-2*a + 1))^2 * (Fractional ideal (7)) }}} {{{id=49| K. = QuadraticField(-5) /// }}} {{{id=153| b.minpoly() /// x^2 + 5 }}} {{{id=50| F.class_number() /// 1 }}} {{{id=51| K.class_number() /// 2 }}} {{{id=52| K.ring_of_integers().gens() /// [1, b] }}} {{{id=53| b.is_integral() /// True }}} {{{id=58| L. = NumberField([x^2-2,x^2-x-1]) /// }}} {{{id=61| /// }}} {{{id=103| OL = L.ring_of_integers() /// }}} {{{id=105| O = L.order([1,a,b,a*b]) /// }}} {{{id=104| O == OL /// True }}} {{{id=154| OL.basis() /// [(b + 2)*a - 3*b, a - b, -2*b*a + b + 3, (3*b + 5)*a - 8*b - 1] }}} {{{id=106| alpha = a+3*b /// }}} {{{id=107| mList = [alpha*e for e in O.basis()] mList /// [(6*b + 3)*a - 7*b - 5, 2*b*a - 3*b - 1, (-5*b - 3)*a + 8*b + 3, (16*b + 8)*a - 21*b - 14] }}} {{{id=62| F.gen() /// a }}} {{{id=155| d = F.degree() bas = [F.gen()^i for i in range(d)] bas /// [1, a] }}} {{{id=156| M.First, how one might nievely try. It works, painfully.
{{{id=90| R. = QQ[] print R I = R.ideal([a^2-t, b^2-(t+1)]) print I.gens() /// Multivariate Polynomial Ring in a, b, t over Rational Field [a^2 - t, b^2 - t - 1] }}} {{{id=91| Q. = R.quotient(I); print Q S.Here's how to do this using function fields
{{{id=88| F.