{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Annonce\n", "La branche étudiante de l'IEEE propose, ce jeudi 25 février de 13 h 30 à 17 h 30, une formation à Mathematica pour donner les bases de ce logiciel. L'inscription est nécessaire.\n", "http://ieee.aees.be/fr/accueil/25-francais/activites/conferences/151-formation-mathematica" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Initialisation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Pour que la division soit comme en Python 3:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from __future__ import division" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Importer toutes les fonctions et quelques variables de Sympy:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from sympy import *\n", "from sympy.abc import a,b,c,k,n,t,u,v,w,x,y,z\n", "init_printing(pretty_print=True, use_latex='mathjax')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Plusieurs choses ne sont pas dans les notes de cours" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculer le pgcd de $$p(x)=x^5 - 20x^4 + 140x^3 - 430x^2 + 579x - 270$$ et $$q(x)=x^6 - 25x^5 + 243x^4 - 1163x^3 + 2852x^2 - 3348x + 1440$$" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], "source": [ "p = x**5 - 20*x**4 + 140*x**3 - 430*x**2 + 579*x - 270\n", "q = x**6 - 25*x**5 + 243*x**4 - 1163*x**3 + 2852*x**2 - 3348*x + 1440" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$2$$" ], "text/plain": [ "2" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gcd(4,6)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$x^{4} - 11 x^{3} + 41 x^{2} - 61 x + 30$$" ], "text/plain": [ " 4 3 2 \n", "x - 11⋅x + 41⋅x - 61⋅x + 30" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gcd(p,q)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 7 Calcul différentiel et intégral" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 7.1 Limites" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from sympy.abc import x" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "limit(1/x, x, 0, dir='+')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "oo" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "limit(1/x, x, oo)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 7.2 Sommes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculer la somme des nombres 134,245,325,412,57." ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$1173$$" ], "text/plain": [ "1173" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sum([134, 245, 325, 412, 57])" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$x + 1173$$" ], "text/plain": [ "x + 1173" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sum([134, 245, 325, 412, 57, x])" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "ename": "TypeError", "evalue": "unsupported operand type(s) for +: 'Add' and 'list'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m134\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m245\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m325\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m412\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m57\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'Add' and 'list'" ] } ], "source": [ "sum([134, 245, 325, 412, 57, x, []])" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Caluler la somme \n", "$$\\sum_{i=0}^n i$$" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{n^{2}}{2} + \\frac{n}{2}$$" ], "text/plain": [ " 2 \n", "n n\n", "── + ─\n", "2 2" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from sympy.abc import i\n", "summation(i, (i,0,n))" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$2733212496$$" ], "text/plain": [ "2733212496" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "summation(i**2, (i,0,2016))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculer la somme \n", "$$\\sum_{k=1}^\\infty {1 \\over k^6}$$" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{\\pi^{6}}{945}$$" ], "text/plain": [ " 6\n", " π \n", "───\n", "945" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "summation(1/k**6, (k, 1, oo))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 7.3 Produit" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculer le produit \n", "$$\\prod_{n=1}^{2016} 2n+1$$" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$8868169326519690749916346923947655056485312237838739648241772231965162628093269499861910784452591061014430955912255189498073213940814331266176188364591926426070508871165254457859565586232524705699185609047788562381145568750910753228948567801351561868323366323452074205042649918222402205940414662437823614838957989530490151204746525246869495640288645650461944177046293564842754663795155020445912565051583499175836977215497725547651618402095088774966971369261469093626958486424060684083098525097770124941776909671023220789779362207308465721201881343561241295602137569990257711658275155986974067284162093944333211269019750980841578510758831440006143755585767024067141912296999922161006801048983751003585977722909963368292440608434616997931271635073573781029235336643382614341542164644141344176697410614218306305948653800591923230304574498199224742542023279626438989450369141911263150337976710409414188536078453665238082129024790286193490510403594154979960421291692881925375690437241661455710503213154231081238139187387691150065889950850364369713486130897172852040327299713168196650136701637915083611083235626132722941102386496905288227533004127250399699896697612481690347483756170191619230464185528973752058981749669359315584478044860942906420071324996148353834714079080120477042786314575357557841495303417439076813969702181842312813397251377534302269021259401425803956350638781968981320112594947691293276137315290235737349392231207929797010279995857967049643614680773866981551810273447362536818494420661933773419436582636932662297192944345546127636491167324183635975717018293826093759939318374659537756000218419039404239192518142704414899646162294172907458511567017005287060020347111180514655691127446052457625355935097582389033283920296291541885067614185713360386071824575870876316997492208001451781115569251443443201992111530146648492993595442690082429090699054308398625220265797872641395019086792274861371579690851375908077121782341959163903021493148364206552426546058671889307256603925761307492831779541859544697723557644829603886822669897225969343359445245314914686813814563594521419514617361279244650717632811193677366796042858050849732679481661565005931399405128903121922920510185768123774231091173713268857634497611523459593104714394884543986656436113256338417772498936630507589129352460091175905158706384986015184025134723511439664618867418364309771320785678134474192947293083439468539871513963596475857769221507478012531861534736812017153221534999942095280716121221550315834844118243191092024630454674268453416805609769873534738233208493562956443587541923643021456346913790768900439230891366954474911123378567628767446009686347683585946818162311479014722668273312780199347217464655259283471708669308345783026934623186393413030472119912740205038353184011698377949948706605171257201989592588039520402603885497560173020064957639215291596163949169686294973519052439104394301720872071488430112429106871908951070705829746247792247542688439879531639710931489716690372137736768592304813796481238024712322226165048562989424647510215588316574202394650365741975111841211625628863443942751783458927987548987690484953760604668221693173442950097465751866017874523516413979329851003324304892027135008044225451368589556785403709319835816600489403145123552161280899325308402361634323029723819644194849080316849261463596800829277881556290273257304407998152661517253801369466311658469803287259145496686022062549676396488159103124682203145230410496006647370811417051218346791121355219820842472402599011899085486954769310234300317342030759879312872644644109391638142984482664248924032729947827287402288275588266221140908604477965187564365542602394297877054935390961737629849953149182570703384198842670196154234838754481335327589157369766811918606372712466315774408082474137114687077232987077392110693801704544605205157034774314584295901350882766088757679467716247769051574645820982576952291979411771530126866646168004684351354726627982532169353583493798362199129087146068948763714213415353569636926757132330513609806542890186960130715536231207843080324783147944371914900172644875443344317742437966973762827088952511411382210334884180906599356893702821848814138030183609452833211079573890188145067664748271091656613981494522003553171808873117847166768803885536219902592518362898697842893736540075739050727556466316530318096917478144480994616755148490388407182821205615672463890929501051320930188863366169990283083511580266137347869307085904829360615503066083706984458759478578490573496463132983501116023835632141557724277215668328720569828110239197289585864644383717012027982928485292862639814400629739854784763903171165978181904701405060494812248362317018254392292093087384428327481660345653697008020991588902823377076664936726775996206213390397312813989845566743750703542365276548916010776627300674977450439993702948507697091127348041477733445575991008807317947159547924152162523313253066324992829482303547404986063420010491808988780540368780059039169949394123596601715078230248532248489929256362683500660750030751113135737315987282799379887514627422994414913672910416284860178308413081410377078914867432800465816939108490261648187640420044710995984825340240396683561964395184559015148925331100494931828510082245801714268323523328924830032619728704824991306838682238357790425028963907695145695965908730381600424368612696524736110269181044095720009940885017936957162525081892663309557453472936867629739938292991728227863410832797975852035284186107469278301034360314468392538065947736353526379312805091851232659355837321260628282652100551281358918077189927803631296823507251101127384024140054506903700999298858279445880574252957748425475405076367405070791118441808568033458015177042581076897889707944973507020756443266957446936429550137789111139205789029421770984433633343577706679129315415351404519389712439289932538716652094489421871644148496452156332098932345698264309700790151003171351184574996671287636492636017153233624074280689530070529711047651333413664100299667353960634472125857025678355480178834210932542237143273035738058631284611446592969900752990452248115051800202758918628949021763754089397106215519480600732525763068083353519718691928033432059442193958871218407541522424953345925482155043895248137951122586303160336124157390922189229663216882968285397078039827386315161742836151144685429692241155684573433451550462841114431377116657432376983296549514111141443439834119999432004988193511962890625$$" ], "text/plain": [ "886816932651969074991634692394765505648531223783873964824177223196516262809326\n", "949986191078445259106101443095591225518949807321394081433126617618836459192642\n", "607050887116525445785956558623252470569918560904778856238114556875091075322894\n", "856780135156186832336632345207420504264991822240220594041466243782361483895798\n", "953049015120474652524686949564028864565046194417704629356484275466379515502044\n", "591256505158349917583697721549772554765161840209508877496697136926146909362695\n", "848642406068408309852509777012494177690967102322078977936220730846572120188134\n", "356124129560213756999025771165827515598697406728416209394433321126901975098084\n", "157851075883144000614375558576702406714191229699992216100680104898375100358597\n", "772290996336829244060843461699793127163507357378102923533664338261434154216464\n", "414134417669741061421830630594865380059192323030457449819922474254202327962643\n", "898945036914191126315033797671040941418853607845366523808212902479028619349051\n", "040359415497996042129169288192537569043724166145571050321315423108123813918738\n", "769115006588995085036436971348613089717285204032729971316819665013670163791508\n", "361108323562613272294110238649690528822753300412725039969989669761248169034748\n", "375617019161923046418552897375205898174966935931558447804486094290642007132499\n", "614835383471407908012047704278631457535755784149530341743907681396970218184231\n", "281339725137753430226902125940142580395635063878196898132011259494769129327613\n", "731529023573734939223120792979701027999585796704964361468077386698155181027344\n", "736253681849442066193377341943658263693266229719294434554612763649116732418363\n", "597571701829382609375993931837465953775600021841903940423919251814270441489964\n", "616229417290745851156701700528706002034711118051465569112744605245762535593509\n", "758238903328392029629154188506761418571336038607182457587087631699749220800145\n", "178111556925144344320199211153014664849299359544269008242909069905430839862522\n", "026579787264139501908679227486137157969085137590807712178234195916390302149314\n", "836420655242654605867188930725660392576130749283177954185954469772355764482960\n", "388682266989722596934335944524531491468681381456359452141951461736127924465071\n", "763281119367736679604285805084973267948166156500593139940512890312192292051018\n", "576812377423109117371326885763449761152345959310471439488454398665643611325633\n", "841777249893663050758912935246009117590515870638498601518402513472351143966461\n", "886741836430977132078567813447419294729308343946853987151396359647585776922150\n", "747801253186153473681201715322153499994209528071612122155031583484411824319109\n", "202463045467426845341680560976987353473823320849356295644358754192364302145634\n", "691379076890043923089136695447491112337856762876744600968634768358594681816231\n", "147901472266827331278019934721746465525928347170866930834578302693462318639341\n", "303047211991274020503835318401169837794994870660517125720198959258803952040260\n", "388549756017302006495763921529159616394916968629497351905243910439430172087207\n", "148843011242910687190895107070582974624779224754268843987953163971093148971669\n", "037213773676859230481379648123802471232222616504856298942464751021558831657420\n", "239465036574197511184121162562886344394275178345892798754898769048495376060466\n", "822169317344295009746575186601787452351641397932985100332430489202713500804422\n", "545136858955678540370931983581660048940314512355216128089932530840236163432302\n", "972381964419484908031684926146359680082927788155629027325730440799815266151725\n", "380136946631165846980328725914549668602206254967639648815910312468220314523041\n", "049600664737081141705121834679112135521982084247240259901189908548695476931023\n", "430031734203075987931287264464410939163814298448266424892403272994782728740228\n", "827558826622114090860447796518756436554260239429787705493539096173762984995314\n", "918257070338419884267019615423483875448133532758915736976681191860637271246631\n", "577440808247413711468707723298707739211069380170454460520515703477431458429590\n", "135088276608875767946771624776905157464582098257695229197941177153012686664616\n", "800468435135472662798253216935358349379836219912908714606894876371421341535356\n", "963692675713233051360980654289018696013071553623120784308032478314794437191490\n", "017264487544334431774243796697376282708895251141138221033488418090659935689370\n", "282184881413803018360945283321107957389018814506766474827109165661398149452200\n", "355317180887311784716676880388553621990259251836289869784289373654007573905072\n", "755646631653031809691747814448099461675514849038840718282120561567246389092950\n", "105132093018886336616999028308351158026613734786930708590482936061550306608370\n", "698445875947857849057349646313298350111602383563214155772427721566832872056982\n", "811023919728958586464438371701202798292848529286263981440062973985478476390317\n", "116597818190470140506049481224836231701825439229209308738442832748166034565369\n", "700802099158890282337707666493672677599620621339039731281398984556674375070354\n", "236527654891601077662730067497745043999370294850769709112734804147773344557599\n", "100880731794715954792415216252331325306632499282948230354740498606342001049180\n", "898878054036878005903916994939412359660171507823024853224848992925636268350066\n", "075003075111313573731598728279937988751462742299441491367291041628486017830841\n", "308141037707891486743280046581693910849026164818764042004471099598482534024039\n", "668356196439518455901514892533110049493182851008224580171426832352332892483003\n", "261972870482499130683868223835779042502896390769514569596590873038160042436861\n", "269652473611026918104409572000994088501793695716252508189266330955745347293686\n", "762973993829299172822786341083279797585203528418610746927830103436031446839253\n", "806594773635352637931280509185123265935583732126062828265210055128135891807718\n", "992780363129682350725110112738402414005450690370099929885827944588057425295774\n", "842547540507636740507079111844180856803345801517704258107689788970794497350702\n", "075644326695744693642955013778911113920578902942177098443363334357770667912931\n", "541535140451938971243928993253871665209448942187164414849645215633209893234569\n", "826430970079015100317135118457499667128763649263601715323362407428068953007052\n", "971104765133341366410029966735396063447212585702567835548017883421093254223714\n", "327303573805863128461144659296990075299045224811505180020275891862894902176375\n", "408939710621551948060073252576306808335351971869192803343205944219395887121840\n", "754152242495334592548215504389524813795112258630316033612415739092218922966321\n", "688296828539707803982738631516174283615114468542969224115568457343345155046284\n", "111443137711665743237698329654951411114144343983411999943200498819351196289062\n", "5" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "product(2*n+1, (n,1,2016))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 7.4 Calcul différentiel" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Calculer la dérivée de $$x^5+bx$$" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left ( b, \\quad x\\right )$$" ], "text/plain": [ "(b, x)" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b,x" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$x$$" ], "text/plain": [ "x" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "diff(x**5+b*x, b)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$b + 5 x^{4}$$" ], "text/plain": [ " 4\n", "b + 5⋅x " ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "diff(x**5+b*x, x)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Calculer la dérivée de $$\\arcsin(x)$$" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{1}{\\sqrt{- x^{2} + 1}}$$" ], "text/plain": [ " 1 \n", "─────────────\n", " __________\n", " ╱ 2 \n", "╲╱ - x + 1 " ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "diff(asin(x), x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 7.5 Calcul intégral" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Calculer l'intégrale $$\\int\\log(x)\\, dx$$" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$x \\log{\\left (x \\right )} - x$$" ], "text/plain": [ "x⋅log(x) - x" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "integrate(log(x), x)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Calculer l'intégrale $$\\int a^x\\, dx$$" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\begin{cases} x & \\text{for}\\: \\log{\\left (a \\right )} = 0 \\\\\\frac{a^{x}}{\\log{\\left (a \\right )}} & \\text{otherwise} \\end{cases}$$" ], "text/plain": [ "⎧ x for log(a) = 0\n", "⎪ \n", "⎪ x \n", "⎨ a \n", "⎪────── otherwise \n", "⎪log(a) \n", "⎩ " ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "integrate(a**x, x)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Calculer l'intégrale $$\\int x^a\\, dx$$" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\begin{cases} \\log{\\left (x \\right )} & \\text{for}\\: a = -1 \\\\\\frac{x^{a + 1}}{a + 1} & \\text{otherwise} \\end{cases}$$" ], "text/plain": [ "⎧log(x) for a = -1\n", "⎪ \n", "⎪ a + 1 \n", "⎨x \n", "⎪────── otherwise \n", "⎪a + 1 \n", "⎩ " ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "integrate(x**a, x)" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$2$$" ], "text/plain": [ "2" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "log(100, 10)" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "collapsed": true }, "outputs": [], "source": [ "log?" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Calculer l'intégrale \n", "$$\\int \\sec^2(x)\\,dx$$" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{\\sin{\\left (x \\right )}}{\\cos{\\left (x \\right )}}$$" ], "text/plain": [ "sin(x)\n", "──────\n", "cos(x)" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "integrate(sec(x)**2, x)" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{x^{3} y^{2}}{6}$$" ], "text/plain": [ " 3 2\n", "x ⋅y \n", "─────\n", " 6 " ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "integrate(integrate(x**2*y, x), y)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$\\int_0^5\\int_0^2 x^2y\\,dx\\,dy$$" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{100}{3}$$" ], "text/plain": [ "100/3" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "integrate(x**2*y, (x,0,2), (y,0,5))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 7.6 Sommes, produits, dérivées et intégrales non évaluées" ] }, { "cell_type": "code", "execution_count": 40, "metadata": { "collapsed": false }, "outputs": [], "source": [ "A = Sum(1/k**6, (k,1,oo))\n", "B = Product(2*n+1, (n,1,21))\n", "C = Derivative(asin(x), x)\n", "D = Integral(log(x), x)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\sum_{k=1}^{\\infty} \\frac{1}{k^{6}} = \\frac{\\pi^{6}}{945}$$" ], "text/plain": [ " ∞ \n", " ____ \n", " ╲ \n", " ╲ 1 6\n", " ╲ ── π \n", " ╱ 6 = ───\n", " ╱ k 945\n", " ╱ \n", " ‾‾‾‾ \n", "k = 1 " ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Eq(A, A.doit())" ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\prod_{n=1}^{21} \\left(2 n + 1\\right) = 563862029680583509947946875$$" ], "text/plain": [ " 21 \n", "┬───┬ \n", "│ │ 2⋅n + 1 = 563862029680583509947946875\n", "│ │ \n", "n = 1 " ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Eq(B, B.doit())" ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{d}{d x} \\operatorname{asin}{\\left (x \\right )} = \\frac{1}{\\sqrt{- x^{2} + 1}}$$" ], "text/plain": [ "d 1 \n", "──(asin(x)) = ─────────────\n", "dx __________\n", " ╱ 2 \n", " ╲╱ - x + 1 " ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Eq(C, C.doit())" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\int \\log{\\left (x \\right )}\\, dx = x \\log{\\left (x \\right )} - x$$" ], "text/plain": [ "⌠ \n", "⎮ log(x) dx = x⋅log(x) - x\n", "⌡ " ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Eq(D, D.doit())" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 7.7 Développement en séries" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculer la série de Taylor de $\\tan(x)$ en $x_0=0$ d'ordre 14." ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$x + \\frac{x^{3}}{3} + \\frac{2 x^{5}}{15} + \\frac{17 x^{7}}{315} + \\frac{62 x^{9}}{2835} + \\frac{1382 x^{11}}{155925} + \\frac{21844 x^{13}}{6081075} + \\mathcal{O}\\left(x^{14}\\right)$$" ], "text/plain": [ " 3 5 7 9 11 13 \n", " x 2⋅x 17⋅x 62⋅x 1382⋅x 21844⋅x ⎛ 14⎞\n", "x + ── + ──── + ───── + ───── + ──────── + ───────── + O⎝x ⎠\n", " 3 15 315 2835 155925 6081075 " ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "series(tan(x), x, 0, 14)" ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$x - \\frac{x^{3}}{6} + \\frac{x^{5}}{120} - \\frac{x^{7}}{5040} + \\frac{x^{9}}{362880} + \\mathcal{O}\\left(x^{10}\\right)$$" ], "text/plain": [ " 3 5 7 9 \n", " x x x x ⎛ 10⎞\n", "x - ── + ─── - ──── + ────── + O⎝x ⎠\n", " 6 120 5040 362880 " ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "series(sin(x), x, 0, 10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 7.8 Équations différentielles" ] }, { "cell_type": "code", "execution_count": 55, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{d}{d x} e^{x} = e^{x}$$" ], "text/plain": [ "d ⎛ x⎞ x\n", "──⎝ℯ ⎠ = ℯ \n", "dx " ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from sympy import E\n", "A = Derivative(E**x, x)\n", "Eq(A, A.doit())" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Trouver une fonction $f(x)$ telle que ${d\\over dx} f(x) = f(x)$" ] }, { "cell_type": "code", "execution_count": 56, "metadata": { "collapsed": true }, "outputs": [], "source": [ "f = Function('f')" ] }, { "cell_type": "code", "execution_count": 58, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$f{\\left (x \\right )}$$" ], "text/plain": [ "f(x)" ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f(x)" ] }, { "cell_type": "code", "execution_count": 61, "metadata": { "collapsed": false }, "outputs": [], "source": [ "eq = Eq(Derivative(f(x),x), f(x))" ] }, { "cell_type": "code", "execution_count": 62, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$f{\\left (x \\right )} = C_{1} e^{x}$$" ], "text/plain": [ " x\n", "f(x) = C₁⋅ℯ " ] }, "execution_count": 62, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dsolve(eq)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Trouver une fonction $f(x)$ telle que ${d^2\\over dx^2} f(x) = -f(x)$" ] }, { "cell_type": "code", "execution_count": 64, "metadata": { "collapsed": true }, "outputs": [], "source": [ "eq2 = Eq(Derivative(f(x),x,x), -f(x))" ] }, { "cell_type": "code", "execution_count": 65, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$f{\\left (x \\right )} = C_{1} \\sin{\\left (x \\right )} + C_{2} \\cos{\\left (x \\right )}$$" ], "text/plain": [ "f(x) = C₁⋅sin(x) + C₂⋅cos(x)" ] }, "execution_count": 65, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dsolve(eq2)" ] }, { "cell_type": "code", "execution_count": 66, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{d^{5}}{d x^{5}} f{\\left (x \\right )}$$" ], "text/plain": [ " 5 \n", " d \n", "───(f(x))\n", " 5 \n", "dx " ] }, "execution_count": 66, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Derivative(f(x),x,x,x,x,x)" ] }, { "cell_type": "code", "execution_count": 67, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{d^{5}}{d x^{5}} f{\\left (x \\right )}$$" ], "text/plain": [ " 5 \n", " d \n", "───(f(x))\n", " 5 \n", "dx " ] }, "execution_count": 67, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Derivative(f(x),x,5)" ] }, { "cell_type": "code", "execution_count": 68, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\frac{d^{5}}{d x^{5}} f{\\left (x \\right )}$$" ], "text/plain": [ " 5 \n", " d \n", "───(f(x))\n", " 5 \n", "dx " ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f(x).diff(x,5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Résoudre$$y''-4y'+5y=0$$." ] }, { "cell_type": "code", "execution_count": 69, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$y{\\left (x \\right )} = \\left(C_{1} \\sin{\\left (x \\right )} + C_{2} \\cos{\\left (x \\right )}\\right) e^{2 x}$$" ], "text/plain": [ " 2⋅x\n", "y(x) = (C₁⋅sin(x) + C₂⋅cos(x))⋅ℯ " ] }, "execution_count": 69, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from sympy.abc import x,y\n", "eq = Eq(y(x).diff(x,x)-4*y(x).diff(x)+5*y(x),0)\n", "dsolve(eq, y(x))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 8 Algèbre linéaire" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 8.1 Définir une matrice" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Définir la matrice\n", "$$M=\\begin{bmatrix}\n", "2& 9& 3\\\\ 4& 5& 10\\\\ 2& 0& 3\n", "\\end{bmatrix}$$" ] }, { "cell_type": "code", "execution_count": 70, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}2 & 9 & 3\\\\4 & 5 & 10\\\\2 & 0 & 3\\end{matrix}\\right]$$" ], "text/plain": [ "⎡2 9 3 ⎤\n", "⎢ ⎥\n", "⎢4 5 10⎥\n", "⎢ ⎥\n", "⎣2 0 3 ⎦" ] }, "execution_count": 70, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Matrix([[2, 9, 3], [4, 5, 10], [2, 0, 3]])" ] }, { "cell_type": "code", "execution_count": 107, "metadata": { "collapsed": false }, "outputs": [], "source": [ "M = Matrix(3,3,[2, 9, 3, 4, 5, 10, 2, 0, 3])" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Définir la matrice\n", "$$N=\\begin{bmatrix}\n", "2& 9& 3\\\\ 4& 5& 10\\\\ -6& -1& -17\n", "\\end{bmatrix}$$" ] }, { "cell_type": "code", "execution_count": 73, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}2 & 9 & 3\\\\4 & 5 & 10\\\\-6 & -1 & -17\\end{matrix}\\right]$$" ], "text/plain": [ "⎡2 9 3 ⎤\n", "⎢ ⎥\n", "⎢4 5 10 ⎥\n", "⎢ ⎥\n", "⎣-6 -1 -17⎦" ] }, "execution_count": 73, "metadata": {}, "output_type": "execute_result" } ], "source": [ "N = Matrix(3,3,[2,9,3,4,5,10,-6,-1,-17]); N" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Définir le vecteur\n", "$$v=\\begin{bmatrix}\n", "5\\\\ 2\\\\ 1\n", "\\end{bmatrix}$$" ] }, { "cell_type": "code", "execution_count": 75, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}5\\\\2\\\\1\\end{matrix}\\right]$$" ], "text/plain": [ "⎡5⎤\n", "⎢ ⎥\n", "⎢2⎥\n", "⎢ ⎥\n", "⎣1⎦" ] }, "execution_count": 75, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v = Matrix([5,2,1]); v" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 8.2 Opérations de base" ] }, { "cell_type": "code", "execution_count": 76, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left ( \\left[\\begin{matrix}2 & 9 & 3\\\\4 & 5 & 10\\\\2 & 0 & 3\\end{matrix}\\right], \\quad \\left[\\begin{matrix}2 & 9 & 3\\\\4 & 5 & 10\\\\-6 & -1 & -17\\end{matrix}\\right]\\right )$$" ], "text/plain": [ "⎛⎡2 9 3 ⎤, ⎡2 9 3 ⎤⎞\n", "⎜⎢ ⎥ ⎢ ⎥⎟\n", "⎜⎢4 5 10⎥ ⎢4 5 10 ⎥⎟\n", "⎜⎢ ⎥ ⎢ ⎥⎟\n", "⎝⎣2 0 3 ⎦ ⎣-6 -1 -17⎦⎠" ] }, "execution_count": 76, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M, N" ] }, { "cell_type": "code", "execution_count": 77, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}4 & 18 & 6\\\\8 & 10 & 20\\\\-4 & -1 & -14\\end{matrix}\\right]$$" ], "text/plain": [ "⎡4 18 6 ⎤\n", "⎢ ⎥\n", "⎢8 10 20 ⎥\n", "⎢ ⎥\n", "⎣-4 -1 -14⎦" ] }, "execution_count": 77, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M + N" ] }, { "cell_type": "code", "execution_count": 78, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}6 & 27 & 9\\\\12 & 15 & 30\\\\6 & 0 & 9\\end{matrix}\\right]$$" ], "text/plain": [ "⎡6 27 9 ⎤\n", "⎢ ⎥\n", "⎢12 15 30⎥\n", "⎢ ⎥\n", "⎣6 0 9 ⎦" ] }, "execution_count": 78, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M * 3" ] }, { "cell_type": "code", "execution_count": 79, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}22 & 60 & 45\\\\-32 & 51 & -108\\\\-14 & 15 & -45\\end{matrix}\\right]$$" ], "text/plain": [ "⎡22 60 45 ⎤\n", "⎢ ⎥\n", "⎢-32 51 -108⎥\n", "⎢ ⎥\n", "⎣-14 15 -45 ⎦" ] }, "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M * N" ] }, { "cell_type": "code", "execution_count": 80, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}31\\\\40\\\\13\\end{matrix}\\right]$$" ], "text/plain": [ "⎡31⎤\n", "⎢ ⎥\n", "⎢40⎥\n", "⎢ ⎥\n", "⎣13⎦" ] }, "execution_count": 80, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M * v" ] }, { "cell_type": "code", "execution_count": 81, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}\\frac{5}{24} & - \\frac{3}{8} & \\frac{25}{24}\\\\\\frac{1}{9} & 0 & - \\frac{1}{9}\\\\- \\frac{5}{36} & \\frac{1}{4} & - \\frac{13}{36}\\end{matrix}\\right]$$" ], "text/plain": [ "⎡ 25 ⎤\n", "⎢5/24 -3/8 ── ⎥\n", "⎢ 24 ⎥\n", "⎢ ⎥\n", "⎢ 1/9 0 -1/9⎥\n", "⎢ ⎥\n", "⎢ -13 ⎥\n", "⎢-5/36 1/4 ────⎥\n", "⎣ 36 ⎦" ] }, "execution_count": 81, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M ** -1" ] }, { "cell_type": "code", "execution_count": 82, "metadata": { "collapsed": false }, "outputs": [ { "ename": "ValueError", "evalue": "Matrix det == 0; not invertible.", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mN\u001b[0m \u001b[0;34m**\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/sympy/core/decorators.pyc\u001b[0m in \u001b[0;36mbinary_op_wrapper\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 116\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 117\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 118\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 119\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mbinary_op_wrapper\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 120\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mpriority_decorator\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/sympy/matrices/dense.pyc\u001b[0m in \u001b[0;36m__pow__\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 561\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mcall_highest_priority\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'__rpow__'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 562\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__pow__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 563\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mDenseMatrix\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__pow__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 564\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 565\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mcall_highest_priority\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'__pow__'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/sympy/matrices/matrices.pyc\u001b[0m in \u001b[0;36m__pow__\u001b[0;34m(self, num)\u001b[0m\n\u001b[1;32m 537\u001b[0m \u001b[0mn\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnum\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 538\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mn\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 539\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0mn\u001b[0m \u001b[0;31m# A**-2 = (A**-1)**2\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 540\u001b[0m \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0meye\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcols\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 541\u001b[0m \u001b[0ms\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/sympy/matrices/matrices.pyc\u001b[0m in \u001b[0;36minv\u001b[0;34m(self, method, **kwargs)\u001b[0m\n\u001b[1;32m 307\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 308\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'method'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 309\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_eval_inverse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 310\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 311\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0minv_mod\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mm\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/sympy/matrices/dense.pyc\u001b[0m in \u001b[0;36m_eval_inverse\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 304\u001b[0m \u001b[0mM\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mas_mutable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 305\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"GE\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 306\u001b[0;31m \u001b[0mrv\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mM\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minverse_GE\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miszerofunc\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0miszerofunc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 307\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"LU\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 308\u001b[0m \u001b[0mrv\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mM\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minverse_LU\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miszerofunc\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0miszerofunc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/sympy/matrices/matrices.pyc\u001b[0m in \u001b[0;36minverse_GE\u001b[0;34m(self, iszerofunc)\u001b[0m\n\u001b[1;32m 2629\u001b[0m \u001b[0mred\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrref\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miszerofunc\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0miszerofunc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msimplify\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2630\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0many\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miszerofunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mred\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mj\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mj\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mred\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrows\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2631\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Matrix det == 0; not invertible.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2632\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2633\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_new\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mred\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrows\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mValueError\u001b[0m: Matrix det == 0; not invertible." ] } ], "source": [ "N ** -1" ] }, { "cell_type": "code", "execution_count": 83, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}2 & 4 & 2\\\\9 & 5 & 0\\\\3 & 10 & 3\\end{matrix}\\right]$$" ], "text/plain": [ "⎡2 4 2⎤\n", "⎢ ⎥\n", "⎢9 5 0⎥\n", "⎢ ⎥\n", "⎣3 10 3⎦" ] }, "execution_count": 83, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.transpose()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 8.3 Accéder aux coefficients" ] }, { "cell_type": "code", "execution_count": 84, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}2 & 9 & 3\\\\4 & 5 & 10\\\\2 & 0 & 3\\end{matrix}\\right]$$" ], "text/plain": [ "⎡2 9 3 ⎤\n", "⎢ ⎥\n", "⎢4 5 10⎥\n", "⎢ ⎥\n", "⎣2 0 3 ⎦" ] }, "execution_count": 84, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M" ] }, { "cell_type": "code", "execution_count": 85, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$5$$" ], "text/plain": [ "5" ] }, "execution_count": 85, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M[1,1]" ] }, { "cell_type": "code", "execution_count": 88, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$0$$" ], "text/plain": [ "0" ] }, "execution_count": 88, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M[2,1]" ] }, { "cell_type": "code", "execution_count": 90, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}2 & 9 & 3\\end{matrix}\\right]$$" ], "text/plain": [ "[2 9 3]" ] }, "execution_count": 90, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.row(0)" ] }, { "cell_type": "code", "execution_count": 92, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}9\\\\5\\\\0\\end{matrix}\\right]$$" ], "text/plain": [ "⎡9⎤\n", "⎢ ⎥\n", "⎢5⎥\n", "⎢ ⎥\n", "⎣0⎦" ] }, "execution_count": 92, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.col(1)" ] }, { "cell_type": "code", "execution_count": 94, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}2 & 9 & 3\\\\4 & 5 & 10\\\\2 & 0 & 3\\end{matrix}\\right]$$" ], "text/plain": [ "⎡2 9 3 ⎤\n", "⎢ ⎥\n", "⎢4 5 10⎥\n", "⎢ ⎥\n", "⎣2 0 3 ⎦" ] }, "execution_count": 94, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M" ] }, { "cell_type": "code", "execution_count": 96, "metadata": { "collapsed": true }, "outputs": [], "source": [ "M[0,0] = pi" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 8.4 Construction de matrices particulières" ] }, { "cell_type": "code", "execution_count": 102, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}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{matrix}\\right]$$" ], "text/plain": [ "⎡0 0 0 0 0 0⎤\n", "⎢ ⎥\n", "⎢0 0 0 0 0 0⎥\n", "⎢ ⎥\n", "⎢0 0 0 0 0 0⎥\n", "⎢ ⎥\n", "⎣0 0 0 0 0 0⎦" ] }, "execution_count": 102, "metadata": {}, "output_type": "execute_result" } ], "source": [ "zeros(4,6)" ] }, { "cell_type": "code", "execution_count": 103, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\\\1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\\\1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\end{matrix}\\right]$$" ], "text/plain": [ "⎡1 1 1 1 1 1 1 1⎤\n", "⎢ ⎥\n", "⎢1 1 1 1 1 1 1 1⎥\n", "⎢ ⎥\n", "⎣1 1 1 1 1 1 1 1⎦" ] }, "execution_count": 103, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ones(3,8)" ] }, { "cell_type": "code", "execution_count": 104, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}1 & 0 & 0 & 0 & 0\\\\0 & 1 & 0 & 0 & 0\\\\0 & 0 & 1 & 0 & 0\\\\0 & 0 & 0 & 1 & 0\\\\0 & 0 & 0 & 0 & 1\\end{matrix}\\right]$$" ], "text/plain": [ "⎡1 0 0 0 0⎤\n", "⎢ ⎥\n", "⎢0 1 0 0 0⎥\n", "⎢ ⎥\n", "⎢0 0 1 0 0⎥\n", "⎢ ⎥\n", "⎢0 0 0 1 0⎥\n", "⎢ ⎥\n", "⎣0 0 0 0 1⎦" ] }, "execution_count": 104, "metadata": {}, "output_type": "execute_result" } ], "source": [ "eye(5)" ] }, { "cell_type": "code", "execution_count": 105, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}3 & 0 & 0\\\\0 & 4 & 0\\\\0 & 0 & 5\\end{matrix}\\right]$$" ], "text/plain": [ "⎡3 0 0⎤\n", "⎢ ⎥\n", "⎢0 4 0⎥\n", "⎢ ⎥\n", "⎣0 0 5⎦" ] }, "execution_count": 105, "metadata": {}, "output_type": "execute_result" } ], "source": [ "diag(3,4,5)" ] }, { "cell_type": "code", "execution_count": 106, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}3 & 0 & 0 & 0 & 0 & 0\\\\0 & 4 & 0 & 0 & 0 & 0\\\\0 & 0 & 5 & 0 & 0 & 0\\\\0 & 0 & 0 & \\pi & 9 & 3\\\\0 & 0 & 0 & 4 & 5 & 10\\\\0 & 0 & 0 & 2 & 0 & 3\\end{matrix}\\right]$$" ], "text/plain": [ "⎡3 0 0 0 0 0 ⎤\n", "⎢ ⎥\n", "⎢0 4 0 0 0 0 ⎥\n", "⎢ ⎥\n", "⎢0 0 5 0 0 0 ⎥\n", "⎢ ⎥\n", "⎢0 0 0 π 9 3 ⎥\n", "⎢ ⎥\n", "⎢0 0 0 4 5 10⎥\n", "⎢ ⎥\n", "⎣0 0 0 2 0 3 ⎦" ] }, "execution_count": 106, "metadata": {}, "output_type": "execute_result" } ], "source": [ "diag(3,4,5,M)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 8.5 Matrice échelonnée réduite" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculer la forme échelonnée réduite de $M$ et $N$." ] }, { "cell_type": "code", "execution_count": 108, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}2 & 9 & 3\\\\4 & 5 & 10\\\\2 & 0 & 3\\end{matrix}\\right]$$" ], "text/plain": [ "⎡2 9 3 ⎤\n", "⎢ ⎥\n", "⎢4 5 10⎥\n", "⎢ ⎥\n", "⎣2 0 3 ⎦" ] }, "execution_count": 108, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M" ] }, { "cell_type": "code", "execution_count": 110, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left ( \\left[\\begin{matrix}1 & 0 & 0\\\\0 & 1 & 0\\\\0 & 0 & 1\\end{matrix}\\right], \\quad \\left [ 0, \\quad 1, \\quad 2\\right ]\\right )$$" ], "text/plain": [ "⎛⎡1 0 0⎤, [0, 1, 2]⎞\n", "⎜⎢ ⎥ ⎟\n", "⎜⎢0 1 0⎥ ⎟\n", "⎜⎢ ⎥ ⎟\n", "⎝⎣0 0 1⎦ ⎠" ] }, "execution_count": 110, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.rref()" ] }, { "cell_type": "code", "execution_count": 112, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}2 & 9 & 3\\\\4 & 5 & 10\\\\-6 & -1 & -17\\end{matrix}\\right]$$" ], "text/plain": [ "⎡2 9 3 ⎤\n", "⎢ ⎥\n", "⎢4 5 10 ⎥\n", "⎢ ⎥\n", "⎣-6 -1 -17⎦" ] }, "execution_count": 112, "metadata": {}, "output_type": "execute_result" } ], "source": [ "N" ] }, { "cell_type": "code", "execution_count": 111, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left ( \\left[\\begin{matrix}1 & 0 & \\frac{75}{26}\\\\0 & 1 & - \\frac{4}{13}\\\\0 & 0 & 0\\end{matrix}\\right], \\quad \\left [ 0, \\quad 1\\right ]\\right )$$" ], "text/plain": [ "⎛⎡ 75 ⎤ ⎞\n", "⎜⎢1 0 ── ⎥, [0, 1]⎟\n", "⎜⎢ 26 ⎥ ⎟\n", "⎜⎢ ⎥ ⎟\n", "⎜⎢0 1 -4/13⎥ ⎟\n", "⎜⎢ ⎥ ⎟\n", "⎝⎣0 0 0 ⎦ ⎠" ] }, "execution_count": 111, "metadata": {}, "output_type": "execute_result" } ], "source": [ "N.rref()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 8.6 Noyau" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculer le noyau des matrices $M$ et $N$." ] }, { "cell_type": "code", "execution_count": 113, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left [ \\right ]$$" ], "text/plain": [ "[]" ] }, "execution_count": 113, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.nullspace()" ] }, { "cell_type": "code", "execution_count": 114, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left [ \\left[\\begin{matrix}- \\frac{75}{26}\\\\\\frac{4}{13}\\\\1\\end{matrix}\\right]\\right ]$$" ], "text/plain": [ "⎡⎡-75 ⎤⎤\n", "⎢⎢────⎥⎥\n", "⎢⎢ 26 ⎥⎥\n", "⎢⎢ ⎥⎥\n", "⎢⎢4/13⎥⎥\n", "⎢⎢ ⎥⎥\n", "⎣⎣ 1 ⎦⎦" ] }, "execution_count": 114, "metadata": {}, "output_type": "execute_result" } ], "source": [ "N.nullspace()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 8.7 Déterminant" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculer le déterminant des matrices $M$ et $N$." ] }, { "cell_type": "code", "execution_count": 115, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$72$$" ], "text/plain": [ "72" ] }, "execution_count": 115, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.det()" ] }, { "cell_type": "code", "execution_count": 116, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$0$$" ], "text/plain": [ "0" ] }, "execution_count": 116, "metadata": {}, "output_type": "execute_result" } ], "source": [ "N.det()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 8.8 Polynôme caractéristique" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculer le polynôme caractérisque de la matrice $M$ et de $N$." ] }, { "cell_type": "code", "execution_count": 117, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from sympy.abc import x" ] }, { "cell_type": "code", "execution_count": 118, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\operatorname{PurePoly}{\\left( x^{3} - 10 x^{2} - 11 x - 72, x, domain=\\mathbb{Z} \\right)}$$" ], "text/plain": [ "PurePoly(x**3 - 10*x**2 - 11*x - 72, x, domain='ZZ')" ] }, "execution_count": 118, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.charpoly(x)" ] }, { "cell_type": "code", "execution_count": 119, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$x^{3} - 10 x^{2} - 11 x - 72$$" ], "text/plain": [ " 3 2 \n", "x - 10⋅x - 11⋅x - 72" ] }, "execution_count": 119, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.charpoly(x).as_expr()" ] }, { "cell_type": "code", "execution_count": 120, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$x^{3} + 10 x^{2} - 117 x$$" ], "text/plain": [ " 3 2 \n", "x + 10⋅x - 117⋅x" ] }, "execution_count": 120, "metadata": {}, "output_type": "execute_result" } ], "source": [ "N.charpoly(x).as_expr()" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "### 8.9 Valeurs propres et vecteurs propres" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Calculer les valeurs propres et vecteurs propres de\n", "$$K=\\begin{bmatrix}\n", "93& 27& -57\\\\ -40& 180& -140\\\\ -15& 27& 51\n", "\\end{bmatrix}$$" ] }, { "cell_type": "code", "execution_count": 121, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left[\\begin{matrix}93 & 27 & -57\\\\-40 & 180 & -140\\\\-15 & 27 & 51\\end{matrix}\\right]$$" ], "text/plain": [ "⎡93 27 -57 ⎤\n", "⎢ ⎥\n", "⎢-40 180 -140⎥\n", "⎢ ⎥\n", "⎣-15 27 51 ⎦" ] }, "execution_count": 121, "metadata": {}, "output_type": "execute_result" } ], "source": [ "K = Matrix(3,3,[93,27,-57,-40,180,-140,-15,27,51])\n", "K" ] }, { "cell_type": "code", "execution_count": 122, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left \\{ 90 : 1, \\quad 108 : 1, \\quad 126 : 1\\right \\}$$" ], "text/plain": [ "{90: 1, 108: 1, 126: 1}" ] }, "execution_count": 122, "metadata": {}, "output_type": "execute_result" } ], "source": [ "K.eigenvals()" ] }, { "cell_type": "code", "execution_count": 123, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left [ \\left ( 90, \\quad 1, \\quad \\left [ \\left[\\begin{matrix}1\\\\2\\\\1\\end{matrix}\\right]\\right ]\\right ), \\quad \\left ( 108, \\quad 1, \\quad \\left [ \\left[\\begin{matrix}\\frac{9}{5}\\\\1\\\\0\\end{matrix}\\right]\\right ]\\right ), \\quad \\left ( 126, \\quad 1, \\quad \\left [ \\left[\\begin{matrix}1\\\\\\frac{10}{3}\\\\1\\end{matrix}\\right]\\right ]\\right )\\right ]$$" ], "text/plain": [ "⎡⎛90, 1, ⎡⎡1⎤⎤⎞, ⎛108, 1, ⎡⎡9/5⎤⎤⎞, ⎛126, 1, ⎡⎡ 1 ⎤⎤⎞⎤\n", "⎢⎜ ⎢⎢ ⎥⎥⎟ ⎜ ⎢⎢ ⎥⎥⎟ ⎜ ⎢⎢ ⎥⎥⎟⎥\n", "⎢⎜ ⎢⎢2⎥⎥⎟ ⎜ ⎢⎢ 1 ⎥⎥⎟ ⎜ ⎢⎢10/3⎥⎥⎟⎥\n", "⎢⎜ ⎢⎢ ⎥⎥⎟ ⎜ ⎢⎢ ⎥⎥⎟ ⎜ ⎢⎢ ⎥⎥⎟⎥\n", "⎣⎝ ⎣⎣1⎦⎦⎠ ⎝ ⎣⎣ 0 ⎦⎦⎠ ⎝ ⎣⎣ 1 ⎦⎦⎠⎦" ] }, "execution_count": 123, "metadata": {}, "output_type": "execute_result" } ], "source": [ "K.eigenvects()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "En général, les racines peuvent être plus compliquées:" ] }, { "cell_type": "code", "execution_count": 124, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$$\\left \\{ \\frac{10}{3} + \\left(- \\frac{1}{2} - \\frac{\\sqrt{3} i}{2}\\right) \\sqrt[3]{\\frac{2 \\sqrt{11523}}{3} + \\frac{2467}{27}} + \\frac{133}{9 \\left(- \\frac{1}{2} - \\frac{\\sqrt{3} i}{2}\\right) \\sqrt[3]{\\frac{2 \\sqrt{11523}}{3} + \\frac{2467}{27}}} : 1, \\quad \\frac{10}{3} + \\frac{133}{9 \\left(- \\frac{1}{2} + \\frac{\\sqrt{3} i}{2}\\right) \\sqrt[3]{\\frac{2 \\sqrt{11523}}{3} + \\frac{2467}{27}}} + \\left(- \\frac{1}{2} + \\frac{\\sqrt{3} i}{2}\\right) \\sqrt[3]{\\frac{2 \\sqrt{11523}}{3} + \\frac{2467}{27}} : 1, \\quad \\frac{133}{9 \\sqrt[3]{\\frac{2 \\sqrt{11523}}{3} + \\frac{2467}{27}}} + \\frac{10}{3} + \\sqrt[3]{\\frac{2 \\sqrt{11523}}{3} + \\frac{2467}{27}} : 1\\right \\}$$" ], "text/plain": [ "⎧ ____________________ \n", "⎪ ⎛ ___ ⎞ ╱ _______ \n", "⎪10 ⎜ 1 ╲╱ 3 ⋅ⅈ⎟ ╱ 2⋅╲╱ 11523 2467 133 \n", "⎪── + ⎜- ─ - ───────⎟⋅3 ╱ ─────────── + ──── + ────────────────────────────\n", "⎨3 ⎝ 2 2 ⎠ ╲╱ 3 27 _____\n", "⎪ ⎛ ___ ⎞ ╱ \n", "⎪ ⎜ 1 ╲╱ 3 ⋅ⅈ⎟ ╱ 2⋅╲╱\n", "⎪ 9⋅⎜- ─ - ───────⎟⋅3 ╱ ────\n", "⎩ ⎝ 2 2 ⎠ ╲╱ \n", "\n", " \n", " ⎛ \n", " 10 133 ⎜ 1 \n", "───────────────: 1, ── + ─────────────────────────────────────────── + ⎜- ─ + \n", "_______________ 3 ____________________ ⎝ 2 \n", "_______ ⎛ ___ ⎞ ╱ _______ \n", " 11523 2467 ⎜ 1 ╲╱ 3 ⋅ⅈ⎟ ╱ 2⋅╲╱ 11523 2467 \n", "─────── + ──── 9⋅⎜- ─ + ───────⎟⋅3 ╱ ─────────── + ──── \n", " 3 27 ⎝ 2 2 ⎠ ╲╱ 3 27 \n", "\n", " ____________________ \n", " ___ ⎞ ╱ _______ \n", "╲╱ 3 ⋅ⅈ⎟ ╱ 2⋅╲╱ 11523 2467 133 10 ╱\n", "───────⎟⋅3 ╱ ─────────── + ──── : 1, ─────────────────────────── + ── + 3 ╱ \n", " 2 ⎠ ╲╱ 3 27 ____________________ 3 ╲╱ \n", " ╱ _______ \n", " ╱ 2⋅╲╱ 11523 2467 \n", " 9⋅3 ╱ ─────────── + ──── \n", " ╲╱ 3 27 \n", "\n", " ____________________ ⎫\n", "╱ _______ ⎪\n", " 2⋅╲╱ 11523 2467 ⎪\n", " ─────────── + ──── : 1⎪\n", " 3 27 ⎬\n", " ⎪\n", " ⎪\n", " ⎪\n", " ⎭" ] }, "execution_count": 124, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.eigenvals()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.10" } }, "nbformat": 4, "nbformat_minor": 0 }