# Things MAT 271 Wanted to Know

## 2292 days ago by kcrisman

### How do I get text in the worksheets?

Answer: Hover over a blue line and Shift-Click!

I like text in my worksheets.

• I like math
• I like things that use math
• I like things that depend on things that use math

### Can I do the Mandelbrot set?

%cython from sage.rings.all import CC def color(z): cdef float x0 = z.real() cdef float y0 = z.imag() cdef float x=0 cdef float y=0 cdef int iteration for iteration from 0<=iteration<1000: if x*x+y*y>4: break x,y=(x*x-y*y+x0, 2*x*y+y0) else: return CC(0,0) return CC(0,iteration)
def color2(z): return color(z)
@interact def _(xmin=-2,xmax=1,ymin=-1.5,ymax=1.5): show(complex_plot(color2, (xmin,xmax), (ymin,ymax),plot_points=200))

## Click to the left again to hide and once more to show the dynamic interactive window

### Can I calculate some values of sin?

sin(63*pi/180).n(digits=100)
 0.8910065241883678623597095714136263127705185190360887454055222845224922\ 741761352243779385827348614778 0.8910065241883678623597095714136263127705185190360887454055222845224922741761352243779385827348614778

### Can I plot in three dimensions?

y = var('y') plot3d(x^2-y^2,(x,-1,1),(y,-1,1))
u, v = var('u,v') fx = (3+sin(v)+cos(u))*cos(2*v) fy = (3+sin(v)+cos(u))*sin(2*v) fz = sin(u)+2*cos(v) parametric_plot3d([fx, fy, fz], (u, 0, 2*pi), (v, 0, 2*pi), frame=False, color="red",plot_points=200)

### Can I solve equations?

solve(x^4-1,x)
 [x == I, x == -1, x == -I, x == 1] [x == I, x == -1, x == -I, x == 1]
var('y') show(solve([cos(x)*sin(x) == 1/2, x+y == 0],x,y))

### Can I do probability?

import scipy.stats binom_dist = scipy.stats.binom(20,.05) bar_chart([binom_dist.pmf(x) for x in range(21)])

### Can I do big numbers?

binomial(factorial(280),3)
 786366295079233259324404162114629898468075100463765296340051103491109718\ 621196388974925508593111294475890165771975335888959705440616413513854939\ 147577661407825679981472775713132230851256038739127928800194812908604088\ 283784987354580619324560569916081582293654826596534710807090389157608993\ 181069587272293029873719496678643634154226431202027586402721439812242938\ 856950136248833624581433545455982010359611768416772604088487794664919845\ 718103990661848563067385461460934237833377836654080119173113961862180049\ 535291794723838449550949307943855385396221205998158798621139714204420177\ 840851338922483147704616992100619047112276685929899636196817597485158373\ 703214227291400194314806553558736310128568982155520070933829919610454441\ 689585103976548560125190211837542729120069648307625496968563502745044916\ 651783903290728524828740240858012116927373551362298041635263164253513584\ 917349801885985157953446451493917206492720620431687922880764501146204817\ 280589739258291683592287973399393791684475969238114595485744562959980316\ 874276739782827025889347801178942241971553680966118686333090339287194809\ 568899458238727667371795913775973667108306145786095388448161031232184933\ 126404307425840392484245540664231360555602410483665561031631273593646868\ 395322415616941435847929633348238438110718663976062375690287961363715492\ 469965627508861268339812263090801095402563064033776375961353973800080505\ 178187236887851105500349735375755757736343945817475675099489929942154000\ 841954491346528785484037553349548772823115911029983634015623960715279147\ 093081246932382225525393576732552544586176240200488525304076605641134724\ 400659112626126403644310032962534493913088000000000000000000000000000000\ 000000000000000000000000000000000000000 786366295079233259324404162114629898468075100463765296340051103491109718621196388974925508593111294475890165771975335888959705440616413513854939147577661407825679981472775713132230851256038739127928800194812908604088283784987354580619324560569916081582293654826596534710807090389157608993181069587272293029873719496678643634154226431202027586402721439812242938856950136248833624581433545455982010359611768416772604088487794664919845718103990661848563067385461460934237833377836654080119173113961862180049535291794723838449550949307943855385396221205998158798621139714204420177840851338922483147704616992100619047112276685929899636196817597485158373703214227291400194314806553558736310128568982155520070933829919610454441689585103976548560125190211837542729120069648307625496968563502745044916651783903290728524828740240858012116927373551362298041635263164253513584917349801885985157953446451493917206492720620431687922880764501146204817280589739258291683592287973399393791684475969238114595485744562959980316874276739782827025889347801178942241971553680966118686333090339287194809568899458238727667371795913775973667108306145786095388448161031232184933126404307425840392484245540664231360555602410483665561031631273593646868395322415616941435847929633348238438110718663976062375690287961363715492469965627508861268339812263090801095402563064033776375961353973800080505178187236887851105500349735375755757736343945817475675099489929942154000841954491346528785484037553349548772823115911029983634015623960715279147093081246932382225525393576732552544586176240200488525304076605641134724400659112626126403644310032962534493913088000000000000000000000000000000000000000000000000000000000000000000000
2800^28000000

### Can I do matrices?

Sure.  There are a few versions of the syntax.

• In the first one, you give a list (in brackets) of the whole thing, and tell Sage how many rows to do.
• In the second one, you give a list of rows, each of which is another list.

This is easiest to see in practice.

matrix(3,[2,3,4,1,2,3]) # 3 rows
 [2 3] [4 1] [2 3] [2 3] [4 1] [2 3]
matrix(2,[2,3,4,1,2,3]) # same data, but 2 rows
 [2 3 4] [1 2 3] [2 3 4] [1 2 3]
matrix([[2,3,4],[1,2,3]]) # notice that all [ and ( must be balanced
 [2 3 4] [1 2 3] [2 3 4] [1 2 3]