Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168696
Image: ubuntu2004

Follow along: http://sagenb.org/pub/

Sage:  A Community Owned

Foundation for Computational Mathematics

 

FoCM 2011 Plenary

William Stein (University of Washington, Seattle)

















Testing, testing, ...

1 + 2 + 3
6



 

A Dream Come True: Community-Owned Knowledge


  • Which do you use more?   Wikipedia or Encyclopædia Britannica?  

  • Which are you more likely to contribute to?

  • The English Wikipedia alone has over 1 billion words, which is over 25 times as many as Encyclopædia Britannica.

 

Sage Project Mission Statement

"Create A Viable Free Open Source Alternative to Magma, Maple, Mathematica, and Matlab"

  • Mathematical features: Of Magma, Maple, Mathematica, and Matlab, with comparable speed

  • Graphics: 2d and 3d

  • Notebook: Interactive graphical user interface

  • Documentation: Books, papers, curriculum, etc.

 

Sage is not a drop-in replacement; it does not run programs written in the custom languages of the Ma's. It's nothing like Octave (versus Matlab).  It's culture, architecture, and feel are all very different than the Ma's. 

Why not Magma, Maple, Matlab, Mathematica?

  1. Commercial: Expensive for my collaborators and students.  Not community owned.

  2. Closed: Implementation of algorithms often secret

  3. Frustrating: Tight control of development

  4. Copy protection: Hard to run on clusters or my new laptop

  5. Programming language: All use a special math-only language

  6. Bugs: Bug tracking is secret

  7. Compiler: Lack of compilers for their math-only languages

  1. Python: a mainstream general purpose programming language (with a compiler: Cython)

  2. Distribution: about 100 open source packages (written by you and your colleagues!)

  3. Interfaces: smoothly tie together all these libraries and packages

  4. New library: implements novel algorithms; well over a half million lines; written by a worldwide community of several hundred people.

Distribution

Hundreds of Sage Developers



History

  • 2005:SAGE-0.1 released February 1, 2005; SAGE=Software for Arithmetic Geometry Experimentation

  • 2006: (2 Sage Days workshops); Sage is not just for number theory

  • 2007: (4 Sage Days) 100% test requirements; peer review of all new code (see trac); industry funding; NSF; Trophees du Libre

  • 2008: (7 Sage Days) Release managers besides me.

  • 2009: (8 Sage Days) Better foundations; 3d graphics; more developers (e.g., sage-combinat)

  • 2010: (13 Sage Days) More devs and users; nontrivial NSF grants

  • 2011: (>= 9 Sage Days) Faster http://sagenb.org; undergrad curriculum development taking off.

See this article for more details about the pre-history of Sage.

Question Break 1 (of 2)

????

Interactive Image Compression

(using numpy

import pylab, numpy X = pylab.imread(DATA + 'focm.png') A_image = numpy.mean(X, 2) u,s,v = numpy.linalg.svd(A_image) S = numpy.zeros(A_image.shape) S[:len(s),:len(s)] = numpy.diag(s) n = A_image.shape[0] @interact def svd_image(i = ("Eigenvalues (quality)", (20,(1..A_image.shape[0]//2)))): A_approx = numpy.dot(numpy.dot(u[:,:i], S[:i,:i]), v[:i,:]) g = graphics_array([matrix_plot(A_approx), matrix_plot(A_image)]) show(g, axes=False, figsize=(8,4)) html("Compressed to %.1f%% of size using %s eigenvalues."%( 100*(2.0*i*n+i)/(n*n), i))

Number Theory

factor(2009201020112012) # uses PARI
2^2 * 43 * 2269 * 5148259709
# Jon Bober - Rademacher's formula time number_of_partitions(10^4)
36167251325636293988820471890953695495016030339315650422081868605887952568754066420592310556052906916435144 Time: CPU 0.00 s, Wall: 0.00 s
@interact def _(n=(25..10000)): plot(prime_pi, 0, n, gridlines='minor').show()
E = EllipticCurve('37a'); E
Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field
v = E.integral_points(both_signs=True); v # mwrank, new code
[(-1 : -1 : 1), (-1 : 0 : 1), (0 : -1 : 1), (0 : 0 : 1), (1 : -1 : 1), (1 : 0 : 1), (2 : -3 : 1), (2 : 2 : 1), (6 : -15 : 1), (6 : 14 : 1)]
plot(E, xmax=7, gridlines=True) + points([z[:2] for z in v], color='red', pointsize=50)
E.change_ring(GF(next_prime(10^50))).cardinality() # pari SEA
100000000000000000000000001917684156174529696959920

Graph Theory

set_random_seed(1) G = graphs.RandomLobster(8, .6, .3) show(G, figsize=7)
G.automorphism_group()
Permutation Group with generators [(12,26)]
G.chromatic_number()
2
G.shortest_path(13,20)
[13, 0, 1, 2, 3, 4, 5, 19, 20]
graph_editor(G)
graphs.
<sage.graphs.graph_generators.GraphGenerators instance at 0x109f54368>

Cython

  • Smooth transition between Python and compiled C code.
  • Make code that involves lots of manipulation of C-level data structures optimally fast (orthogonal to algorithm choice).
  • Very heavily used in scientific computing using Python.
def python_sum2(n): s = int(0) for i in xrange(1, n+1): s += i*i return s
python_sum2(3)
14
python_sum2(2*10^6)
2666668666667000000
timeit('python_sum2(2*10^6)')
5 loops, best of 3: 157 ms per loop
%cython def cython_sum2(long n): cdef long i, s = 0 for i in range(1, n+1): s += i*i return s
cython_sum2(3)
14
cython_sum2(2*10^6)
2666668666667000000
timeit('cython_sum2(2*10^6)')
125 loops, best of 3: 1.82 ms per loop
153/1.88
81.3829787234043
Of course, it is better to choose a different algorithm:
var('k, n') show(factor(sum(k^2, k, 1, n)))
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{6} \, {\left(n + 1\right)} {\left(2 \, n + 1\right)} n
def sum2(n): return n*(2*n+1)*(n+1)/6
sum2(2*10^6)
2666668666667000000
timeit('sum2(2*10^6)')
625 loops, best of 3: 2.28 µs per loop
%cython def c_sum2(long n): return n*(2*n+1)*(n+1)/6
c_sum2(3)
14
timeit('c_sum2(2*10^6)')
625 loops, best of 3: 602 ns per loop
c_sum2(2*10^6) # WARNING: overflow -- it's just like C...
-407788678951258603
n=2*10^6; n*(2*n+1)*(n+1) > 2^63
True

Solving Equations

Solve a cubic equation:

x = var('x'); show(solve(x^3 + x - 1==0, x)[0])
\newcommand{\Bold}[1]{\mathbf{#1}}x = -\frac{1}{2} \, {\left(i \, \sqrt{3} + 1\right)} {\left(\frac{1}{18} \, \sqrt{3} \sqrt{31} + \frac{1}{2}\right)}^{\left(\frac{1}{3}\right)} + \frac{-i \, \sqrt{3} + 1}{6 \, {\left(\frac{1}{18} \, \sqrt{3} \sqrt{31} + \frac{1}{2}\right)}^{\left(\frac{1}{3}\right)}}

Solve a system of two linear equations with one unknown coefficient α\alpha:

var('alpha, y') show(solve([3*x + 7*y == 2, alpha*x + 3*y == 8], x,y)[0])
\newcommand{\Bold}[1]{\mathbf{#1}}\left[x = \frac{50}{7 \, \alpha - 9}, y = \frac{2 \, {\left(\alpha - 12\right)}}{7 \, \alpha - 9}\right]

Solve a system of 500 linear equations exactly over the rational numbers:

n = 500 A = random_matrix(QQ,n,n,num_bound=10, den_bound=10) v = random_matrix(QQ,n,1,num_bound=10, den_bound=10) A.visualize_structure()
# IML is used -- http://www.cs.uwaterloo.ca/~astorjoh/iml.html time w = A.solve_right(v)
Time: CPU 2.09 s, Wall: 1.94 s
print w.str()
WARNING: Output truncated!
[ -351702876068802906437552420686055850326076457904676962275100830127540142095526131918250547265540344687113337535121385535022681546419262541678542779937822420479756487655377896847799471633977576723782073207520130799030819775724029423428556318476349173343755677252009492874198149433287102465125415887341239164981948271409429616954743899492932166187839273830840430242204133808650932888101185375789831810538994617493023740843690694407922374278683391461155140955728290202668993916913435555785505719850338025423229864154969579884279586929569973510779920100244120646553550505898020495083583179450653843216750029252593017958064901402944177967526951565395241248059756160265233192669848180922694279211718585778306380885162305086669108043433115714019399764705656405532372637424988128302930037221573841204291852109644817711181710035826684632372327454388036464817293856186537192905695504317631243147991171291738007709790188771615389151716498998554084032167552344805530360179417770975752951610003948983037774750319911117156732832021727785395392441490730958689252972967675220988730145127436244943789814598859295627758381613978837709335755249693377694808122420315644792522737484105107310982124866738518101800129697107516438736576977941408274379270293509382653911374966642274279158286587422764882484756865601579730895158614205063551061638491473504793910056083034636703628104249909909358743617446014742435439813694562291652176283751189754664295513611806198927659241385326021014632504226786504648620586888456514119837893571119109533967756125159975652399322500232691192061359137595156810713117303327205420957785613280646524680178422545699670542002396011852068784464293242075746389479364313879352013279031866881866550932388974988195825386061018513865229849909312500792251087107364215523707160192682022566179204513802804002649348052390662029135279718239620685711180813331043126149689112528101979192601149093524782042868789861639973589622434060005735985453157614692625120008989748107127816393893047295612770389853217738467738241538454558869964299842463856929563906378781078448435825750440527227707556191692290825726453524350972864386529150895363907965272416969469402617552438862114293776690558921934623925909303675286193416452595298612780914411142216266018732516721256192081722809558262961748724637965800722153538320807583614908367937680580453094035409535396244827250872802838491507467232684489867657561080066542916543081427459267666550278740733523244436200829487939168383811194688142700374028190883369685908216732077/406778287548421232666331161732867083284451766898265331336067813926311992369988856628099086734855735667115529095643017475187509536025110579820674273512710409816506781413949219095421900994613025586328298832520783087510115995249000462483853695254032218916775883778046276732513287003348820832286627339151659920216118602434782892082868740908234817764021744897598451761291562171363826753518869638462172176786920750397046439419756522146331329906325922062334126886845307227747533166221063380004741504866680087220033007960420359539342564917059907398615028523186317797636660999604624165361705540811548027344347944843318379754195828447139714059075956823953574961456072422821379853471265957417978467907648030343371041680488666213418782854500371449004464628137151693278248611405436919105441634514379785943438321498699491374429974941411916188300692918447066207671860293291735706044903379459163329722215462487004764606673950227898048328401073006835733854423499982247502117755480969561242112088131965551967459900917790184504128348366688399796247714348331657116276519708370377748220107893500318506080007877295044619391333807678344042981270732923845847840661087831919093000529797399599904218182992292585508525349195563753868289669013772157736583348697099384043469144344547635488272911439832922066075313432817036914368704456808129124539273223910518127512694139126508695831281678860513712181333729105725904365496018849941845190976573970615503284681408750206307284620020356423014190813611899820786073110923736507592224098870834184189350561093842374187901309709249334375710994985735557672788610080629408146012015171554449734793702597134820310225203084105776449433119524680976123866181969647041370142480229859354877697883210865623491026410955602205911593318386075749335920440095933187160459299339643209960996075895440125644540573643065630406530215220384502737018981682502335606698154233159446864117915813842827734973170373721996301841763236329935471494386783276795049901144295223363777310171682399431489512674283791187221666388715006803961777072989016656984486829254799709389454885066301520728637334573706302170617918018593936439994981310508468063757045909826757786706357829130980704081337842853100001277249846738997785268785823852018104843245188926381179282263086482208903119981671229274976649707235429823900190171387464844391690441164936391687051774383726627139496012306231401783236358878349778653017133170776393229190077739628990310160502280814134853096788081965867629862390376323081486388081447209515623489102340] [ 71261096665143257668658162813232178540279364200282412331110182949961695729619420326309715440293827746251713390662903114352846151161281250441097120169029621264201559926948837404463199725065392914261993758563637265716525976069107384179272777091468494307719490301188556768341390340816156617252353756419127818281645357724613582355543184860894266036241632315995877050056198788230497329665256989181826524968540664880713798787000910728967770589145496803196912017402877174429216398616845433296440873683660849250971849629916655993271828496826232795038918938573116045910787352245863991905838467324633559360554430624817595395913219293755479897335880812139782138804278160670554569961122212400908136488735192680666483344725664521511053801158073421310373130308034512364445006119180576475961863594091165497083388721381453096455530902278590384672749433429129256239417672349696156895982401889862608677052119437357644637225104291460491570315388547606285349023077861754642731395396147714122001657791717438876674684606713884558865151857664117599294425421186338236473525954284813297244776256788990307429793582533758315822389852482364969642131790501926822557594967463572790593437926087684404625778663873834394082223883152404741743301223911129088397625388249055844857299383656476135201070898941726734045537635452236215442384068459897850965386500626001863657763804553423678482599695192944057837796311113705969598918970167771490316260084254566579197725371370404615513394464764040419856844903744306776376464893117420666912682936776973023468566410451441069204781397957003909033198810510400547339572230363816338924666227886503338037720379727395038207464336208666886671133731349867050234600937153017892466402643845629073741624926120645957930774500537957102688612854797095880705125399265851735616177049028737268865920757894719932155963464160432598594917437126156682898070744235398285260476274677283583042221644724748805983275443480729773682890620163526090549881807584412022687257714984446642603687106695040670465420788840440266441899434832132557088303837838676997019945434756578898536498122338059558253662633497162947887448452563564352374794784923454915640125028651130682137951059870731965711620352929234572091755395562745097297150142145693347197839779225002496499973787358575825662518076299762975907067917750786637406902075858335457029962918804981790639912622621725327441804043881077932887578760644677172353210896802045553120040221747735815047265560792085411289595812221132708939135952750960631854645917841141921884756787/813556575096842465332662323465734166568903533796530662672135627852623984739977713256198173469711471334231058191286034950375019072050221159641348547025420819633013562827898438190843801989226051172656597665041566175020231990498000924967707390508064437833551767556092553465026574006697641664573254678303319840432237204869565784165737481816469635528043489795196903522583124342727653507037739276924344353573841500794092878839513044292662659812651844124668253773690614455495066332442126760009483009733360174440066015920840719078685129834119814797230057046372635595273321999209248330723411081623096054688695889686636759508391656894279428118151913647907149922912144845642759706942531914835956935815296060686742083360977332426837565709000742898008929256274303386556497222810873838210883269028759571886876642997398982748859949882823832376601385836894132415343720586583471412089806758918326659444430924974009529213347900455796096656802146013671467708846999964495004235510961939122484224176263931103934919801835580369008256696733376799592495428696663314232553039416740755496440215787000637012160015754590089238782667615356688085962541465847691695681322175663838186001059594799199808436365984585171017050698391127507736579338027544315473166697394198768086938288689095270976545822879665844132150626865634073828737408913616258249078546447821036255025388278253017391662563357721027424362667458211451808730992037699883690381953147941231006569362817500412614569240040712846028381627223799641572146221847473015184448197741668368378701122187684748375802619418498668751421989971471115345577220161258816292024030343108899469587405194269640620450406168211552898866239049361952247732363939294082740284960459718709755395766421731246982052821911204411823186636772151498671840880191866374320918598679286419921992151790880251289081147286131260813060430440769005474037963365004671213396308466318893728235831627685655469946340747443992603683526472659870942988773566553590099802288590446727554620343364798862979025348567582374443332777430013607923554145978033313968973658509599418778909770132603041457274669147412604341235836037187872879989962621016936127514091819653515573412715658261961408162675685706200002554499693477995570537571647704036209686490377852762358564526172964417806239963342458549953299414470859647800380342774929688783380882329872783374103548767453254278992024612462803566472717756699557306034266341552786458380155479257980620321004561628269706193576163931735259724780752646162972776162894419031246978204680] [ -160368478412945774060217542266565614741480339664473882003496792380575289784943072053141554829053293930921857607102015402295709462520818428590597947081758626095111584217558171924149959990476644701661857370387120939161533080399107778728384741444771537907653922319759894925698920371891777353298344299989533341107106083455795918934303490134789381788149001754798357219163777955690624243090780940038394378744275143397662074039674778320791060793269012306741816670290835859282706666942663850625245146784469575887380489922101453134982957742075499004591789195750769348073242033773798477949923643941006395796361486072093633870383782866702158458546676461882498748278944745533497547122031834700319769783250390513841810237819370359022464431560993945921165694696851110031181085277800724768081489399381001096579409475861721879194912363344711398871523122632382536199508988784889511121664982989461247748275493782505705516437124556673236330124644843440717359475895909244905162150877680661132588489739431934491509649514421694064324595796508075639597977267911753289413618179937603437414778980866101466420855502252646305132994695772053544350880301467972535190342552264548626637596538640456639698125168044830077007218921035179691445124822750802413590763916770854032550397882750430506899363811690620437674458177079518594760964045472453277260432501059471358000277224128740628155546846871267522572627083716424935148969530675300287456263163761382833280197051341817671547784446172478777405397645740727692316304905027489628603324136327734105780063644438612194345797356644259989147002965033613516078420616201919717306671583888623882301355687955109440791726834339176839207112932036985722404197924010064653628113454857728315766849988900523564728935734775708582736645678832610674020627036575175920506126245180893499938008508940409206301120662957230203490764480306807870623765188813668626650165413652927518384485750979325936171383262262191357859343934793785783747699127458180847994892687283610594823235273995871136224100720764934278774155992776467311846037633630453882493603407311085883629008582793117780678702334008758518549450449090031726050253937052251803278864703625809836432226005491499478743364915537677681217714272645327756195396244217254600617619844580763415685473113379704415199206135752245256559320142639667436992446660525914733367980482973098699798343578080927082562140380781846246271891778595282906513132447188590580991471165079819069880082887415773781212036573804731437644926508362935501173611761755873866318209749/813556575096842465332662323465734166568903533796530662672135627852623984739977713256198173469711471334231058191286034950375019072050221159641348547025420819633013562827898438190843801989226051172656597665041566175020231990498000924967707390508064437833551767556092553465026574006697641664573254678303319840432237204869565784165737481816469635528043489795196903522583124342727653507037739276924344353573841500794092878839513044292662659812651844124668253773690614455495066332442126760009483009733360174440066015920840719078685129834119814797230057046372635595273321999209248330723411081623096054688695889686636759508391656894279428118151913647907149922912144845642759706942531914835956935815296060686742083360977332426837565709000742898008929256274303386556497222810873838210883269028759571886876642997398982748859949882823832376601385836894132415343720586583471412089806758918326659444430924974009529213347900455796096656802146013671467708846999964495004235510961939122484224176263931103934919801835580369008256696733376799592495428696663314232553039416740755496440215787000637012160015754590089238782667615356688085962541465847691695681322175663838186001059594799199808436365984585171017050698391127507736579338027544315473166697394198768086938288689095270976545822879665844132150626865634073828737408913616258249078546447821036255025388278253017391662563357721027424362667458211451808730992037699883690381953147941231006569362817500412614569240040712846028381627223799641572146221847473015184448197741668368378701122187684748375802619418498668751421989971471115345577220161258816292024030343108899469587405194269640620450406168211552898866239049361952247732363939294082740284960459718709755395766421731246982052821911204411823186636772151498671840880191866374320918598679286419921992151790880251289081147286131260813060430440769005474037963365004671213396308466318893728235831627685655469946340747443992603683526472659870942988773566553590099802288590446727554620343364798862979025348567582374443332777430013607923554145978033313968973658509599418778909770132603041457274669147412604341235836037187872879989962621016936127514091819653515573412715658261961408162675685706200002554499693477995570537571647704036209686490377852762358564526172964417806239963342458549953299414470859647800380342774929688783380882329872783374103548767453254278992024612462803566472717756699557306034266341552786458380155479257980620321004561628269706193576163931735259724780752646162972776162894419031246978204680] [ 670780905754609967862650398220177131177982831134934789266535389879224675773307564662073865692648181233994331697383846839497175338963679798323513187899868079464157734043255602408681967520161201925055301342464903570471904668198180264901434541450940837169885399568778669797277584818744804151520865781157194206457963383958940453038570178726464435502120297975155121858149317360619754079230429560868422017095051303456340847868979957454837223853465437437654331101665463453971428493185955270172827607409888305744587027806884471151602466921702271564609879556828705860943892266695837122690078564177545904879325344663082066414135658896061425931644562780728315670905927070614377744904990994289022401542062368203773561307846567219499395996438129464206420489864647382646396571610758270980794351970912021233545865456886524596773516466835470878718792567580333908554121695311325318702591696054956415626235577721689430069542015257128482768041386152484643086684909751991007395420172135538285912319239017008565968032526765724608123929851299 ... 928314429244369494603036889639548333673675740224437536949675160523883699733750284397994294223069115444032251763258404806068621779893917481038853928124090081233642310579773247809872390449546472787858816548056992091943741951079153284346249396410564382240882364637327354430299734368176038373274864183719735857283984398430358176050257816229457226252162612086088153801094807592673000934242679261693263778745647166325537131093989268149488798520736705294531974188597754713310718019960457718089345510924068672959772595805069713516474888666555486002721584710829195606662793794731701919883755781954026520608291454933829482520868247167207437574575997992524203387225502818363930703114682543131652392281632535137141240000510899938695599114107514329540807241937298075570552471712905234592883561247992668491709990659882894171929560076068554985937756676176465974556674820709753490650855798404922492560713294543551339911461206853268310557291676031095851596124064200912325653941238715232786347051944956150529232594555232578883806249395640936] [ 945260438484163563044816553270592918001394751912601774911825365496702101869516492466616395590211147173762603314811628294546497345263839563666415583095090067032994069691334912003870897476485026314210361234918632939627113750449192588841359026968866079516989072845040071940793991295151325555378155861981887132570589489287106795044073018125006894041466829840435185554095249086105918270373351244069950304821688160848574794292595412083193782255633569430951497593694134968328311112412111626673937106082001550878189006390542393132340296934604234894704844140553852953769601316024676680918627892453987630419620020497064502598327996829810101649304391646190740797656277617083226079919395211544210888444042385829536994393210450651199728670394153493355137383333993363189657749125373009649962059304497351975563946123204314316576218152264789694619954476090375233361538701533649288116764115532254010558548901149494658657504048591644907239559563758928695118666640796415414777980825494750146503022200282376165485639543051257724778421157118490532187380404634254768989064965878170952631359925451301370623771401054377000604587293230405831288638233961825316508199469981546355528511040796390360589193272004060090801171319387281223700624649553757262338223923345889066439761405289990288428639070654876921929568265462002905768632303202778273065462907624324570343872094765158455209524374765324336530325375866974450465948376270177533291727397356838285622914531657541338612055138174753528355821001604691566163573615831527923914531595903687486584099485877470410018067517554997896868834157780642327548164523905313595745654569524691995670963596443444258027097524653552645917906701767500506143166159568497263134244759938183252565345294474154600776120953534094860058553868504396439566981898063636746218198732319710801586401659041709051749207853320770698143933357673936552557367359279288126574362896160724072947728043556896394907309356716909208924749626242048197726284571299226330550247095469436831654022026719371425964531044734433290481019910059532907619013194384163144094845729069342567803937185325801377563775644505083555319782084434941824586972864807839554277117559681492762524089402439947751920848126754469881251759962560522859110189200270636661740491889398071797735958772710053573297443175261338656116565852050642004020743136552986786830586614578587320048479176856369922262578475480783237925833497937251244233283694508981977343884896964120786817533130298359915273484212275453501089851844417605157177929842231947390251620333/406778287548421232666331161732867083284451766898265331336067813926311992369988856628099086734855735667115529095643017475187509536025110579820674273512710409816506781413949219095421900994613025586328298832520783087510115995249000462483853695254032218916775883778046276732513287003348820832286627339151659920216118602434782892082868740908234817764021744897598451761291562171363826753518869638462172176786920750397046439419756522146331329906325922062334126886845307227747533166221063380004741504866680087220033007960420359539342564917059907398615028523186317797636660999604624165361705540811548027344347944843318379754195828447139714059075956823953574961456072422821379853471265957417978467907648030343371041680488666213418782854500371449004464628137151693278248611405436919105441634514379785943438321498699491374429974941411916188300692918447066207671860293291735706044903379459163329722215462487004764606673950227898048328401073006835733854423499982247502117755480969561242112088131965551967459900917790184504128348366688399796247714348331657116276519708370377748220107893500318506080007877295044619391333807678344042981270732923845847840661087831919093000529797399599904218182992292585508525349195563753868289669013772157736583348697099384043469144344547635488272911439832922066075313432817036914368704456808129124539273223910518127512694139126508695831281678860513712181333729105725904365496018849941845190976573970615503284681408750206307284620020356423014190813611899820786073110923736507592224098870834184189350561093842374187901309709249334375710994985735557672788610080629408146012015171554449734793702597134820310225203084105776449433119524680976123866181969647041370142480229859354877697883210865623491026410955602205911593318386075749335920440095933187160459299339643209960996075895440125644540573643065630406530215220384502737018981682502335606698154233159446864117915813842827734973170373721996301841763236329935471494386783276795049901144295223363777310171682399431489512674283791187221666388715006803961777072989016656984486829254799709389454885066301520728637334573706302170617918018593936439994981310508468063757045909826757786706357829130980704081337842853100001277249846738997785268785823852018104843245188926381179282263086482208903119981671229274976649707235429823900190171387464844391690441164936391687051774383726627139496012306231401783236358878349778653017133170776393229190077739628990310160502280814134853096788081965867629862390376323081486388081447209515623489102340] [ -358669728503033965955046155185932503931883887379872277455118210909083910254386318143853434768979832723549374539655035486287332528493716123204745893692383498832669526276786683673904466835238639111088489501764730667623702309564454401524664751962733297767756605046843810323282157342929200103920561874440525477251448694426475910906183363714801162688648567335403604919306230696926882577929210556910121365156244335925007234747417158732119181576748955003656031315033939093045533552754366877253024275739836582994296438228735310225687885278263039248688556077564643767517982473448420357984617974602745319923721806502352817676428835210626041095041734222183170303483420251965030769896190208542328632059559453213241348772132134549531895343197550427800366651064387349790717313637250573233398872198367767305295605199794826409807429614725189991883347980227928648581553485969294746060266480342002929419022471021492334789007101452134820262221327986827987140951621494784318179324074936945809504651484175647749810818574041046595389734807049926345085452602202495438270813565238225424537383086557558600224205290612814923663677037807470148872131015934686634473433295002914172318504192997580817878689368136443866464498705094242183375719200623212808829793591695768014573181159527956973914106685103790783006656091515892720470980684760153787067511421381557188030604358243681050112120262571883700854830653937068812916727205063269066865426830426904725752660087749124636974478378476186271582986987960882649998017980091353322415899683597318914629576909708090027040130438756995162342242460534844728261881102222892659751843527102638515452202500931719814414012919016714886649180935485401425937962683182259880954308659482380558744432162687339111706757814070105172386748842634326219715775441906177809841217172274961913302352783648798965584644483165038286859822860523058893268264305557294565373133526881255668457900027337630727918199156288155894459066363732549980163605448331717010590559332428229989478346966992548153505364195296707498890926568747883424771896925615428218039677903568278431217963254424260294339880029899143539042133908188545883190015389767352097922328789815889634728782118044120593851265268406258913236600002879915013168902752334850484291447438752544708294311652150661754967997446326566290375718815961511556596354983345627682097287229943600353589533260214906973525693290967337231477300997837442444005683040302147427806569828438714089672217900345012788326328335017573022213821202871617596056917140884160335108012469/813556575096842465332662323465734166568903533796530662672135627852623984739977713256198173469711471334231058191286034950375019072050221159641348547025420819633013562827898438190843801989226051172656597665041566175020231990498000924967707390508064437833551767556092553465026574006697641664573254678303319840432237204869565784165737481816469635528043489795196903522583124342727653507037739276924344353573841500794092878839513044292662659812651844124668253773690614455495066332442126760009483009733360174440066015920840719078685129834119814797230057046372635595273321999209248330723411081623096054688695889686636759508391656894279428118151913647907149922912144845642759706942531914835956935815296060686742083360977332426837565709000742898008929256274303386556497222810873838210883269028759571886876642997398982748859949882823832376601385836894132415343720586583471412089806758918326659444430924974009529213347900455796096656802146013671467708846999964495004235510961939122484224176263931103934919801835580369008256696733376799592495428696663314232553039416740755496440215787000637012160015754590089238782667615356688085962541465847691695681322175663838186001059594799199808436365984585171017050698391127507736579338027544315473166697394198768086938288689095270976545822879665844132150626865634073828737408913616258249078546447821036255025388278253017391662563357721027424362667458211451808730992037699883690381953147941231006569362817500412614569240040712846028381627223799641572146221847473015184448197741668368378701122187684748375802619418498668751421989971471115345577220161258816292024030343108899469587405194269640620450406168211552898866239049361952247732363939294082740284960459718709755395766421731246982052821911204411823186636772151498671840880191866374320918598679286419921992151790880251289081147286131260813060430440769005474037963365004671213396308466318893728235831627685655469946340747443992603683526472659870942988773566553590099802288590446727554620343364798862979025348567582374443332777430013607923554145978033313968973658509599418778909770132603041457274669147412604341235836037187872879989962621016936127514091819653515573412715658261961408162675685706200002554499693477995570537571647704036209686490377852762358564526172964417806239963342458549953299414470859647800380342774929688783380882329872783374103548767453254278992024612462803566472717756699557306034266341552786458380155479257980620321004561628269706193576163931735259724780752646162972776162894419031246978204680] [ 94845608333097133173401888178176458058832090978630604413922484212836628856606299168225592655383516946510320600786952561285584383672535782370444557928845542502800318016033743491602294306312049277866092796960805826013736829825775518426269648187883363421136852966085215421910247612201575741848139194292482051768721430018527906012269426488046758265747513494798641566802199827783229808348585230164912908128805544164279980141002798873299232313266181661270328019533635992923810686456150235396730932129375230466804467871481290704951816259796110040716930836486219583991994588336766319125808902170852173227591600459058775457997712880519539397066463308016247590116941852125967316575867074982416259646479821673341594414125367529471312245190727413975078825223112367837976434085495114687857050066610252083336737515050272209950369811875931985129459706060254484842370489024373355567653887976290504101064692469124926023290781715520535875387470931683441759534773491053101786808259343647755603278279938041928352841299637769724250061850371711697787714995062371020928486039555331072415692774208121422221288799894254156260975960627977637937664775325312194035175587094218978067022902303201317200546213304055596547273229543258328466136934551237036580051114195023626655937621557653896328644550310236669514712423764690397004384388419162642901597507898983470661842720515800673527477104236906480601610644925093160066953220006986065422049226212008252162020833988571878693620796925623704138261382316135011911942945909150227142087963748646415195807484336944765521070550962312638973564387487948839566176454971246168530810949502352518642572093583028226823818381773174139115143867987052212309115403011542565072220391630425274684713659728556538800193064808839182079147256993832713170403686970379758369998500557657108150892066393499804483707480335791460002301158524085107299551026142062002471185782037096417724527835627158594419473980665155330636050397092879438893520526866531369671015628647982314388141504753903911512625844651416959849823644449810616899404264026786969883941962862316318139956294868954158941737486232839221595049477801107679372168915288975095394927862912695483022350031666986962394011941027440468622670018481678907544041525829125922749496595577288463732270361803614110187194613630325563894603895653028659842554757675429788048709764909166842506531697578529691272393821106179926353716178985129634627039662019030317498068636227419987061196612738040762439867035389965115976196278333457010123362614934679690155154701/406778287548421232666331161732867083284451766898265331336067813926311992369988856628099086734855735667115529095643017475187509536025110579820674273512710409816506781413949219095421900994613025586328298832520783087510115995249000462483853695254032218916775883778046276732513287003348820832286627339151659920216118602434782892082868740908234817764021744897598451761291562171363826753518869638462172176786920750397046439419756522146331329906325922062334126886845307227747533166221063380004741504866680087220033007960420359539342564917059907398615028523186317797636660999604624165361705540811548027344347944843318379754195828447139714059075956823953574961456072422821379853471265957417978467907648030343371041680488666213418782854500371449004464628137151693278248611405436919105441634514379785943438321498699491374429974941411916188300692918447066207671860293291735706044903379459163329722215462487004764606673950227898048328401073006835733854423499982247502117755480969561242112088131965551967459900917790184504128348366688399796247714348331657116276519708370377748220107893500318506080007877295044619391333807678344042981270732923845847840661087831919093000529797399599904218182992292585508525349195563753868289669013772157736583348697099384043469144344547635488272911439832922066075313432817036914368704456808129124539273223910518127512694139126508695831281678860513712181333729105725904365496018849941845190976573970615503284681408750206307284620020356423014190813611899820786073110923736507592224098870834184189350561093842374187901309709249334375710994985735557672788610080629408146012015171554449734793702597134820310225203084105776449433119524680976123866181969647041370142480229859354877697883210865623491026410955602205911593318386075749335920440095933187160459299339643209960996075895440125644540573643065630406530215220384502737018981682502335606698154233159446864117915813842827734973170373721996301841763236329935471494386783276795049901144295223363777310171682399431489512674283791187221666388715006803961777072989016656984486829254799709389454885066301520728637334573706302170617918018593936439994981310508468063757045909826757786706357829130980704081337842853100001277249846738997785268785823852018104843245188926381179282263086482208903119981671229274976649707235429823900190171387464844391690441164936391687051774383726627139496012306231401783236358878349778653017133170776393229190077739628990310160502280814134853096788081965867629862390376323081486388081447209515623489102340]

Symbolic Calculus

Symbolic Calculus makes use of Maxima and Ginac under the hood.

var('x') f = sqrt(1 - x^2) plot(f, thickness=3, color='red', aspect_ratio=1, fill=True)
var('t') assume(t+1 > 0) g = integrate(f, (x, -1, t)); show(g)
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{4} \, \pi + \frac{1}{2} \, \sqrt{-t^{2} + 1} t + \frac{1}{2} \, \arcsin\left(t\right)
show(g(t=1) - g(t=-1))
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2} \, \pi

Plotting in 2D

plot(sin(1/x^2), (x,.1,.5))
G = sum(circle((random(), random()), random()/3, color=hue(random())) for i in range(25)) G.show(aspect_ratio=1, frame=True)

Plotting in 3D

f(x,y) = sin(x - y) * y * cos(x) plot3d(f, (x,-3,3), (y,-3,3), opacity=.9, color='red')
G = sum(sphere((random(), random(), random()), random()/4, color=hue(random()), opacity=.6) for i in range(20)) G.show(aspect_ratio=1, frame=True)
# Yoda! (53,756 vertices) from scipy import io yoda = io.loadmat(DATA + 'yodapose.mat') from sage.plot.plot3d.index_face_set import IndexFaceSet V = yoda['V']; F3=yoda['F3']-1; F4=yoda['F4']-1 Y = IndexFaceSet(F3,V,color=Color('#444444')) + IndexFaceSet(F4,V,color=Color('#007700')) Y = Y.rotateX(-1) Y.show(aspect_ratio=1, frame=False, zoom=1.2)

Question Break 2 (of 2)

????