Spaces:
Build error
Build error
Upload 3077 files
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- MLPY/Lib/site-packages/sympy-1.13.1.dist-info/AUTHORSAdded+1317
- MLPY/Lib/site-packages/sympy-1.13.1.dist-info/INSTALLERAdded+1
- MLPY/Lib/site-packages/sympy-1.13.1.dist-info/LICENSEAdded+153
- MLPY/Lib/site-packages/sympy-1.13.1.dist-info/METADATAAdded+304
- MLPY/Lib/site-packages/sympy-1.13.1.dist-info/RECORDAdded
- MLPY/Lib/site-packages/sympy-1.13.1.dist-info/WHEELAdded+5
- MLPY/Lib/site-packages/sympy-1.13.1.dist-info/entry_points.txtAdded+2
- MLPY/Lib/site-packages/sympy-1.13.1.dist-info/top_level.txtAdded+2
- MLPY/Lib/site-packages/sympy/__init__.pyAdded+542
- MLPY/Lib/site-packages/sympy/__pycache__/__init__.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/__pycache__/abc.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/__pycache__/conftest.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/__pycache__/galgebra.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/__pycache__/release.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/__pycache__/this.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/abc.pyAdded+111
- MLPY/Lib/site-packages/sympy/algebras/__init__.pyAdded+3
- MLPY/Lib/site-packages/sympy/algebras/__pycache__/__init__.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/algebras/__pycache__/quaternion.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/algebras/quaternion.pyAdded+1667
- MLPY/Lib/site-packages/sympy/algebras/tests/__init__.pyAdded
- MLPY/Lib/site-packages/sympy/algebras/tests/__pycache__/__init__.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/algebras/tests/__pycache__/test_quaternion.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/algebras/tests/test_quaternion.pyAdded+428
- MLPY/Lib/site-packages/sympy/assumptions/__init__.pyAdded+18
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/__init__.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/ask.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/ask_generated.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/assume.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/cnf.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/facts.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/lra_satask.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/refine.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/satask.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/sathandlers.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/__pycache__/wrapper.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/ask.pyAdded+651
- MLPY/Lib/site-packages/sympy/assumptions/ask_generated.pyAdded+352
- MLPY/Lib/site-packages/sympy/assumptions/assume.pyAdded+485
- MLPY/Lib/site-packages/sympy/assumptions/cnf.pyAdded+445
- MLPY/Lib/site-packages/sympy/assumptions/facts.pyAdded+270
- MLPY/Lib/site-packages/sympy/assumptions/handlers/__init__.pyAdded+13
- MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/__init__.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/calculus.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/common.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/matrices.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/ntheory.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/order.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/sets.cpython-39.pycAdded
- MLPY/Lib/site-packages/sympy/assumptions/handlers/calculus.pyAdded+258
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317All people who contributed to SymPy by sending at least a patch ormore (in the order of the date of their first contribution), exceptthose who explicitly didn't want to be mentioned. People with a * nextto their names are not found in the metadata of the git history. Thisfile is generated automatically by running `./bin/authors_update.py`.
There are a total of 1309 authors.
Ondřej Čertík <ondrej@certik.cz>Fabian Pedregosa <fabian@fseoane.net>Jurjen N.E. Bos <jnebos@gmail.com>Mateusz Paprocki <mattpap@gmail.com>*Marc-Etienne M.Leveille <protonyc@gmail.com>Brian Jorgensen <brian.jorgensen@gmail.com>Jason Gedge <inferno1386@gmail.com>Robert Schwarz <lethargo@googlemail.com>Pearu Peterson <pearu.peterson@gmail.com>Fredrik Johansson <fredrik.johansson@gmail.com>Chris Wu <chris.wu@gmail.com>*Ulrich Hecht <ulrich.hecht@gmail.com>Goutham Lakshminarayan <dl.goutham@gmail.com>David Lawrence <dmlawrence@gmail.com>Jaroslaw Tworek <dev.jrx@gmail.com>David Marek <h4wk.cz@gmail.com>Bernhard R. Link <brlink@debian.org>Andrej Tokarčík <androsis@gmail.com>Or Dvory <gidesa@gmail.com>Saroj Adhikari <adh.saroj@gmail.com>Pauli Virtanen <pav@iki.fi>Robert Kern <robert.kern@gmail.com>James Aspnes <aspnes@cs.yale.edu>Nimish Telang <ntelang@gmail.com>Abderrahim Kitouni <a.kitouni@gmail.com>Pan Peng <pengpanster@gmail.com>Friedrich Hagedorn <friedrich_h@gmx.de>Elrond der Elbenfuerst <elrond+sympy.org@samba-tng.org>Rizgar Mella <rizgar.mella@gmail.com>Felix Kaiser <felix.kaiser@fxkr.net>Roberto Nobrega <rwnobrega@gmail.com>David Roberts <dvdr18@gmail.com>Sebastian Krämer <basti.kr@gmail.com>Vinzent Steinberg <vinzent.steinberg@gmail.com>Riccardo Gori <goriccardo@gmail.com>Case Van Horsen <casevh@gmail.com>Stepan Roucka <stepan@roucka.eu>Ali Raza Syed <arsyed@gmail.com>Stefano Maggiolo <s.maggiolo@gmail.com>Robert Cimrman <cimrman3@ntc.zcu.cz>Bastian Weber <bastian.weber@gmx-topmail.de>Sebastian Krause <sebastian.krause@gmx.de>Sebastian Kreft <skreft@gmail.com>*Dan <coolg49964@gmail.com>Alan Bromborsky <abrombo@verizon.net>Boris Timokhin <qoqenator@gmail.com>Robert <average.programmer@gmail.com>Andy R. Terrel <aterrel@uchicago.edu>Hubert Tsang <intsangity@gmail.com>Konrad Meyer <konrad.meyer@gmail.com>Henrik Johansson <henjo2006@gmail.com>Priit Laes <plaes@plaes.org>Freddie Witherden <freddie@witherden.org>Brian E. Granger <ellisonbg@gmail.com>Andrew Straw <strawman@astraw.com>Kaifeng Zhu <cafeeee@gmail.com>Ted Horst <ted.horst@earthlink.net>Andrew Docherty <andrewd@maths.usyd.edu.au>Akshay Srinivasan <akshaysrinivasan@gmail.com>Aaron Meurer <asmeurer@gmail.com>Barry Wardell <barry.wardell@gmail.com>Tomasz Buchert <thinred@gmail.com>Vinay Kumar <gnulinooks@gmail.com>Johann Cohen-Tanugi <johann.cohentanugi@gmail.com>Jochen Voss <voss@seehuhn.de>Luke Peterson <hazelnusse@gmail.com>Chris Smith <smichr@gmail.com>Thomas Sidoti <TSidoti@gmail.com>Florian Mickler <florian@mickler.org>Nicolas Pourcelot <nicolas.pourcelot@gmail.com>Ben Goodrich <goodrich.ben@gmail.com>Toon Verstraelen <Toon.Verstraelen@UGent.be>Ronan Lamy <ronan.lamy@gmail.com>James Abbatiello <abbeyj@gmail.com>Ryan Krauss <ryanlists@gmail.com>Bill Flynn <wflynny@gmail.com>Kevin Goodsell <kevin-opensource@omegacrash.net>Jorn Baayen <jorn.baayen@gmail.com>Eh Tan <tan2tan2@gmail.com>Renato Coutinho <renato.coutinho@gmail.com>Oscar Benjamin <oscar.j.benjamin@gmail.com>Øyvind Jensen <jensen.oyvind@gmail.com>Julio Idichekop Filho <idichekop@yahoo.com.br>Łukasz Pankowski <lukpank@o2.pl>*Chu-Ching Huang <cchuang@mail.cgu.edu.tw>Fernando Perez <Fernando.Perez@berkeley.edu>Raffaele De Feo <alberthilbert@gmail.com>Christian Muise <christian.muise@gmail.com>Matt Curry <mattjcurry@gmail.com>Kazuo Thow <kazuo.thow@gmail.com>Christian Schubert <chr.schubert@gmx.de>Jezreel Ng <jezreel@gmail.com>James Pearson <xiong.chiamiov@gmail.com>Matthew Brett <matthew.brett@gmail.com>Addison Cugini <ajcugini@gmail.com>Nicholas J.S. Kinar <n.kinar@usask.ca>Harold Erbin <harold.erbin@gmail.com>Thomas Dixon <thom@thomdixon.org>Cristóvão Sousa <crisjss@gmail.com>Andre de Fortier Smit <freevryheid@gmail.com>Mark Dewing <markdewing@gmail.com>Alexey U. Gudchenko <proga@goodok.ru>Gary Kerr <gary.kerr@blueyonder.co.uk>Sherjil Ozair <sherjilozair@gmail.com>Oleksandr Gituliar <gituliar@gmail.com>Sean Vig <sean.v.775@gmail.com>Prafullkumar P. Tale <hector1618@gmail.com>Vladimir Perić <vlada.peric@gmail.com>Tom Bachmann <e_mc_h2@web.de>Yuri Karadzhov <yuri.karadzhov@gmail.com>Vladimir Lagunov <werehuman@gmail.com>Matthew Rocklin <mrocklin@cs.uchicago.edu>Saptarshi Mandal <sapta.iitkgp@gmail.com>Gilbert Gede <gilbertgede@gmail.com>Anatolii Koval <weralwolf@gmail.com>Tomo Lazovich <lazovich@gmail.com>Pavel Fedotov <fedotovp@gmail.com>Jack McCaffery <jpmccaffery@gmail.com>Jeremias Yehdegho <j.yehdegho@gmail.com>Kibeom Kim <kk1674@nyu.edu>Gregory Ksionda <ksiondag846@gmail.com>Tomáš Bambas <tomas.bambas@gmail.com>Raymond Wong <rayman_407@yahoo.com>Luca Weihs <astronomicalcuriosity@gmail.com>Shai 'Deshe' Wyborski <shaide@cs.huji.ac.il>Thomas Wiecki <thomas.wiecki@gmail.com>Óscar Nájera <najera.oscar@gmail.com>Mario Pernici <mario.pernici@gmail.com>Benjamin McDonald <mcdonald.ben@gmail.com>Sam Magura <samtheman132@gmail.com>Stefan Krastanov <krastanov.stefan@gmail.com>Bradley Froehle <brad.froehle@gmail.com>Min Ragan-Kelley <benjaminrk@gmail.com>Emma Hogan <ehogan@gemini.edu>Nikhil Sarda <diff.operator@gmail.com>Julien Rioux <julien.rioux@gmail.com>Roberto Colistete, Jr. <roberto.colistete@gmail.com>Raoul Bourquin <raoulb@bluewin.ch>Gert-Ludwig Ingold <gert.ingold@physik.uni-augsburg.de>Srinivas Vasudevan <srvasude@gmail.com>Jason Moore <moorepants@gmail.com>Miha Marolt <tloramus@gmail.com>Tim Lahey <tim.lahey@gmail.com>Luis Garcia <ppn.online@me.com>Matt Rajca <matt.rajca@me.com>David Li <l33tnerd.li@gmail.com>Alexandr Gudulin <alexandr.gudulin@gmail.com>Bilal Akhtar <bilalakhtar@ubuntu.com>Grzegorz Świrski <sognat@gmail.com>Matt Habel <habelinc@gmail.com>David Ju <Sgtmook314@gmail.com>Nichita Utiu <nikita.utiu+github@gmail.com>Nikolay Lazarov <qwerqwerqwer@abv.bg>Steve Anton <anxuiz.nx@gmail.com>Imran Ahmed Manzoor <imran.manzoor31@gmail.com>Ljubiša Moćić <3rdslasher@gmail.com>Piotr Korgul <p.korgul@gmail.com>Jim Zhang <Hyriodula@gmail.com>Sam Sleight <samuel.sleight@gmail.com>tborisova <ts.borisova3@gmail.com>Chancellor Arkantos <Chancellor_Arkantos@hotmail.co.uk>Stepan Simsa <simsa.st@gmail.com>Tobias Lenz <t_lenz94@web.de>Siddhanathan Shanmugam <siddhanathan@gmail.com>Tiffany Zhu <bubble.wubble.303@gmail.com>Tristan Hume <tris.hume@gmail.com>Alexey Subach <alexey.subach@gmail.com>Joan Creus <joan.creus.c@gmail.com>Geoffry Song <goffrie@gmail.com>Puneeth Chaganti <punchagan@gmail.com>Marcin Kostrzewa <>Natalia Nawara <fankalemura@gmail.com>vishal <vishal.panjwani15@gmail.com>Shruti Mangipudi <shruti2395@gmail.com>Davy Mao <e_equals_mass_speed_light_squared@hotmail.com>Swapnil Agarwal <swapnilag29@gmail.com>Dhia Kennouche <kendhia@gmail.com>jerryma1121 <jerryma1121@gmail.com>Joachim Durchholz <jo@durchholz.org>Martin Povišer <martin.povik@gmail.com>Siddhant Jain <getsiddhant@gmail.com>Kevin Hunter <hunteke@earlham.edu>Michael Mayorov <marchael@kb.csu.ru>Nathan Alison <nathan.f.alison@gmail.com>Christian Bühler <christian@cbuehler.de>Carsten Knoll <CarstenKnoll@gmx.de>Bharath M R <catchmrbharath@gmail.com>Matthias Toews <mat.toews@googlemail.com>Sergiu Ivanov <unlimitedscolobb@gmail.com>Jorge E. Cardona <jorgeecardona@gmail.com>Sanket Agarwal <sanket@sanketagarwal.com>Manoj Babu K. <manoj.babu2378@gmail.com>Sai Nikhil <tsnlegend@gmail.com>Aleksandar Makelov <amakelov@college.harvard.edu>Sachin Irukula <sachin.irukula@gmail.com>Raphael Michel <webmaster@raphaelmichel.de>Ashwini Oruganti <ashwini.oruganti@gmail.com>Andreas Klöckner <inform@tiker.net>Prateek Papriwal <papriwalprateek@gmail.com>Arpit Goyal <agmps18@gmail.com>Angadh Nanjangud <angadh.n@gmail.com>Comer Duncan <comer.duncan@gmail.com>Jens H. Nielsen <jenshnielsen@gmail.com>Joseph Dougherty <Github@JWDougherty.com>Elliot Marshall <Marshall2389@gmail.com>Guru Devanla <grdvnl@gmail.com>George Waksman <waksman@gwax.com>Alexandr Popov <alexandr.s.popov@gmail.com>Tarun Gaba <tarun.gaba7@gmail.com>Takafumi Arakaki <aka.tkf@gmail.com>Saurabh Jha <saurabh.jhaa@gmail.com>Rom le Clair <jacen.guardian@gmail.com>Angus Griffith <16sn6uv@gmail.com>Timothy Reluga <treluga@math.psu.edu>Brian Stephanik <xoedusk@gmail.com>Alexander Eberspächer <alex.eberspaecher@gmail.com>Sachin Joglekar <srjoglekar246@gmail.com>Tyler Pirtle <teeler@gmail.com>Vasily Povalyaev <vapovalyaev@gmail.com>Colleen Lee <colleenclee@gmail.com>Matthew Hoff <mhoff14@gmail.com>Niklas Thörne <notrupertthorne@gmail.com>Huijun Mai <m.maihuijun@gmail.com>Marek Šuppa <mr@shu.io>Ramana Venkata <idlike2dream@gmail.com>Prasoon Shukla <prasoon92.iitr@gmail.com>Stefen Yin <zqyin@ucdavis.edu>Thomas Hisch <t.hisch@gmail.com>Madeleine Ball <mpball@gmail.com>Mary Clark <mary.spriteling@gmail.com>Rishabh Dixit <rishabhdixit11@gmail.com>Manoj Kumar <manojkumarsivaraj334@gmail.com>Akshit Agarwal <akshit.jiit@gmail.com>CJ Carey <perimosocordiae@gmail.com>Patrick Lacasse <patrick.m.lacasse@gmail.com>Ananya H <ananyaha93@gmail.com>Tarang Patel <tarangrockr@gmail.com>Christopher Dembia <cld72@cornell.edu>Benjamin Fishbein <fishbeinb@gmail.com>Sean Ge <seange727@gmail.com>Amit Jamadagni <bitsjamadagni@gmail.com>Ankit Agrawal <aaaagrawal@iitb.ac.in>Björn Dahlgren <bjodah@gmail.com>Christophe Saint-Jean <christophe.saint-jean@univ-lr.fr>Demian Wassermann <demian@bwh.harvard.edu>Khagesh Patel <khageshpatel93@gmail.com>Stephen Loo <shikil@yahoo.com>hm <hacman0@gmail.com>Patrick Poitras <acebulf@gmail.com>Katja Sophie Hotz <katja.sophie.hotz@student.tuwien.ac.at>Varun Joshi <joshi.142@osu.edu>Chetna Gupta <cheta.gup@gmail.com>Thilina Rathnayake <thilinarmtb@gmail.com>Max Hutchinson <maxhutch@gmail.com>Shravas K Rao <shravas@gmail.com>Matthew Tadd <matt.tadd@gmail.com>Alexander Hirzel <alex@hirzel.us>Randy Heydon <randy.heydon@clockworklab.net>Oliver Lee <oliverzlee@gmail.com>Seshagiri Prabhu <seshagiriprabhu@gmail.com>Pradyumna <pradyu1993@gmail.com>Erik Welch <erik.n.welch@gmail.com>Eric Nelson <eric.the.red.XLII@gmail.com>Roland Puntaier <roland.puntaier@chello.at>Chris Conley <chrisconley15@gmail.com>Tim Swast <tswast@gmail.com>Dmitry Batkovich <batya239@gmail.com>Francesco Bonazzi <franz.bonazzi@gmail.com>Yuriy Demidov <iurii.demidov@gmail.com>Rick Muller <rpmuller@gmail.com>Manish Gill <gill.manish90@gmail.com>Markus Müller <markus.mueller.1.g@googlemail.com>Amit Saha <amitsaha.in@gmail.com>Jeremy <twobitlogic@gmail.com>QuaBoo <kisonchristian@gmail.com>Stefan van der Walt <stefan@sun.ac.za>David Joyner <wdjoyner@gmail.com>Lars Buitinck <larsmans@gmail.com>Alkiviadis G. Akritas <akritas@uth.gr>Vinit Ravishankar <vinit.ravishankar@gmail.com>Mike Boyle <boyle@astro.cornell.edu>Heiner Kirchhoffer <Heiner.Kirchhoffer@gmail.com>Pablo Puente <ppuedom@gmail.com>James Fiedler <jrfiedler@gmail.com>Harsh Gupta <mail@hargup.in>Tuomas Airaksinen <tuomas.airaksinen@gmail.com>Paul Strickland <p.e.strickland@gmail.com>James Goppert <james.goppert@gmail.com>rathmann <rathmann.os@gmail.com>Avichal Dayal <avichal.dayal@gmail.com>Paul Scott <paul.scott@nicta.com.au>Shipra Banga <bangashipra@gmail.com>Pramod Ch <pramodch14@gmail.com>Akshay <akshaynukala95@gmail.com>Buck Shlegeris <buck2@bruceh15.anu.edu.au>Jonathan Miller <jdmiller93@gmail.com>Edward Schembor <eschemb1@jhu.edu>Rajath Shashidhara <rajaths.rajaths@gmail.com>Zamrath Nizam <zamiguy_ni@yahoo.com>Aditya Shah <adityashah30@gmail.com>Rajat Aggarwal <rajataggarwal1975@gmail.com>Sambuddha Basu <sammygamer@live.com>Zeel Shah <kshah215@gmail.com>Abhinav Chanda <abhinavchanda01@gmail.com>Jim Crist <crist042@umn.edu>Sudhanshu Mishra <mrsud94@gmail.com>Anurag Sharma <anurags92@gmail.com>Soumya Dipta Biswas <sdb1323@gmail.com>Sushant Hiray <hiraysushant@gmail.com>Ben Lucato <ben.lucato@gmail.com>Kunal Arora <kunalarora.135@gmail.com>Henry Gebhardt <hsggebhardt@gmail.com>Dammina Sahabandu <dmsahabandu@gmail.com>Manish Shukla <manish.shukla393@gmail>Ralph Bean <rbean@redhat.com>richierichrawr <richierichrawr@users.noreply.github.com>John Connor <john.theman.connor@gmail.com>Juan Luis Cano Rodríguez <juanlu001@gmail.com>Sahil Shekhawat <sahilshekhawat01@gmail.com>Kundan Kumar <kundankumar18581@gmail.com>Stas Kelvich <stanconn@gmail.com>sevaader <sevaader@gmail.com>Dhruvesh Vijay Parikh <parikhdhruvesh1@gmail.com>Venkatesh Halli <venkatesh.fatality@gmail.com>Lennart Fricke <lennart@die-frickes.eu>Vlad Seghete <vlad.seghete@gmail.com>Shashank Agarwal <shashank.agarwal94@gmail.com>carstimon <carstimon@gmail.com>Pierre Haessig <pierre.haessig@crans.org>Maciej Baranski <getrox.sc@gmail.com>Benjamin Gudehus <hastebrot@gmail.com>Faisal Anees <faisal.iiit@gmail.com>Mark Shoulson <mark@kli.org>Robert Johansson <jrjohansson@gmail.com>Kalevi Suominen <jksuom@gmail.com>Kaushik Varanasi <kaushik.varanasi1@gmail.com>Fawaz Alazemi <Mba7eth@gmail.com>Ambar Mehrotra <mehrotraambar@gmail.com>David P. Sanders <dpsanders@gmail.com>Peter Brady <petertbrady@gmail.com>John V. Siratt <jvsiratt@gmail.com>Sarwar Chahal <chahal.sarwar98@gmail.com>Nathan Woods <charlesnwoods@gmail.com>Colin B. Macdonald <cbm@m.fsf.org>Marcus Näslund <naslundx@gmail.com>Clemens Novak <clemens@familie-novak.net>Mridul Seth <seth.mridul@gmail.com>Craig A. Stoudt <craig.stoudt@gmail.com>Raj <raj454raj@gmail.com>Mihai A. Ionescu <ionescu.a.mihai@gmail.com>immerrr <immerrr@gmail.com>Chai Wah Wu <cwwuieee@gmail.com>Leonid Blouvshtein <leonidbl91@gmail.com>Peleg Michaeli <freepeleg@gmail.com>ck Lux <lux.r.ck@gmail.com>zsc347 <zsc347@gmail.com>Hamish Dickson <hamish.dickson@gmail.com>Michael Gallaspy <gallaspy.michael@gmail.com>Roman Inflianskas <infroma@gmail.com>Duane Nykamp <nykamp@umn.edu>Ted Dokos <tdokos@gmail.com>Sunny Aggarwal <sunnyaggarwal1994@gmail.com>Victor Brebenar <v.brebenar@gmail.com>Akshat Jain <akshat.jain@students.iiit.ac.in>Shivam Vats <shivamvats.iitkgp@gmail.com>Longqi Wang <iqgnol@gmail.com>Juan Felipe Osorio <jfosorio@gmail.com>Ray Cathcart <github@cathcart.us>Lukas Zorich <lukas.zorich@gmail.com>Eric Miller <emiller42@gmail.com>Cody Herbst <cyherbst@gmail.com>Nishith Shah <nishithshah.2211@gmail.com>Amit Kumar <dtu.amit@gmail.com>Yury G. Kudryashov <urkud.urkud@gmail.com>Guillaume Gay <contact@damcb.com>Mihir Wadwekar <m.mihirw@gmail.com>Tuan Manh Lai <laituan245@gmail.com>Asish Panda <asishrocks95@gmail.com>Darshan Chaudhary <deathbullet@gmail.com>Alec Kalinin <alec.kalinin@gmail.com>Ralf Stephan <ralf@ark.in-berlin.de>Aaditya Nair <aadityanair6494@gmail.com>Jayesh Lahori <jlahori92@gmail.com>Harshil Goel <harshil158@gmail.com>Luv Agarwal <agarwal.iiit@gmail.com>Jason Ly <jason.ly@gmail.com>Lokesh Sharma <lokeshhsharma@gmail.com>Sartaj Singh <singhsartaj94@gmail.com>Chris Swierczewski <cswiercz@gmail.com>Konstantin Togoi <konstantin.togoi@gmail.com>Param Singh <paramsingh258@gmail.com>Sumith Kulal <sumith1896@gmail.com>Juha Remes <jremes@outlook.com>Philippe Bouafia <philippe.bouafia@ensea.fr>Peter Schmidt <peter@peterjs.com>Jiaxing Liang <liangjiaxing57@gmail.com>Lucas Jones <lucas@lucasjones.co.uk>Gregory Ashton <gash789@gmail.com>Jennifer White <jcrw122@googlemail.com>Renato Orsino <renato.orsino@gmail.com>Michael Boyle <michael.oliver.boyle@gmail.com>Alistair Lynn <arplynn@gmail.com>Govind Sahai <gsiitbhu@gmail.com>Adam Bloomston <adam@glitterfram.es>Kyle McDaniel <mcdanie5@illinois.edu>Nguyen Truong Duy <truongduy134@yahoo.com>Alex Lindsay <adlinds3@ncsu.edu>Mathew Chong <mathewchong.dev@gmail.com>Jason Siefken <siefkenj@gmail.com>Gaurav Dhingra <gauravdhingra.gxyd@gmail.com>Gao, Xiang <qasdfgtyuiop@gmail.com>Kevin Ventullo <kevin.ventullo@gmail.com>mao8 <thisisma08@gmail.com>Isuru Fernando <isuruf@gmail.com>Shivam Tyagi <shivam.tyagi.apm13@itbhu.ac.in>Richard Otis <richard.otis@outlook.com>Rich LaSota <rjlasota@gmail.com>dustyrockpyle <dustyrockpyle@gmail.com>Anton Akhmerov <anton.akhmerov@gmail.com>Michael Zingale <michael.zingale@stonybrook.edu>Chak-Pong Chung <chakpongchung@gmail.com>David T <derDavidT@users.noreply.github.com>Phil Ruffwind <rf@rufflewind.com>Sebastian Koslowski <koslowski@kit.edu>Kumar Krishna Agrawal <kumar.1994.14@gmail.com>Dustin Gadal <Dustin.Gadal@gmail.com>João Moura <operte@gmail.com>Yu Kobayashi <yukoba@accelart.jp>Shashank Kumar <shashank.kumar.apc13@iitbhu.ac.in>Timothy Cyrus <tcyrus@users.noreply.github.com>Devyani Kota <devyanikota@gmail.com>Keval Shah <kevalshah_96@yahoo.co.in>Dzhelil Rufat <drufat@caltech.edu>Pastafarianist <mr.pastafarianist@gmail.com>Sourav Singh <souravsingh@users.noreply.github.com>Jacob Garber <jgarber1@ualberta.ca>Vinay Singh <csvinay.d@gmail.com>GolimarOurHero <metalera94@hotmail.com>Prashant Tyagi <prashanttyagi221295@gmail.com>Matthew Davis <davisml.md@gmail.com>Tschijnmo TSCHAU <tschijnmotschau@gmail.com>Alexander Bentkamp <bentkamp@gmail.com>Jack Kemp <metaknightdrake-git@yahoo.co.uk>Kshitij Saraogi <KshitijSaraogi@gmail.com>Thomas Baruchel <baruchel@gmx.com>Nicolás Guarín-Zapata <nicoguarin@gmail.com>Jens Jørgen Mortensen <jj@smoerhul.dk>Sampad Kumar Saha <sampadsaha5@gmail.com>Eva Charlotte Mayer <eva-charlotte.mayer@posteo.de>Laura Domine <temigo@gmx.com>Justin Blythe <jblythe29@gmail.com>Meghana Madhyastha <meghana.madhyastha@gmail.com>Tanu Hari Dixit <tokencolour@gmail.com>Shekhar Prasad Rajak <shekharrajak@live.com>Aqnouch Mohammed <aqnouch.mohammed@gmail.com>Arafat Dad Khan <arafat.da.khan@gmail.com>Boris Atamanovskiy <shaomoron@gmail.com>Sam Tygier <sam.tygier@hep.manchester.ac.uk>Jai Luthra <me@jailuthra.in>Guo Xingjian <Seeker1995@gmail.com>Sandeep Veethu <sandeep.veethu@gmail.com>Archit Verma <architv07@gmail.com>Shubham Tibra <shubh.tibra@gmail.com>Ashutosh Saboo <ashutosh.saboo96@gmail.com>Michael S. Hansen <michael.hansen@nih.gov>Anish Shah <shah.anish07@gmail.com>Guillaume Jacquenot <guillaume.jacquenot@gmail.com>Bhautik Mavani <mavanibhautik@gmail.com>Michał Radwański <enedil.isildur@gmail.com>Jerry Li <jerry@jerryli.ca>Pablo Zubieta <pabloferz@yahoo.com.mx>Shivam Agarwal <knowthyself2503@gmail.com>Chaitanya Sai Alaparthi <achaitanyasai@gmail.com>Arihant Parsoya <parsoyaarihant@gmail.com>Ruslan Pisarev <rpisarev@cloudlinux.com>Akash Trehan <akash.trehan123@gmail.com>Nishant Nikhil <nishantiam@gmail.com>Vladimir Poluhsin <vovapolu@gmail.com>Akshay Nagar <awesomeay13@yahoo.com>James Brandon Milam <jmilam343@gmail.com>Abhinav Agarwal <abhinavagarwal1996@gmail.com>Rishabh Daal <rishabhdaal@gmail.com>Sanya Khurana <sanya@monica.in>Aman Deep <amandeep1024@gmail.com>Aravind Reddy <aravindreddy255@gmail.com>Abhishek Verma <iamvermaabhishek@gmail.com>Matthew Parnell <matt@parnmatt.co.uk>Thomas Hickman <Thomas.Hickman42@gmail.com>Akshay Siramdas <akshaysiramdas@gmail.com>YiDing Jiang <yidinggjiangg@gmail.com>Jatin Yadav <jatinyadav25@gmail.com>Matthew Thomas <mnmt@users.noreply.github.com>Rehas Sachdeva <aquannie@gmail.com>Michael Mueller <michaeldmueller7@gmail.com>Srajan Garg <srajan.garg@gmail.com>Prabhjot Singh <prabhjot.nith@gmail.com>Haruki Moriguchi <harukimoriguchi@gmail.com>Tom Gijselinck <tomgijselinck@gmail.com>Nitin Chaudhary <nitinmax1000@gmail.com>Alex Argunov <sajkoooo@gmail.com>Nathan Musoke <nathan.musoke@gmail.com>Abhishek Garg <abhishekgarg119@gmail.com>Dana Jacobsen <dana@acm.org>Vasiliy Dommes <vasdommes@gmail.com>Phillip Berndt <phillip.berndt@googlemail.com>Haimo Zhang <zh.hammer.dev@gmail.com>Anthony Scopatz <scopatz@gmail.com>bluebrook <perl4logic@gmail.com>Leonid Kovalev <leonidvkovalev@gmail.com>Josh Burkart <jburkart@gmail.com>Dimitra Konomi <t8130064@dias.aueb.gr>Christina Zografou <t8130048@dias.aueb.gr>Fiach Antaw <fiach.antaw+github@gmail.com>Langston Barrett <langston.barrett@gmail.com>Krit Karan <kritkaran.b13@iiits.in>G. D. McBain <gdmcbain@protonmail.com>Prempal Singh <prempal.42@gmail.com>Gabriel Orisaka <orisaka@gmail.com>Matthias Bussonnier <bussonniermatthias@gmail.com>rahuldan <rahul02013@gmail.com>Colin Marquardt <github@marquardt-home.de>Andrew Taber <andrew.e.taber@gmail.com>Yash Reddy <write2yashreddy@gmail.com>Peter Stangl <peter.stangl@ph.tum.de>elvis-sik <e.sikora@grad.ufsc.br>Nikos Karagiannakis <nikoskaragiannakis@gmail.com>Jainul Vaghasia <jainulvaghasia@gmail.com>Dennis Meckel <meckel@datenschuppen.de>Harshil Meena <harshil.7535@gmail.com>Micky <mickydroch@gmail.com>Nick Curtis <nicholas.curtis@uconn.edu>Michele Zaffalon <michele.zaffalon@gmail.com>Martha Giannoudovardi <maapxa@gmail.com>Devang Kulshreshtha <devang.kulshreshtha.cse14@itbhu.ac.in>Steph Papanik <spapanik21@gmail.com>Mohammad Sadeq Dousti <msdousti@gmail.com>Arif Ahmed <arif.ahmed.5.10.1995@gmail.com>Abdullah Javed Nesar <abduljaved1994@gmail.com>Lakshya Agrawal <zeeshan.lakshya@gmail.com>shruti <shrutishrm512@gmail.com>Rohit Rango <rohit.rango@gmail.com>Hong Xu <hong@topbug.net>Ivan Petuhov <ivan@ostrovok.ru>Alsheh <alsheh@rpi.edu>Marcel Stimberg <marcel.stimberg@ens.fr>Alexey Pakhocmhik <cool.Bakov@yandex.ru>Tommy Olofsson <tommy.olofsson.90@gmail.com>Zulfikar <zulfikar97@gmail.com>Blair Azzopardi <blairuk@gmail.com>Danny Hermes <daniel.j.hermes@gmail.com>Sergey Pestov <pestov-sa@yandex.ru>Mohit Chandra <mohit.chandra@research.iiit.ac.in>Karthik Chintapalli <karthik.chintapalli@students.iiit.ac.in>Marcin Briański <marcin.brianski@student.uj.edu.pl>andreo <andrey.torba@gmail.com>Flamy Owl <flamyowl@protonmail.ch>Yicong Guo <guoyicong100@gmail.com>Varun Garg <varun.garg03@gmail.com>Rishabh Madan <rishabhmadan96@gmail.com>Aditya Kapoor <aditya.kapoor.apm12@itbhu.ac.in>Karan Sharma <karan1276@gmail.com>Vedant Rathore <vedantr1998@gmail.com>Johan Blåbäck <johan_bluecreek@riseup.net>Pranjal Tale <pranjaltale16@gmail.com>Jason Tokayer <jason.tokayer@gmail.com>Raghav Jajodia <jajodia.raghav@gmail.com>Rajat Thakur <rajatthakur1997@gmail.com>Dhruv Bhanushali <dhruv_b@live.com>Anjul Kumar Tyagi <anjul.ten@gmail.com>Barun Parruck <barun.parruck@gmail.com>Bao Chau <chauquocbao0907@gmail.com>Tanay Agrawal <tanay_agrawal@hotmail.com>Ranjith Kumar <ranjith.dakshana2015@gmail.com>Shikhar Makhija <shikharmakhija2@gmail.com>Yathartha Joshi <yathartha32@gmail.com>Valeriia Gladkova <valeriia.gladkova@gmail.com>Sagar Bharadwaj <sagarbharadwaj50@gmail.com>Daniel Mahler <dmahler@gmail.com>Ka Yi <chua.kayi@yahoo.com.sg>Rishat Iskhakov <iskhakov@frtk.ru>Szymon Mieszczak <szymon.mieszczak@gmail.com>Sachin Agarwal <sachinagarwal0499@gmail.com>Priyank Patel <pspbot7@gmail.com>Satya Prakash Dwibedi <akash581050@gmail.com>tools4origins <tools4origins@gmail.com>Nico Schlömer <nico.schloemer@gmail.com>Fermi Paradox <FermiParadox@users.noreply.github.com>Ekansh Purohit <purohit.e15@gmail.com>Vedarth Sharma <vedarth.sharma@gmail.com>Peeyush Kushwaha <peeyush.p97@gmail.com>Jayjayyy <vfhsln8s3l4b87t4c3@byom.de>Christopher J. Wright <cjwright4242gh@gmail.com>Jakub Wilk <jwilk@jwilk.net>Mauro Garavello <mauro.garavello@unimib.it>Chris Tefer <ctefer@gmail.com>Shikhar Jaiswal <jaiswalshikhar87@gmail.com>Chiu-Hsiang Hsu <wdv4758h@gmail.com>Carlos Cordoba <ccordoba12@gmail.com>Fabian Ball <fabian.ball@kit.edu>Yerniyaz <yerniyaz.nurgabylov@nu.edu.kz>Christiano Anderson <canderson@riseup.net>Robin Neatherway <robin.neatherway@gmail.com>Thomas Hunt <thomashunt13@gmail.com>Theodore Han <theodorehan@hotmail.com>Duc-Minh Phan <alephvn@gmail.com>Lejla Metohajrova <l.metohajrova@gmail.com>Samyak Jain <samyak.jain2016a@vitstudent.ac.in>Aditya Rohan <riyuzakiiitk@gmail.com>Vincent Delecroix <vincent.delecroix@labri.fr>Michael Sparapany <msparapa@purdue.edu>Harsh Jain <harshjniitr@gmail.com>Nathan Goldbaum <ngoldbau@illinois.edu>latot <felipematas@yahoo.com>Kenneth Lyons <ixjlyons@gmail.com>Stan Schymanski <stan.schymanski@env.ethz.ch>David Daly <david.daly12@kzoo.edu>Ayush Shridhar <ayush.shridhar1999@gmail.com>Javed Nissar <javednissar@gmail.com>Jiri Kuncar <jiri.kuncar@gmail.com>vedantc98 <vedantc98@gmail.com>Rupesh Harode <rupeshharode@gmail.com>Rob Zinkov <rob@zinkov.com>James Harrop <ebc121@gmail.com>James Taylor <user234683@tutanota.com>Ishan Joshi <ishanaj98@gmail.com>Marco Mancini <marco.mancini@obspm.fr>Boris Ettinger <ettinger.boris@gmail.com>Micah Fitch <micahscopes@gmail.com>Daniel Wennberg <daniel.wennberg@gmail.com>ylemkimon <ylemkimon@naver.com>Akash Vaish <akash.9712@gmail.com>Peter Enenkel <peter.enenkel+git@gmail.com>Waldir Pimenta <waldyrious@gmail.com>Jithin D. George <jithindgeorge93@gmail.com>Lev Chelyadinov <leva181777@gmail.com>Lucas Wiman <lucas.wiman@gmail.com>Rhea Parekh <rheaparekh12@gmail.com>James Cotton <peabody124@gmail.com>Robert Pollak <robert.pollak@posteo.net>anca-mc <anca-mc@users.noreply.github.com>Sourav Ghosh <souravghosh2197@gmail.com>Jonathan Allan <jjallan@users.noreply.github.com>Nikhil Pappu <nkhlpappu@gmail.com>Ethan Ward <etkewa@gmail.com>Cezary Marczak <zeddq1@gmail.com>dps7ud <dps7ud@virginia.edu>Nilabja Bhattacharya <nilabja10201992@gmail.com>Itay4 <31018228+Itay4@users.noreply.github.com>Poom Chiarawongse <eight1911@gmail.com>Yang Yang <wdscxsj@gmail.com>Cavendish McKay <cmckay@tachycline.com>Bradley Gannon <bradley.m.gannon@gmail.com>B McG <bmcg0890@gmail.com>Rob Drynkin <rob.drynkin@gmail.com>Seth Ebner <murgrehk@gmail.com>Akash Kundu <sk.sayakkundu1997@gmail.com>Mark Jeromin <mark.jeromin@sysfrog.net>Roberto Díaz Pérez <r.r.1994a@gmail.com>Gleb Siroki <g.shiroki@gmail.com>Segev Finer <segev208@gmail.com>Alex Lubbock <code@alexlubbock.com>Ayodeji Ige <ayodeji18@outlook.com>Matthew Wardrop <matthew.wardrop@airbnb.com>Hugo van Kemenade <hugovk@users.noreply.github.com>Austin Palmer <ap4000@nyu.edu>der-blaue-elefant <github@kklein.de>Filip Gokstorp <filip@gokstorp.se>Yuki Matsuda <yuki.matsuda.w@gmail.com>Aaron Miller <acmiller273@gmail.com>Salil Vishnu Kapur <salilvishnukapur@gmail.com>Atharva Khare <khareatharva@gmail.com>Shubham Maheshwari <rmaheshwari05@gmail.com>Pavel Tkachenko <paveltkachenko@email.com>Ashish Kumar Gaurav <ashishkg0022@gmail.com>Rajeev Singh <rajs2010@gmail.com>Keno Goertz <keno@goertz-berlin.com>Lucas Gallindo <lgallindo@gmail.com>Himanshu <hs80941@gmail.com>David Menéndez Hurtado <david.menendez.hurtado@scilifelab.se>Amit Manchanda <amitdelhi1995@gmail.com>Rohit Jain <rohitjain3241@gmail.com>Jonathan A. Gross <jarthurgross@gmail.com>Unknown <kunda@scribus.net>Sayan Goswami <Sayan98@users.noreply.github.com>Subhash Saurabh <subhashsaurabh419@gmail.com>Rastislav Rabatin <rastislav.rabatin@gmail.com>Vishal <vishalg2235@gmail.com>Jeremey Gluck <jeremygluck@yahoo.com>Akshat Maheshwari <akshat14714@gmail.com>symbolique <symbolique@users.noreply.github.com>Saloni Jain <tosalonijain@gmail.com>Arighna Chakrabarty <arighna.chakrabarty100@gmail.com>Abhigyan Khaund <mail@abhigyan.xyz>Jashanpreet Singh <jashansingh.4398@gmail.com>Saurabh Agarwal <shourabh.agarwal@gmail.com>luzpaz <luzpaz@users.noreply.github.com>P. Sai Prasanth <psai.prasanth.min16@itbhu.ac.in>Nirmal Sarswat <nirmalsarswat400@gmail.com>Cristian Di Pietrantonio <cristiandipietrantonio@gmail.com>Ravi charan <ravicharan.vsp@gmail.com>Nityananda Gohain <nityanandagohain@gmail.com>Cédric Travelletti <cedrictravelletti@gmail.com>Nicholas Bollweg <nick.bollweg@gmail.com>Himanshu Ladia <hladia199811@gmail.com>Adwait Baokar <adwaitbaokar18@gmail.com>Mihail Tarigradschi <m.tarigradschi@gmail.com>Saketh <alurusaisaketh@gmail.com>rushyam <rushyamsonu@gmail.com>sfoo <sfoohei@gmail.com>Rahil Hastu <rahilhastu@gmail.com>Zach Raines <raineszm@gmail.com>Sidhant Nagpal <sidhantnagpal97@gmail.com>Gagandeep Singh <singh.23@iitj.ac.in>Rishav Chakraborty <annonymousxyz@outlook.com>Malkhan Singh <malkhansinghrathaur@gmail.com>Joaquim Monserrat <qmonserrat@mailoo.org>Mayank Singh <mayank.singh081997@gmail.com>Rémy Léone <rleone@online.net>Maxence Mayrand <35958639+maxencemayrand@users.noreply.github.com>Nikoleta Glynatsi <GlynatsiNE@cardiff.ac.uk>helo9 <helo9@users.noreply.github.com>Ken Wakita <wakita@is.titech.ac.jp>Carl Sandrock <carl.sandrock@up.ac.za>Fredrik Eriksson <freeriks@student.chalmers.se>Ian Swire <oversizedpenguin@gmail.com>Bulat <daianovich@mail.ru>Ehren Metcalfe <ehren.m@gmail.com>Dmitry Savransky <dsavransky@gmail.com>Kiyohito Yamazaki <kyamaz@openql.org>Caley Finn <caleyreuben@gmail.com>Zhi-Qiang Zhou <zzq_890709@hotmail.com>Alexander Pozdneev <pozdneev@users.noreply.github.com>Wes Turner <50891+westurner@users.noreply.github.com>JMSS-Unknown <31131631+JMSS-Unknown@users.noreply.github.com>Arshdeep Singh <singh.arshdeep1999@gmail.com>cym1 <16437732+cym1@users.noreply.github.com>Stewart Wadsworth <stewart.wadsworth@gmail.com>Jared Lumpe <mjlumpe@gmail.com>Avi Shrivastava <shrivastavaavi123@gmail.com>ramvenkat98 <ramvenkat98@gmail.com>Bilal Ahmed <b.ahmed0918@gmail.com>Dimas Abreu Archanjo Dutra <dimasad@ufmg.br>Yatna Verma <yatnavermaa@gmail.com>S.Y. Lee <sylee957@gmail.com>Miro Hrončok <miro@hroncok.cz>Sudarshan Kamath <sudarshan.kamath97@gmail.com>Ayushman Koul <ayushmankoul4570@gmail.com>Robert Dougherty-Bliss <robert.w.bliss@gmail.com>Andrey Grozin <A.G.Grozin@inp.nsk.su>Bavish Kulur <bavishkulur@gmail.com>Arun Singh <arunsin997@gmail.com>sirnicolaf <43586954+sirnicolaf@users.noreply.github.com>Zachariah Etienne <zachetie@gmail.com>Prayush Dawda <35144226+iamprayush@users.noreply.github.com>2torus <boris.ettinger@gmail.com>Faisal Riyaz <faisalriyaz011@gmail.com>Martin Roelfs <u0114255@kuleuven.be>SirJohnFranklin <sirjfu@googlemail.com>Anthony Sottile <asottile@umich.edu>ViacheslavP <public.viacheslav@gmail.com>Safiya03 <safiyanesar@gmail.com>Alexander Dunlap <alexander.dunlap@gmail.com>Rohit Sharma <31184621+rohitx007@users.noreply.github.com>Jonathan Warner <warnerjon12@gmail.com>Mohit Balwani <mohitbalwani.ict17@gmail.com>Marduk Bolaños <mardukbp@mac.com>amsuhane <ayushsuhane99@iitkgp.ac.in>Matthias Geier <Matthias.Geier@gmail.com>klaasvanaarsen <44929042+klaasvanaarsen@users.noreply.github.com>Shubham Kumar Jha <skjha832@gmail.com>rationa-kunal <kunalgk1999@gmail.com>Animesh Sinha <animeshsinha1309@gmail.com>Gaurang Tandon <1gaurangtandon@gmail.com>Matthew Craven <clyring@users.noreply.github.com>Daniel Ingram <ingramds@appstate.edu>Jogi Miglani <jmig5776@gmail.com>Takumasa Nakamura <n.takumasa@gmail.com>Ritu Raj Singh <RituRajSingh878@gmail.com>Rajiv Ranjan Singh <rajivperfect007@gmail.com>Vera Lozhkina <veralozhkina@gmail.com>adhoc-king <46354827+adhoc-king@users.noreply.github.com>Mikel Rouco <mikel.mrm@gmail.com>Oscar Gustafsson <oscar.gustafsson@gmail.com>damianos <damianos@semmle.com>Supreet Agrawal <supreet11agrawal@gmail.com>shiksha11 <shiksharawat01@gmail.com>Martin Ueding <dev@martin-ueding.de>sharma-kunal <kunalsharma6914@gmail.com>Divyanshu Thakur <divyanshu@iiitmanipur.ac.in>Susumu Ishizuka <susumu.ishizuka@kii.com>Samnan Rahee <namanush.rsr.16@gmail.com>Fredrik Andersson <fredrik.andersson@fcc.chalmers.se>Bhavya Srivastava <bhavya17037@iiitd.ac.in>Alpesh Jamgade <alpeshjamgade21@gmail.com>Shubham Abhang <shubhamabhang77@gmail.com>Vishesh Mangla <manglavishesh64@gmail.com>Nicko van Someren <nicko@nicko.org>dandiez <47832466+dandiez@users.noreply.github.com>Frédéric Chapoton <fchapoton2@gmail.com>jhanwar <f2015463@pilani.bits-pilani.ac.in>Noumbissi valere Gille Geovan <noumbissivalere@gmail.com>Salmista-94 <alejandrogroso@hotmail.com>Shivani Kohli <shivanikohli.09@gmail.com>Parker Berry <parkereberry@gmail.com>Pragyan Mehrotra <pragyan18168@iiitd.ac.in>Nabanita Dash <dashnabanita@gmail.com>Gaetano Guerriero <x.guerriero@tin.it>Ankit Raj Pandey <pandeyan@grinnell.edu>Ritesh Kumar <ritesh99rakesh@gmail.com>kangzhiq <709563092@qq.com>Jun Lin <junlin0604@gmail.com>Petr Kungurtsev <corwinat@gmail.com>Anway De <anway1756@gmail.com>znxftw <vishnu2101@gmail.com>Denis Ivanenko <ivanenko@ucu.edu.ua>Orestis Vaggelis <orestisvaggelis@mail.com>Nikhil Maan <nikhilmaan22@gmail.com>Abhinav Anand <abhinav.anand2807@gmail.com>Qingsha Shi <googol.sqs@gmail.com>Juan Barbosa <js.barbosa10@uniandes.edu.co>Prionti Nasir <pdn3628@rit.edu>Bharat Raghunathan <bharatraghunthan9767@gmail.com>arooshiverma <av22@iitbbs.ac.in>Christoph Gohle <ctg@mpq.mpg.de>Charalampos Tsiagkalis <ctsiagkalis@uth.gr>Daniel Sears <highpost@users.noreply.github.com>Megan Ly <megan.ly@learnosity.com>Sean P. Cornelius <spcornelius@gmail.com>Erik R. Gomez <gomez@kth.se>Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>Henry Metlov <genrih.metlov@gmail.com>pekochun <hamburg_hamburger2000@yahoo.co.jp>Bendik Samseth <b.samseth@gmail.com>Vighnesh Shenoy <vighneshq@gmail.com>Versus Void <versusvoid@gmail.com>Denys Rybalka <rybalka.denis@gmail.com>Mark Dickinson <dickinsm@gmail.com>Rimi <rimibis@umich.edu>rimibis <33387803+rimibis@users.noreply.github.com>Steven Lee <stevenlee123@protonmail.com>Gilles Schintgen <gschintgen@hambier.lu>Abhi58 <abhijithbharadwaj58@gmail.com>Tomasz Pytel <tompytel@gmail.com>Aadit Kamat <aadit.k12@gmail.com>Samesh <samesh.lakhotia@gmail.com>Velibor Zeli <velibor@mech.kth.se>Gabriel Bernardino <gabriel.bernardino@upf.edu>Joseph Redfern <joseph@redfern.me>Evelyn King <evelyn.cameron.king@gmail.com>Miguel Marco <mmarco@unizar.es>David Hagen <david@drhagen.com>Hannah Kari <hannah.kari@marquette.edu>Soniya Nayak <soniyanayak51@gmail.com>Harsh Agarwal <hagarwal9200@gmail.com>Enric Florit <efz1005@gmail.com>Yogesh Mishra <ymishra013@gmail.com>Denis Rykov <rykovd@gmail.com>Ivan Tkachenko <me@ratijas.tk>Kenneth Emeka Odoh <kenneth.odoh@gmail.com>Stephan Seitz <stephan.seitz@fau.de>Yeshwanth N <yeshsurya@gmail.com>Oscar Gerardo Lazo Arjona <oscar.lazoarjona@physics.ox.ac.uk>Srinivasa Arun Yeragudipati <ysarun1999@gmail.com>Kirtan Mali <kirtanmali555@gmail.com>TitanSnow <sweeto@live.cn>Pengning Chao <8857165+PengningChao@users.noreply.github.com>Louis Abraham <louis.abraham@yahoo.fr>Morten Olsen Lysgaard <morten@lysgaard.no>Akash Nagaraj (akasnaga) <akasnaga@cisco.com>Akash Nagaraj <grassknoted@gmail.com>Lauren Glattly <laurenglattly@gmail.com>Hou-Rui <houruinus@gmail.com>George Korepanov <gkorepanov.gk@gmail.com>dranknight09 <cbhaavan@gmail.com>aditisingh2362 <aditisingh2362@gmail.com>Gina <Dr-G@users.noreply.github.com>gregmedlock <gmedlo@gmail.com>Georgios Giapitzakis Tzintanos <giorgosgiapis@mail.com>Eric Wieser <wieser.eric@gmail.com>Bradley Dowling <34559056+btdow@users.noreply.github.com>Maria Marginean <33810762+mmargin@users.noreply.github.com>Akash Agrawall <akash.wanted@gmail.com>jgulian <josephdgulian@gmail.com>Sourav Goyal <souravgl0@gmail.com>Zlatan Vasović <zlatanvasovic@gmail.com>Alex Meiburg <timeroot.alex@gmail.com>Smit Lunagariya <smitlunagariya.mat18@itbhu.ac.in>Naman Gera <namangera15@gmail.com>Julien Palard <julien@palard.fr>Dhruv Mendiratta <dhruvmendiratta6@gmail.com>erdOne <36414270+erdOne@users.noreply.github.com>risubaba <risubhjain1010@gmail.com>abhinav28071999 <41710346+abhinav28071999@users.noreply.github.com>Jisoo Song <jeesoo9595@snu.ac.kr>Jaime R <38530589+Jaime02@users.noreply.github.com>Vikrant Malik <vikrantmalik051@gmail.com>Hardik Saini <43683678+Guardianofgotham@users.noreply.github.com>Abhishek <uchiha@pop-os.localdomain>Johannes Hartung <joha2@gmx.net>Milan Jolly <milan.cs16@iitp.ac.in>faizan2700 <syedfaizan824@gmail.com>mohit <39158356+mohitacecode@users.noreply.github.com>Mohit Gupta <mohitgupta@gmail.com>Psycho-Pirate <prakharsaxena.civ18@iitbhu.ac.in>Chanakya-Ekbote <ca10@iitbbs.ac.in>Rashmi Shehana <rashmi.watagedara@syscolabs.com>Jonty16117 <jonty@DESKTOP-J1O6ANP.localdomain>Anubhav Gupta <anubhav.gupta.cse19@itbhu.ac.in>Michal Grňo <m93a.cz@gmail.com>vezeli <37907135+vezeli@users.noreply.github.com>Tim Gates <tim.gates@iress.com>Sandeep Murthy <smurthy@protonmail.ch>Neil <mistersheik@gmail.com>V1krant <46847915+V1krant@users.noreply.github.com>alejandro <amartinhernan@gmail.com>Riyan Dhiman <Riyandhiman14@gmail.com>sbt4104 <sthorat661@gmail.com>Seth Troisi <sethtroisi@google.com>Bhaskar Gupta <guptabhanu1999@gmail.com>Smit Gajjar <smitgajjar.gs@gmail.com>rbl <rlee@grove.co>Ilya Pchelintsev <ilya.pchelintsev@outlook.com>Omar Wagih <o.wagih.ow@gmail.com>prshnt19 <prashant.rawat216@gmail.com>Johan Guzman <jguzm022@ucr.edu>Vasileios Kalos <kalosbasileios@gmail.com>BasileiosKal <61801875+BasileiosKal@users.noreply.github.com>Shubham Thorat <37049710+sbt4104@users.noreply.github.com>Arpan Chattopadhyay <f20180319@pilani.bits-pilani.ac.in>Ashutosh Hathidara <ashutoshhathidara98@gmail.com>Moses Paul R <iammosespaulr@gmail.com>Saanidhya vats <saanidhyavats@gmail.com>tnzl <you@example.com>Vatsal Srivastava <alstav.trivas.sava@gmail.com>Jean-Luc Herren <jlh@gmx.ch>Dhruv Kothari <dhruvkothari22@gmail.com>seadavis <45022599+seadavis@users.noreply.github.com>kamimura <kamimura@live.jp>slacker404 <pchantza@gmail.com>Jaime Resano <gemailpersonal02@gmail.com>Ebrahim Byagowi <ebrahim@gnu.org>wuyudi <wuyudi119@163.com>Akira Kyle <ak@akirakyle.com>Calvin Jay Ross <calvinjayross@gmail.com>Martin Thoma <info@martin-thoma.de>Thomas A Caswell <tcaswell@gmail.com>Lagaras Stelios <stel.lag@hotmail.com>Jerry James <loganjerry@gmail.com>Jan Kruse <janckruse@t-online.de>Nathan Taylor <pecan.pine@gmail.com>Vaishnav Damani <vaishnavdamani3496@gmail.com>Mohit Shah <mohitshah3111999@gmail.com>Mathias Louboutin <mathias.louboutin@gmail.com>Marijan Smetko <marijansmetko123@gmail.com>Dave Witte Morris <Dave.Morris@uleth.ca>soumi7 <soumibardhan10@gmail.com>Zhongshi <zj495@nyu.edu>Wes Galbraith <galbwe92@gmail.com>KaustubhDamania <kaustubh.damania@gmail.com>w495 <w495@yandex-team.ru>Akhil Rajput <akh1lrjput@gmail.com>Markus Mohrhard <markus.mohrhard@googlemail.com>Benjamin Wolba <mail@benjaminwolba.com>彭于斌 <1931127624@qq.com>Rudr Tiwari <rudrtiwari@gmail.com>Aaryan Dewan <aaryandewan@yahoo.com>Benedikt Placke <benedikt.placke@outlook.com>Sneha Goddu <s.goddu@wustl.edu>goddus <39923708+goddus@users.noreply.github.com>Shivang Dubey <shivangdubey8@gmail.com>Michael Greminger <michael.greminger@gmail.com>Peter Cock <p.j.a.cock@googlemail.com>Willem Melching <willem.melching@gmail.com>Elias Basler <e.e.basler@protonmail.com>Brandon David <brandon.david@zoho.com>Abhay_Dhiman <abhaysdhimans@gmail.com>Tasha Kim <jae_young_kim@brown.edu>Ayush Malik <ayushmalik779@gmail.com>Devesh Sawant <devesh47cool@gmail.com>Wolfgang Stöcher <wolfgang@stoecher.com>Sudeep Sidhu <sudeepmanilsidhu@gmail.com>foice <foice.news@gmail.com>Ben Payne <ben.is.located@gmail.com>Muskan Kumar <31043527+muskanvk@users.noreply.github.com>noam simcha finkelstein <noam.finkelstein@protonmail.com>Garrett Folbe <gmfolbe@yahoo.com>Islam Mansour <is3mansour@gmail.com>Sayandip Halder <sayandiph4@gmail.com>Shubham Agrawal <shubham.ag6845@gmail.com>numbermaniac <5206120+numbermaniac@users.noreply.github.com>Sakirul Alam <binarysakir@gmail.com>Mohammed Bilal <r.mohammedbilal@gmail.com>Chris du Plessis <christopherjonduplessis@gmail.com>Coder-RG <rgoel1999@gmail.com>Ansh Mishra <anshmishra471@gmail.com>Alex Malins <github@alexmalins.com>Lorenzo Contento <lorenzo.contento@gmail.com>Naveen Sai <naveensaisreenivas@gmail.com>Shital Mule <shitalmule04@gmail.com>Amanda Dsouza <meezamanda@yahoo.com>Nijso Beishuizen <nijso@koolmees.numerically-related.com>Harry Zheng <harry@harryzheng.com>Felix Yan <felixonmars@archlinux.org>Constantin Mateescu <costica1234@me.com>Eva Tiwari <eva.tiwari@gmail.com>Aditya Kumar Sinha <adityakumar113141@gmail.com>Soumi Bardhan <51290447+Soumi7@users.noreply.github.com>Kaustubh Chaudhari <ckaustubhm06@gmail.com>Kristian Brünn <hello@kristianbrunn.com>Neel Gorasiya <mgorasiya1974@gmail.com>Akshat Sood <68052998+akshatsood2249@users.noreply.github.com>Jose M. Gomez <chemoki@gmail.com>Stefan Petrea <stefan@garage-coding.com>Praveen Sahu <povinsahu@gmail.com>Mark Bell <mark00bell@googlemail.com>AlexCQY <alex_chua@u.nus.edu>Fabian Froehlich <fabian@schaluck.com>Nikhil Gopalam <gopalamn@umich.edu>Kartik Sethi <kartiks31416@gmail.com>Muhammed Abdul Quadir Owais <quadirowais200@gmail.com>Harshit Yadav <harshityadav2k@gmail.com>Sidharth Mundhra <sidharthmundhra16@gmail.com>Suryam Arnav Kalra <suryamkalra35@gmail.com>Prince Gupta <codemastercpp@gmail.com>Kunal Singh <ksingh19136@gmail.com>Mayank Raj <mayank_1901cs35@iitp.ac.in>Achal Jain <2achaljain@gmail.com>Mario Maio <mario.maio@aruba.it>Aaron Stiff <69512633+AaronStiff@users.noreply.github.com>Wyatt Peak <wyattpeak@gmail.com>Bhaskar Joshi <bhaskar.joshi@research.iiit.ac.in>Aditya Jindal <jaditya8889@gmail.com>Vaibhav Bhat <vaibhav.bhat2097@gmail.com>Priyansh Rathi <techiepriyansh@gmail.com>Saket Kumar Singh <saketkumar1202@gmail.com>Yukai Chou <muzimuzhi@gmail.com>Qijia Liu <liumeo@pku.edu.cn>Paul Mandel <paulmandel@google.com>Nisarg Chaudhari <54911392+Nisarg-Chaudhari@users.noreply.github.com>Dominik Stańczak <stanczakdominik@gmail.com>Rodrigo Luger <rodluger@gmail.com>Marco Antônio Habitzreuter <mahabitzreuter@gmail.com>Ayush Bisht <bisht.ayush2001@gmail.com>Akshansh Bhatt <akshansh@tuta.io>Brandon T. Willard <brandonwillard@users.noreply.github.com>Thomas Aarholt <thomasaarholt@gmail.com>Hiren Chalodiya <hirenchalodiya99@gmail.com>Roland Dixon <rols121@gmail.com>dimasvq <dimas.vq.2020@bristol.ac.uk>Sagar231 <sagarfeb298@gmail.com>Michael Chu <michael02chu@gmail.com>Abby Ng <abigailjng@gmail.com>Angad Sandhu <55819847+angadsinghsandhu@users.noreply.github.com>Alexander Cockburn <alexander_cockburn12@hotmail.com>Yaser AlOsh <yaseralosh@outlook.com>Davide Sandonà <sandona.davide@gmail.com>Jonathan Gutow <gutow@uwosh.edu>Nihir Agarwal <f20180701@pilani.bits-pilani.ac.in>Lee Johnston <lee.johnston.100@gmail.com>Zach Carmichael <20629897+craymichael@users.noreply.github.com>Vijairam Ganesh Moorthy <vijairamg@gmail.com>Hanspeter Schmid <hanspeter.schmid@fhnw.ch>Ben Oostendorp <oostben@umich.edu>Nikita <nikita.student.cse19@itbhu.ac.in>Aman <amanmourya295@gmail.com>Shashank KS <shashankks0987@gmail.com>Aman Sharma <amansharma110603@gmail.com>Anup Parikh <parikhanupk@gmail.com>Lucy Mountain <lucymountain1@icloud.com>Miguel Torres Costa <miguelptcosta1995@gmail.com>Rikard Nordgren <rikard.nordgren@farmaci.uu.se>Arun sanganal <74652697+ArunSanganal@users.noreply.github.com>Kamlesh Joshi <72374645+kamleshjoshi8102@users.noreply.github.com>Joseph Rance <56409230+Joseph-Rance@users.noreply.github.com>Huangduirong <huangduirong@huawei.com>Nils Schulte <47043622+Schnilz@users.noreply.github.com>Matt Bogosian <matt@bogosian.net>Elisha Hollander <just4now666666@gmail.com>Aditya Ravuri <infprobscix@gmail.com>Mamidi Ratna Praneeth <praneethratna@gmail.com>Jeffrey Ryan <jeffaryan7@gmail.com>Jonathan Daniel <36337649+jond01@users.noreply.github.com>Robin Richard <raisin@ecomail.fr>Gautam Menghani <gum3ng@protonmail.com>Remco de Boer <29308176+redeboer@users.noreply.github.com>Sebastian East <sebastianeast@ymail.com>Evani Balasubramanyam <balasubramanyam.evani@gmail.com>Rahil Parikh <r.parikh@somaiya.edu>Jason Ross <jasonross1024@gmail.com>Joannah Nanjekye <joannah.nanjekye@ibm.com>Ayush Kumar <ayushk7102@gmail.com>Kshitij <kshitijparwani.mat18@itbhu.ac.in>Daniel Hyams <dhyams@gmail.com>alijosephine <alijosephine@gmail.com>Matthias Köppe <mkoeppe@math.ucdavis.edu>mohajain <mohajain99@gmail.com>Anibal M. Medina-Mardones <ammedmar@gmail.com>Travis Ens <ens.travis@gmail.com>Evgenia Karunus <lakesare@gmail.com>Risiraj Dey <risirajdey@gmail.com>lastcodestanding <rohang71604@gmail.com>Andrey Lekar <andrey_lekar@adoriasoft.com>Abbas Mohammed <42001049+iam-abbas@users.noreply.github.com>anutosh491 <andersonbhat491@gmail.com>Steve Kieffer <sk@skieffer.info>Paul Spiering <paul@spiering.org>Pieter Gijsbers <p.gijsbers@tue.nl>Wang Ran (汪然) <wangr@smail.nju.edu.cn>naelsondouglas <naelson17@gmail.com>Aman Thakur <thakuraman22july@gmail.com>S. Hanko <suzy.hanko@gmail.com>Dennis Sweeney <sweeney.427@osu.edu>Gurpartap Singh <dhaliwal.gurpartap@gmail.com>Hampus Malmberg <hampus.malmberg88@gmail.com>scimax <max.kellermeier@hotmail.de>Nikhil Date <nikhil.s.date@gmail.com>Kuldeep Borkar Jr <kuldeepborkarjr765@gmail.com>AkuBrain <76952313+Franck2111@users.noreply.github.com>Leo Battle <leowbattle@gmail.com>Advait Pote <apote2050@gmail.com>Anurag Bhat <bhat.1@iitj.ac.in>Jeremy Monat <jemonat@calalum.org>Diane Tchuindjo <dtchuindjo@gmail.com>Tom Fryers <61272761+TomFryers@users.noreply.github.com>Zouhair <zouhair.mahboubi@gmail.com>zzj <29055749+zjzh@users.noreply.github.com>shubhayu09 <guptashubhayu601@gmail.com>Siddhant Jain <siddhantashoknagar@gmail.com>Tirthankar Mazumder <63574588+wermos@users.noreply.github.com>Sumit Kumar <mr.sumitkrr@gmail.com>Shivam Sagar <technoshivam12@gmail.com>Gaurav Jain <gjain369@gmail.com>Andrii Oriekhov <andriyorehov@gmail.com>Luis Talavera <luisfertalavera15@gmail.com>Arie Bovenberg <a.c.bovenberg@gmail.com>Carson McManus <carson.mcmanus1@gmail.com>Jack Schmidt <1107865+jackschmidt@users.noreply.github.com>Riley Britten <nrb1324@hotmail.com>Georges Khaznadar <georgesk@debian.org>Donald Wilson <donwilson1029@gmail.com>Timo Stienstra <timostienstra00@gmail.com>dispasha <dispasha@users.noreply.github.com>Saksham Alok <sakshamalok13@gmail.com>Varenyam Bhardwaj <varenyambhardwaj123@gmail.com>oittaa <8972248+oittaa@users.noreply.github.com>Omkaar <79257339+Pysics@users.noreply.github.com>Islem BOUZENIA <fi_bouzenia@esi.dz>extraymond <extraymond@gmail.com>Alexander Behrens <alex.git@gmx.net>user202729 <25191436+user202729@users.noreply.github.com>Pieter Eendebak <pieter.eendebak@gmail.com>Zaz Brown <zazbrown@zazbrown.com>ritikBhandari <ritikbhandari68@gmail.com>viocha <66580331+viocha@users.noreply.github.com>Arthur Ryman <arthur.ryman@gmail.com>Xiang Wu <hsiangwu@fb.com>tttc3 <T.Coxon2@lboro.ac.uk>Seth Poulsen <poulsenseth@yahoo.com>cocolato <haiizhu@outlook.com>Anton Golovanov <agolovanov256@gmail.com>Gareth Ma <grhkm21@gmail.com>Clément M.T. Robert <cr52@protonmail.com>Glenn Horton-Smith <glenn.hortonsmith@gmail.com>Karan <grgkaran03@gmail.com>Stefan Behnle <84378403+behnle@users.noreply.github.com>Shreyash Mishra <72146041+Shreyash-cyber@users.noreply.github.com>Arthur Milchior <arthur@milchior.fr>NotWearingPants <26556598+NotWearingPants@users.noreply.github.com>Ishan Pandhare <ishan9096137017@gmail.com>Carlos García Montoro <TrilceAC@gmail.com>Parcly Taxel <reddeloostw@gmail.com>Saicharan <saicharanhahaha@gmail.com>Kunal Sheth <kunal@kunalsheth.info>Biswadeep Purkayastha <98874428+metabiswadeep@users.noreply.github.com>Jyn Spring 琴春 <me@vx.st>Phil LeMaitre <phil_lemaitre@live.ca>Chris Kerr <chris.kerr@mykolab.ch>José Senart <jose.senart@gmail.com>Uwe L. Korn <uwelk@xhochy.com>ForeverHaibara <69423537+ForeverHaibara@users.noreply.github.com>Yves Tumushimire <yvestumushimire@gmail.com>wookie184 <wookie1840@gmail.com>Costor <pcs2009@web.de>Klaus Rettinghaus <klaus.rettinghaus@enote.com>Sam Brockie <sambrockie@icloud.com>Abhishek Patidar <1e9abhi1e10@gmail.com>Eric Demer <demer@mailbox.org>Pontus von Brömssen <pontus.vonbromssen+github@gmail.com>Victor Immanuel <chrollolucilfer1402@gmail.com>Evandro Bernardes <evbernardes@gmail.com>Michele Ceccacci <michelececcacci1@gmail.com>Ayush Aryan <ayush.aryan71@gmail.com>Kishore Gopalakrishnan <kishore96@gmail.com>Jan-Philipp Hoffmann <sonntagsgesicht@icloud.com>Daiki Takahashi <haru.td@gmail.com>Sayan Mitra <ee18b156@smail.iitm.ac.in>Aman Kumar Shukla <theprofessionalaman@gmail.com>Zoufiné Lauer-Baré <raszoufine@gmail.com>Charles Harris <erdos4d@gmail.com>Tejaswini Sanapathi <sastejaswini2002@gmail.com>Devansh <be19b002@smail.iitm.ac.in>Aaron Gokaslan <aaronGokaslan@gmail.com>Daan Koning (he/him) <daanolivierkoning@gmail.com>Steven Burns <royalstream@hotmail.com>Jay Patankar <patankarjays@gmail.com>Vivek Soni <sonisheela1977@gmail.com>Le Cong Minh Hieu <hieu.lecongminh@gmail.com>Sam Ritchie <sam@mentat.org>Maciej Skórski <maciej.skorski@gmail.com>Tilo Reneau-Cardoso <tiloreneau@gmail.com>Laurence Warne <laurencewarne@gmail.com>Lukas Molleman <Lukas.Molleman@gmail.com>Konstantinos Riganas <kostasriganas24@gmail.com>Grace Su <grace.duansu@gmail.com>Pedro Rosa <pedro_sxbr@usp.br>Abhinav Cillanki <abhinavcillanki@kgpian.iitkgp.ac.in>Baiyuan Qiu <1061688677@qq.com>Liwei Cai <cai.lw123@gmail.com>Daniel Weindl <daniel.weindl@helmholtz-muenchen.de>Isidora Araya <iarayaday@gmail.com>Seb Tiburzio <sebtiburzio@gmail.com>Victory Omole <vtomole2@gmail.com>Abhishek Chaudhary <ac5003@columbia.edu>Alexander Zhura <nice.zhura@list.ru>Shuai Zhou <shuaivzhou@berkeley.edu>Martin Manns <mmanns@gmx.net>John Möller <john.moller@outlook.com>zzc <1378113190@qq.com>Pablo Galindo Salgado <pablogsal@gmail.com>Johannes Kasimir <johannes.kasimir@math.lu.se>Theodore Dias <theodore.dias@hotmail.co.uk>Kaustubh <90597818+kaustubh-765@users.noreply.github.com>Idan Pazi <idan.kp@gmail.com>Ishan Pandhare <91841626+Ishanned@users.noreply.github.com>Shishir Kushwaha <kushwahashishir1112@gmail.com>Bobby Palmer <bobbyp@umich.edu>Saikat Das <saikatdchhe@gmail.com>Suman mondal <smondal.qwerty@gmail.com>Taylan Sahin <info@taylansahin.net>Fabio Luporini <fabio@devitocodes.com>Oriel Malihi <orielmalihi1@gmail.com>Geetika Vadali <geetika.vadali4@gmail.com>Matthias Rettl <matthias.rettl@stud.unileoben.ac.at>Mikhail Remnev <maremnev@gmail.com>philwillnyc <56197213+philwillnyc@users.noreply.github.com>Raphael Lehner <raphael.lehner@gmail.com>Harry Mountain <harrymountain1@icloud.com>Bhavik Sachdev <b.sachdev1904@gmail.com>袁野 (Yuan Ye) <yuanyelele@tutanota.com>fazledyn-or <ataf@openrefactory.com>mohammedouahman <simofun85@gmail.com>K. Kraus <laqueray@googlemail.com>Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>platypus <platypus.computerchip@gmail.com>codecruisader <nnisarg55@gmail.com>James Whitehead <whiteheadj@gmail.com>atharvParlikar <atharvparlikar@gmail.com>Ivan Petukhov <satels@gmail.com>Augusto Borges <borges.augustoar@gmail.com>Han Wei Ang <ang.h.w@u.nus.edu>Congxu Yang <u7189828@anu.edu.au>Saicharan <62512681+saicharan2804@users.noreply.github.com>Arnab Nandi <arnabnandi2002@gmail.com>Harrison Oates <48871176+HarrisonOates@users.noreply.github.com>Corey Cerovsek <corey@cerovsek.com>Harsh Kasat <hkasat@waymore.io>omahs <73983677+omahs@users.noreply.github.com>Pascal Gitz <pascal.gitz@hotmail.ch>Ravindu-Hirimuthugoda <ravindu.18@cse.mrt.ac.lk>Sophia Pustova <tripplezzed@gmail.com>George Pittock <gpittock4@gmail.com>Warren Jacinto <warrenjacinto@gmail.com>Sachin Singh <sachinishu02@gmail.com>Zedmat <104870914+harshkasat@users.noreply.github.com>Samith Karunathilake <55777141+samithkavishke@users.noreply.github.com>Viraj Vekaria <virajv5593@gmail.com>Ankit Kumar Singh <ankitdiswar10@gmail.com>Abhishek Kumar <abhishek.nitdelhi@gmail.com>Mohak Malviya <mohakmalviya2000@gmail.com>Matthias Liesenfeld <116307294+maliesen@users.noreply.github.com>dodo <palumbododo@gmail.com>Mohamed Rezk <mohrizq895@gmail.com>Tommaso Vaccari <05-gesto-follemente@icloud.com>Alexis Schotte <alexis.schotte@gmail.com>Lauren Yim <31467609+cherryblossom000@users.noreply.github.com>Prey Patel <patel.prey@iitgn.ac.in>Riccardo Di Girolamo <riccardodigirolamo01@gmail.com>Abhishek kumar <kumar325571@gmail.com>Sam Lubelsky <sammy56lt@gmail.com>Henrique Soares <henrique.c.soares@tecnico.ulisboa.pt>Vladimir Sereda <voffch@gmail.com>Raj Sapale <raj4sapale4@gmail.com>Gerald Teschl <gerald.teschl@univie.ac.at>Richard Samuel <98638849+samuelard7@users.noreply.github.com>HeeJae Chang <hechang@microsoft.com>Hwayeon Kang <hwayeonniii@gmail.com>Nick Harder <nharder@umich.edu>Ethan DeGuire <ethandeguire@gmail.com>Lorenz Winkler <lorenz.winkler@tuwien.ac.at>Richard Rodenbusch <rrodenbusch@gmail.com>Zhenxu Zhu <xzdlj@outlook.com>Mark van Gelder <m.j.vangelder@student.tudelft.nl>James A. Preiss <jamesalanpreiss@gmail.com>Emile Fourcini <emile.fourcin1@gmail.com>Alberto Jiménez Ruiz <Alberto.Jimenez@uclm.es>João Bravo <joaocgbravo@tecnico.ulisboa.pt>Dean Price <dean1357price1357@gmail.com>Hugo Kerstens <hugo@kerstens.me>Jan Jancar <johny@neuromancer.sk>1pip123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153Copyright (c) 2006-2023 SymPy Development Team
All rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
a. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. b. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. c. Neither the name of SymPy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICTLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAYOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCHDAMAGE.
--------------------------------------------------------------------------------
Patches that were taken from the Diofant project (https://github.com/diofant/diofant)are licensed as:
Copyright (c) 2006-2018 SymPy Development Team, 2013-2023 Sergey B Kirpichev
All rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
a. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. b. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. c. Neither the name of Diofant or SymPy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICTLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAYOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCHDAMAGE.
--------------------------------------------------------------------------------
Submodules taken from the multipledispatch project (https://github.com/mrocklin/multipledispatch)are licensed as:
Copyright (c) 2014 Matthew Rocklin
All rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
a. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. b. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. c. Neither the name of multipledispatch nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICTLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAYOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCHDAMAGE.
--------------------------------------------------------------------------------
The files under the directory sympy/parsing/autolev/tests/pydy-example-repoare directly copied from PyDy project and are licensed as:
Copyright (c) 2009-2023, PyDy AuthorsAll rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.* Neither the name of this project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL PYDY AUTHORS BE LIABLE FOR ANY DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCEOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IFADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
The files under the directory sympy/parsing/latex are directly copied from latex2sympy project and are licensed as:
Copyright 2016, latex2sympy
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304Metadata-Version: 2.1Name: sympyVersion: 1.13.1Summary: Computer algebra system (CAS) in PythonHome-page: https://sympy.orgAuthor: SymPy development teamAuthor-email: sympy@googlegroups.comLicense: BSDProject-URL: Source, https://github.com/sympy/sympyKeywords: Math CASClassifier: License :: OSI Approved :: BSD LicenseClassifier: Operating System :: OS IndependentClassifier: Programming Language :: PythonClassifier: Topic :: Scientific/EngineeringClassifier: Topic :: Scientific/Engineering :: MathematicsClassifier: Topic :: Scientific/Engineering :: PhysicsClassifier: Programming Language :: Python :: 3Classifier: Programming Language :: Python :: 3.8Classifier: Programming Language :: Python :: 3.9Classifier: Programming Language :: Python :: 3.10Classifier: Programming Language :: Python :: 3.11Classifier: Programming Language :: Python :: 3 :: OnlyClassifier: Programming Language :: Python :: Implementation :: CPythonClassifier: Programming Language :: Python :: Implementation :: PyPyRequires-Python: >=3.8Description-Content-Type: text/markdownLicense-File: LICENSELicense-File: AUTHORSRequires-Dist: mpmath <1.4,>=1.1.0Provides-Extra: devRequires-Dist: pytest >=7.1.0 ; extra == 'dev'Requires-Dist: hypothesis >=6.70.0 ; extra == 'dev'
# SymPy
[](https://pypi.python.org/pypi/sympy)[](https://gitter.im/sympy/sympy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[](https://zenodo.org/badge/latestdoi/18918/sympy/sympy)[](https://pepy.tech/project/sympy)[](https://github.com/sympy/sympy/issues)[](https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project)[](https://numfocus.org)[](https://github.com/sympy/sympy/releases)
[](https://sympy.org/)
See the [AUTHORS](AUTHORS) file for the list of authors.
And many more people helped on the SymPy mailing list, reported bugs,helped organize SymPy's participation in the Google Summer of Code, theGoogle Highly Open Participation Contest, Google Code-In, wrote andblogged about SymPy...
License: New BSD License (see the [LICENSE](LICENSE) file for details) covers allfiles in the sympy repository unless stated otherwise.
Our mailing list is at<https://groups.google.com/forum/?fromgroups#!forum/sympy>.
We have a community chat at [Gitter](https://gitter.im/sympy/sympy). Feelfree to ask us anything there. We have a very welcoming and helpfulcommunity.
## Download
The recommended installation method is through Anaconda,<https://www.anaconda.com/products/distribution>
You can also get the latest version of SymPy from<https://pypi.python.org/pypi/sympy/>
To get the git version do
$ git clone https://github.com/sympy/sympy.git
For other options (tarballs, debs, etc.), see<https://docs.sympy.org/dev/install.html>.
## Documentation and Usage
For in-depth instructions on installation and building thedocumentation, see the [SymPy Documentation Style Guide](https://docs.sympy.org/dev/documentation-style-guide.html).
Everything is at:
<https://docs.sympy.org/>
You can generate everything at the above site in your local copy ofSymPy by:
$ cd doc $ make html
Then the docs will be in <span class="title-ref">\_build/html</span>. Ifyou don't want to read that, here is a short usage:
From this directory, start Python and:
``` python>>> from sympy import Symbol, cos>>> x = Symbol('x')>>> e = 1/cos(x)>>> print(e.series(x, 0, 10))1 + x**2/2 + 5*x**4/24 + 61*x**6/720 + 277*x**8/8064 + O(x**10)```
SymPy also comes with a console that is a simple wrapper around theclassic python console (or IPython when available) that loads the SymPynamespace and executes some common commands for you.
To start it, issue:
$ bin/isympy
from this directory, if SymPy is not installed or simply:
$ isympy
if SymPy is installed.
## Installation
To install SymPy using PyPI, run the following command:
$ pip install sympy
To install SymPy using Anaconda, run the following command:
$ conda install -c anaconda sympy
To install SymPy from GitHub source, first clone SymPy using `git`:
$ git clone https://github.com/sympy/sympy.git
Then, in the `sympy` repository that you cloned, simply run:
$ pip install .
See <https://docs.sympy.org/dev/install.html> for more information.
## Contributing
We welcome contributions from anyone, even if you are new to opensource. Please read our [Introduction to Contributing](https://docs.sympy.org/dev/contributing/introduction-to-contributing.html)page and the [SymPy Documentation Style Guide](https://docs.sympy.org/dev/documentation-style-guide.html). If youare new and looking for some way to contribute, a good place to start isto look at the issues tagged [Easy to Fix](https://github.com/sympy/sympy/issues?q=is%3Aopen+is%3Aissue+label%3A%22Easy+to+Fix%22).
Please note that all participants in this project are expected to followour Code of Conduct. By participating in this project you agree to abideby its terms. See [CODE\_OF\_CONDUCT.md](CODE_OF_CONDUCT.md).
## Tests
To execute all tests, run:
$./setup.py test
in the current directory.
For the more fine-grained running of tests or doctests, use `bin/test`or respectively `bin/doctest`. The master branch is automatically testedby GitHub Actions.
To test pull requests, use[sympy-bot](https://github.com/sympy/sympy-bot).
## Regenerate Experimental <span class="title-ref">LaTeX</span> Parser/Lexer
The parser and lexer were generated with the [ANTLR4](http://antlr4.org)toolchain in `sympy/parsing/latex/_antlr` and checked into the repo.Presently, most users should not need to regenerate these files, butif you plan to work on this feature, you will need the `antlr4`command-line tool (and you must ensure that it is in your `PATH`).One way to get it is:
$ conda install -c conda-forge antlr=4.11.1
Alternatively, follow the instructions on the ANTLR website and downloadthe `antlr-4.11.1-complete.jar`. Then export the `CLASSPATH` as instructedand instead of creating `antlr4` as an alias, make it an executable filewith the following contents:``` bash#!/bin/bashjava -jar /usr/local/lib/antlr-4.11.1-complete.jar "$@"```
After making changes to `sympy/parsing/latex/LaTeX.g4`, run:
$ ./setup.py antlr
## Clean
To clean everything (thus getting the same tree as in the repository):
$ git clean -Xdf
which will clear everything ignored by `.gitignore`, and:
$ git clean -df
to clear all untracked files. You can revert the most recent changes ingit with:
$ git reset --hard
WARNING: The above commands will all clear changes you may have made,and you will lose them forever. Be sure to check things with `gitstatus`, `git diff`, `git clean -Xn`, and `git clean -n` before doing anyof those.
## Bugs
Our issue tracker is at <https://github.com/sympy/sympy/issues>. Pleasereport any bugs that you find. Or, even better, fork the repository onGitHub and create a pull request. We welcome all changes, big or small,and we will help you make the pull request if you are new to git (justask on our mailing list or Gitter Channel). If you further have any queries, you can find answerson Stack Overflow using the [sympy](https://stackoverflow.com/questions/tagged/sympy) tag.
## Brief History
SymPy was started by Ondřej Čertík in 2005, he wrote some code duringthe summer, then he wrote some more code during summer 2006. In February2007, Fabian Pedregosa joined the project and helped fix many things,contributed documentation, and made it alive again. 5 students (MateuszPaprocki, Brian Jorgensen, Jason Gedge, Robert Schwarz, and Chris Wu)improved SymPy incredibly during summer 2007 as part of the GoogleSummer of Code. Pearu Peterson joined the development during the summer2007 and he has made SymPy much more competitive by rewriting the corefrom scratch, which has made it from 10x to 100x faster. Jurjen N.E. Boshas contributed pretty-printing and other patches. Fredrik Johansson haswritten mpmath and contributed a lot of patches.
SymPy has participated in every Google Summer of Code since 2007. Youcan see <https://github.com/sympy/sympy/wiki#google-summer-of-code> forfull details. Each year has improved SymPy by bounds. Most of SymPy'sdevelopment has come from Google Summer of Code students.
In 2011, Ondřej Čertík stepped down as lead developer, with AaronMeurer, who also started as a Google Summer of Code student, taking hisplace. Ondřej Čertík is still active in the community but is too busywith work and family to play a lead development role.
Since then, a lot more people have joined the development and somepeople have also left. You can see the full list in doc/src/aboutus.rst,or online at:
<https://docs.sympy.org/dev/aboutus.html#sympy-development-team>
The git history goes back to 2007 when development moved from svn to hg.To see the history before that point, look at<https://github.com/sympy/sympy-old>.
You can use git to see the biggest developers. The command:
$ git shortlog -ns
will show each developer, sorted by commits to the project. The command:
$ git shortlog -ns --since="1 year"
will show the top developers from the last year.
## Citation
To cite SymPy in publications use
> Meurer A, Smith CP, Paprocki M, Čertík O, Kirpichev SB, Rocklin M,> Kumar A, Ivanov S, Moore JK, Singh S, Rathnayake T, Vig S, Granger BE,> Muller RP, Bonazzi F, Gupta H, Vats S, Johansson F, Pedregosa F, Curry> MJ, Terrel AR, Roučka Š, Saboo A, Fernando I, Kulal S, Cimrman R,> Scopatz A. (2017) SymPy: symbolic computing in Python. *PeerJ Computer> Science* 3:e103 <https://doi.org/10.7717/peerj-cs.103>
A BibTeX entry for LaTeX users is
``` bibtex@article{10.7717/peerj-cs.103, title = {SymPy: symbolic computing in Python}, author = {Meurer, Aaron and Smith, Christopher P. and Paprocki, Mateusz and \v{C}ert\'{i}k, Ond\v{r}ej and Kirpichev, Sergey B. and Rocklin, Matthew and Kumar, Amit and Ivanov, Sergiu and Moore, Jason K. and Singh, Sartaj and Rathnayake, Thilina and Vig, Sean and Granger, Brian E. and Muller, Richard P. and Bonazzi, Francesco and Gupta, Harsh and Vats, Shivam and Johansson, Fredrik and Pedregosa, Fabian and Curry, Matthew J. and Terrel, Andy R. and Rou\v{c}ka, \v{S}t\v{e}p\'{a}n and Saboo, Ashutosh and Fernando, Isuru and Kulal, Sumith and Cimrman, Robert and Scopatz, Anthony}, year = 2017, month = Jan, keywords = {Python, Computer algebra system, Symbolics}, abstract = { SymPy is an open-source computer algebra system written in pure Python. It is built with a focus on extensibility and ease of use, through both interactive and programmatic applications. These characteristics have led SymPy to become a popular symbolic library for the scientific Python ecosystem. This paper presents the architecture of SymPy, a description of its features, and a discussion of select submodules. The supplementary material provides additional examples and further outlines details of the architecture and features of SymPy. }, volume = 3, pages = {e103}, journal = {PeerJ Computer Science}, issn = {2376-5992}, url = {https://doi.org/10.7717/peerj-cs.103}, doi = {10.7717/peerj-cs.103}}```
SymPy is BSD licensed, so you are free to use it whatever you like, beit academic, commercial, creating forks or derivatives, as long as youcopy the BSD statement if you redistribute it (see the LICENSE file fordetails). That said, although not required by the SymPy license, if itis convenient for you, please cite SymPy when using it in your work andalso consider contributing all your changes back, so that we canincorporate it and all of us will benefit in the end.12345Wheel-Version: 1.0Generator: setuptools (71.0.3)Root-Is-Purelib: trueTag: py3-none-any
12[console_scripts]isympy = isympy:main12isympysympy123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542"""SymPy is a Python library for symbolic mathematics. It aims to become afull-featured computer algebra system (CAS) while keeping the code as simpleas possible in order to be comprehensible and easily extensible. SymPy iswritten entirely in Python. It depends on mpmath, and other external librariesmay be optionally for things like plotting support.
See the webpage for more information and documentation:
https://sympy.org
"""
import sysif sys.version_info < (3, 8): raise ImportError("Python version 3.8 or above is required for SymPy.")del sys
try: import mpmathexcept ImportError: raise ImportError("SymPy now depends on mpmath as an external library. " "See https://docs.sympy.org/latest/install.html#mpmath for more information.")
del mpmath
from sympy.release import __version__from sympy.core.cache import lazy_function
if 'dev' in __version__: def enable_warnings(): import warnings warnings.filterwarnings('default', '.*', DeprecationWarning, module='sympy.*') del warnings enable_warnings() del enable_warnings
def __sympy_debug(): # helper function so we don't import os globally import os debug_str = os.getenv('SYMPY_DEBUG', 'False') if debug_str in ('True', 'False'): return eval(debug_str) else: raise RuntimeError("unrecognized value for SYMPY_DEBUG: %s" % debug_str)SYMPY_DEBUG = __sympy_debug() # type: bool
from .core import (sympify, SympifyError, cacheit, Basic, Atom, preorder_traversal, S, Expr, AtomicExpr, UnevaluatedExpr, Symbol, Wild, Dummy, symbols, var, Number, Float, Rational, Integer, NumberSymbol, RealNumber, igcd, ilcm, seterr, E, I, nan, oo, pi, zoo, AlgebraicNumber, comp, mod_inverse, Pow, integer_nthroot, integer_log, trailing, Mul, prod, Add, Mod, Rel, Eq, Ne, Lt, Le, Gt, Ge, Equality, GreaterThan, LessThan, Unequality, StrictGreaterThan, StrictLessThan, vectorize, Lambda, WildFunction, Derivative, diff, FunctionClass, Function, Subs, expand, PoleError, count_ops, expand_mul, expand_log, expand_func, expand_trig, expand_complex, expand_multinomial, nfloat, expand_power_base, expand_power_exp, arity, PrecisionExhausted, N, evalf, Tuple, Dict, gcd_terms, factor_terms, factor_nc, evaluate, Catalan, EulerGamma, GoldenRatio, TribonacciConstant, bottom_up, use, postorder_traversal, default_sort_key, ordered, num_digits)
from .logic import (to_cnf, to_dnf, to_nnf, And, Or, Not, Xor, Nand, Nor, Implies, Equivalent, ITE, POSform, SOPform, simplify_logic, bool_map, true, false, satisfiable)
from .assumptions import (AppliedPredicate, Predicate, AssumptionsContext, assuming, Q, ask, register_handler, remove_handler, refine)
from .polys import (Poly, PurePoly, poly_from_expr, parallel_poly_from_expr, degree, total_degree, degree_list, LC, LM, LT, pdiv, prem, pquo, pexquo, div, rem, quo, exquo, half_gcdex, gcdex, invert, subresultants, resultant, discriminant, cofactors, gcd_list, gcd, lcm_list, lcm, terms_gcd, trunc, monic, content, primitive, compose, decompose, sturm, gff_list, gff, sqf_norm, sqf_part, sqf_list, sqf, factor_list, factor, intervals, refine_root, count_roots, all_roots, real_roots, nroots, ground_roots, nth_power_roots_poly, cancel, reduced, groebner, is_zero_dimensional, GroebnerBasis, poly, symmetrize, horner, interpolate, rational_interpolate, viete, together, BasePolynomialError, ExactQuotientFailed, PolynomialDivisionFailed, OperationNotSupported, HeuristicGCDFailed, HomomorphismFailed, IsomorphismFailed, ExtraneousFactors, EvaluationFailed, RefinementFailed, CoercionFailed, NotInvertible, NotReversible, NotAlgebraic, DomainError, PolynomialError, UnificationFailed, GeneratorsError, GeneratorsNeeded, ComputationFailed, UnivariatePolynomialError, MultivariatePolynomialError, PolificationFailed, OptionError, FlagError, minpoly, minimal_polynomial, primitive_element, field_isomorphism, to_number_field, isolate, round_two, prime_decomp, prime_valuation, galois_group, itermonomials, Monomial, lex, grlex, grevlex, ilex, igrlex, igrevlex, CRootOf, rootof, RootOf, ComplexRootOf, RootSum, roots, Domain, FiniteField, IntegerRing, RationalField, RealField, ComplexField, PythonFiniteField, GMPYFiniteField, PythonIntegerRing, GMPYIntegerRing, PythonRational, GMPYRationalField, AlgebraicField, PolynomialRing, FractionField, ExpressionDomain, FF_python, FF_gmpy, ZZ_python, ZZ_gmpy, QQ_python, QQ_gmpy, GF, FF, ZZ, QQ, ZZ_I, QQ_I, RR, CC, EX, EXRAW, construct_domain, swinnerton_dyer_poly, cyclotomic_poly, symmetric_poly, random_poly, interpolating_poly, jacobi_poly, chebyshevt_poly, chebyshevu_poly, hermite_poly, hermite_prob_poly, legendre_poly, laguerre_poly, apart, apart_list, assemble_partfrac_list, Options, ring, xring, vring, sring, field, xfield, vfield, sfield)
from .series import (Order, O, limit, Limit, gruntz, series, approximants, residue, EmptySequence, SeqPer, SeqFormula, sequence, SeqAdd, SeqMul, fourier_series, fps, difference_delta, limit_seq)
from .functions import (factorial, factorial2, rf, ff, binomial, RisingFactorial, FallingFactorial, subfactorial, carmichael, fibonacci, lucas, motzkin, tribonacci, harmonic, bernoulli, bell, euler, catalan, genocchi, andre, partition, divisor_sigma, legendre_symbol, jacobi_symbol, kronecker_symbol, mobius, primenu, primeomega, totient, reduced_totient, primepi, sqrt, root, Min, Max, Id, real_root, Rem, cbrt, re, im, sign, Abs, conjugate, arg, polar_lift, periodic_argument, unbranched_argument, principal_branch, transpose, adjoint, polarify, unpolarify, sin, cos, tan, sec, csc, cot, sinc, asin, acos, atan, asec, acsc, acot, atan2, exp_polar, exp, ln, log, LambertW, sinh, cosh, tanh, coth, sech, csch, asinh, acosh, atanh, acoth, asech, acsch, floor, ceiling, frac, Piecewise, piecewise_fold, piecewise_exclusive, erf, erfc, erfi, erf2, erfinv, erfcinv, erf2inv, Ei, expint, E1, li, Li, Si, Ci, Shi, Chi, fresnels, fresnelc, gamma, lowergamma, uppergamma, polygamma, loggamma, digamma, trigamma, multigamma, dirichlet_eta, zeta, lerchphi, polylog, stieltjes, Eijk, LeviCivita, KroneckerDelta, SingularityFunction, DiracDelta, Heaviside, bspline_basis, bspline_basis_set, interpolating_spline, besselj, bessely, besseli, besselk, hankel1, hankel2, jn, yn, jn_zeros, hn1, hn2, airyai, airybi, airyaiprime, airybiprime, marcumq, hyper, meijerg, appellf1, legendre, assoc_legendre, hermite, hermite_prob, chebyshevt, chebyshevu, chebyshevu_root, chebyshevt_root, laguerre, assoc_laguerre, gegenbauer, jacobi, jacobi_normalized, Ynm, Ynm_c, Znm, elliptic_k, elliptic_f, elliptic_e, elliptic_pi, beta, mathieus, mathieuc, mathieusprime, mathieucprime, riemann_xi, betainc, betainc_regularized)
from .ntheory import (nextprime, prevprime, prime, primerange, randprime, Sieve, sieve, primorial, cycle_length, composite, compositepi, isprime, divisors, proper_divisors, factorint, multiplicity, perfect_power, pollard_pm1, pollard_rho, primefactors, divisor_count, proper_divisor_count, factorrat, mersenne_prime_exponent, is_perfect, is_mersenne_prime, is_abundant, is_deficient, is_amicable, is_carmichael, abundance, npartitions, is_primitive_root, is_quad_residue, n_order, sqrt_mod, quadratic_residues, primitive_root, nthroot_mod, is_nthpow_residue, sqrt_mod_iter, discrete_log, quadratic_congruence, binomial_coefficients, binomial_coefficients_list, multinomial_coefficients, continued_fraction_periodic, continued_fraction_iterator, continued_fraction_reduce, continued_fraction_convergents, continued_fraction, egyptian_fraction)
from .concrete import product, Product, summation, Sum
from .discrete import (fft, ifft, ntt, intt, fwht, ifwht, mobius_transform, inverse_mobius_transform, convolution, covering_product, intersecting_product)
from .simplify import (simplify, hypersimp, hypersimilar, logcombine, separatevars, posify, besselsimp, kroneckersimp, signsimp, nsimplify, FU, fu, sqrtdenest, cse, epath, EPath, hyperexpand, collect, rcollect, radsimp, collect_const, fraction, numer, denom, trigsimp, exptrigsimp, powsimp, powdenest, combsimp, gammasimp, ratsimp, ratsimpmodprime)
from .sets import (Set, Interval, Union, EmptySet, FiniteSet, ProductSet, Intersection, DisjointUnion, imageset, Complement, SymmetricDifference, ImageSet, Range, ComplexRegion, Complexes, Reals, Contains, ConditionSet, Ordinal, OmegaPower, ord0, PowerSet, Naturals, Naturals0, UniversalSet, Integers, Rationals)
from .solvers import (solve, solve_linear_system, solve_linear_system_LU, solve_undetermined_coeffs, nsolve, solve_linear, checksol, det_quick, inv_quick, check_assumptions, failing_assumptions, diophantine, rsolve, rsolve_poly, rsolve_ratio, rsolve_hyper, checkodesol, classify_ode, dsolve, homogeneous_order, solve_poly_system, solve_triangulated, pde_separate, pde_separate_add, pde_separate_mul, pdsolve, classify_pde, checkpdesol, ode_order, reduce_inequalities, reduce_abs_inequality, reduce_abs_inequalities, solve_poly_inequality, solve_rational_inequalities, solve_univariate_inequality, decompogen, solveset, linsolve, linear_eq_to_matrix, nonlinsolve, substitution)
from .matrices import (ShapeError, NonSquareMatrixError, GramSchmidt, casoratian, diag, eye, hessian, jordan_cell, list2numpy, matrix2numpy, matrix_multiply_elementwise, ones, randMatrix, rot_axis1, rot_axis2, rot_axis3, symarray, wronskian, zeros, MutableDenseMatrix, DeferredVector, MatrixBase, Matrix, MutableMatrix, MutableSparseMatrix, banded, ImmutableDenseMatrix, ImmutableSparseMatrix, ImmutableMatrix, SparseMatrix, MatrixSlice, BlockDiagMatrix, BlockMatrix, FunctionMatrix, Identity, Inverse, MatAdd, MatMul, MatPow, MatrixExpr, MatrixSymbol, Trace, Transpose, ZeroMatrix, OneMatrix, blockcut, block_collapse, matrix_symbols, Adjoint, hadamard_product, HadamardProduct, HadamardPower, Determinant, det, diagonalize_vector, DiagMatrix, DiagonalMatrix, DiagonalOf, trace, DotProduct, kronecker_product, KroneckerProduct, PermutationMatrix, MatrixPermute, Permanent, per, rot_ccw_axis1, rot_ccw_axis2, rot_ccw_axis3, rot_givens)
from .geometry import (Point, Point2D, Point3D, Line, Ray, Segment, Line2D, Segment2D, Ray2D, Line3D, Segment3D, Ray3D, Plane, Ellipse, Circle, Polygon, RegularPolygon, Triangle, rad, deg, are_similar, centroid, convex_hull, idiff, intersection, closest_points, farthest_points, GeometryError, Curve, Parabola)
from .utilities import (flatten, group, take, subsets, variations, numbered_symbols, cartes, capture, dict_merge, prefixes, postfixes, sift, topological_sort, unflatten, has_dups, has_variety, reshape, rotations, filldedent, lambdify, threaded, xthreaded, public, memoize_property, timed)
from .integrals import (integrate, Integral, line_integrate, mellin_transform, inverse_mellin_transform, MellinTransform, InverseMellinTransform, laplace_transform, laplace_correspondence, laplace_initial_conds, inverse_laplace_transform, LaplaceTransform, InverseLaplaceTransform, fourier_transform, inverse_fourier_transform, FourierTransform, InverseFourierTransform, sine_transform, inverse_sine_transform, SineTransform, InverseSineTransform, cosine_transform, inverse_cosine_transform, CosineTransform, InverseCosineTransform, hankel_transform, inverse_hankel_transform, HankelTransform, InverseHankelTransform, singularityintegrate)
from .tensor import (IndexedBase, Idx, Indexed, get_contraction_structure, get_indices, shape, MutableDenseNDimArray, ImmutableDenseNDimArray, MutableSparseNDimArray, ImmutableSparseNDimArray, NDimArray, tensorproduct, tensorcontraction, tensordiagonal, derive_by_array, permutedims, Array, DenseNDimArray, SparseNDimArray)
from .parsing import parse_expr
from .calculus import (euler_equations, singularities, is_increasing, is_strictly_increasing, is_decreasing, is_strictly_decreasing, is_monotonic, finite_diff_weights, apply_finite_diff, differentiate_finite, periodicity, not_empty_in, AccumBounds, is_convex, stationary_points, minimum, maximum)
from .algebras import Quaternion
from .printing import (pager_print, pretty, pretty_print, pprint, pprint_use_unicode, pprint_try_use_unicode, latex, print_latex, multiline_latex, mathml, print_mathml, python, print_python, pycode, ccode, print_ccode, smtlib_code, glsl_code, print_glsl, cxxcode, fcode, print_fcode, rcode, print_rcode, jscode, print_jscode, julia_code, mathematica_code, octave_code, rust_code, print_gtk, preview, srepr, print_tree, StrPrinter, sstr, sstrrepr, TableForm, dotprint, maple_code, print_maple_code)
test = lazy_function('sympy.testing.runtests_pytest', 'test')doctest = lazy_function('sympy.testing.runtests', 'doctest')
# This module causes conflicts with other modules:# from .stats import *# Adds about .04-.05 seconds of import time# from combinatorics import *# This module is slow to import:#from physics import unitsfrom .plotting import plot, textplot, plot_backends, plot_implicit, plot_parametricfrom .interactive import init_session, init_printing, interactive_traversal
evalf._create_evalf_table()
__all__ = [ '__version__',
# sympy.core 'sympify', 'SympifyError', 'cacheit', 'Basic', 'Atom', 'preorder_traversal', 'S', 'Expr', 'AtomicExpr', 'UnevaluatedExpr', 'Symbol', 'Wild', 'Dummy', 'symbols', 'var', 'Number', 'Float', 'Rational', 'Integer', 'NumberSymbol', 'RealNumber', 'igcd', 'ilcm', 'seterr', 'E', 'I', 'nan', 'oo', 'pi', 'zoo', 'AlgebraicNumber', 'comp', 'mod_inverse', 'Pow', 'integer_nthroot', 'integer_log', 'trailing', 'Mul', 'prod', 'Add', 'Mod', 'Rel', 'Eq', 'Ne', 'Lt', 'Le', 'Gt', 'Ge', 'Equality', 'GreaterThan', 'LessThan', 'Unequality', 'StrictGreaterThan', 'StrictLessThan', 'vectorize', 'Lambda', 'WildFunction', 'Derivative', 'diff', 'FunctionClass', 'Function', 'Subs', 'expand', 'PoleError', 'count_ops', 'expand_mul', 'expand_log', 'expand_func', 'expand_trig', 'expand_complex', 'expand_multinomial', 'nfloat', 'expand_power_base', 'expand_power_exp', 'arity', 'PrecisionExhausted', 'N', 'evalf', 'Tuple', 'Dict', 'gcd_terms', 'factor_terms', 'factor_nc', 'evaluate', 'Catalan', 'EulerGamma', 'GoldenRatio', 'TribonacciConstant', 'bottom_up', 'use', 'postorder_traversal', 'default_sort_key', 'ordered', 'num_digits',
# sympy.logic 'to_cnf', 'to_dnf', 'to_nnf', 'And', 'Or', 'Not', 'Xor', 'Nand', 'Nor', 'Implies', 'Equivalent', 'ITE', 'POSform', 'SOPform', 'simplify_logic', 'bool_map', 'true', 'false', 'satisfiable',
# sympy.assumptions 'AppliedPredicate', 'Predicate', 'AssumptionsContext', 'assuming', 'Q', 'ask', 'register_handler', 'remove_handler', 'refine',
# sympy.polys 'Poly', 'PurePoly', 'poly_from_expr', 'parallel_poly_from_expr', 'degree', 'total_degree', 'degree_list', 'LC', 'LM', 'LT', 'pdiv', 'prem', 'pquo', 'pexquo', 'div', 'rem', 'quo', 'exquo', 'half_gcdex', 'gcdex', 'invert', 'subresultants', 'resultant', 'discriminant', 'cofactors', 'gcd_list', 'gcd', 'lcm_list', 'lcm', 'terms_gcd', 'trunc', 'monic', 'content', 'primitive', 'compose', 'decompose', 'sturm', 'gff_list', 'gff', 'sqf_norm', 'sqf_part', 'sqf_list', 'sqf', 'factor_list', 'factor', 'intervals', 'refine_root', 'count_roots', 'all_roots', 'real_roots', 'nroots', 'ground_roots', 'nth_power_roots_poly', 'cancel', 'reduced', 'groebner', 'is_zero_dimensional', 'GroebnerBasis', 'poly', 'symmetrize', 'horner', 'interpolate', 'rational_interpolate', 'viete', 'together', 'BasePolynomialError', 'ExactQuotientFailed', 'PolynomialDivisionFailed', 'OperationNotSupported', 'HeuristicGCDFailed', 'HomomorphismFailed', 'IsomorphismFailed', 'ExtraneousFactors', 'EvaluationFailed', 'RefinementFailed', 'CoercionFailed', 'NotInvertible', 'NotReversible', 'NotAlgebraic', 'DomainError', 'PolynomialError', 'UnificationFailed', 'GeneratorsError', 'GeneratorsNeeded', 'ComputationFailed', 'UnivariatePolynomialError', 'MultivariatePolynomialError', 'PolificationFailed', 'OptionError', 'FlagError', 'minpoly', 'minimal_polynomial', 'primitive_element', 'field_isomorphism', 'to_number_field', 'isolate', 'round_two', 'prime_decomp', 'prime_valuation', 'galois_group', 'itermonomials', 'Monomial', 'lex', 'grlex', 'grevlex', 'ilex', 'igrlex', 'igrevlex', 'CRootOf', 'rootof', 'RootOf', 'ComplexRootOf', 'RootSum', 'roots', 'Domain', 'FiniteField', 'IntegerRing', 'RationalField', 'RealField', 'ComplexField', 'PythonFiniteField', 'GMPYFiniteField', 'PythonIntegerRing', 'GMPYIntegerRing', 'PythonRational', 'GMPYRationalField', 'AlgebraicField', 'PolynomialRing', 'FractionField', 'ExpressionDomain', 'FF_python', 'FF_gmpy', 'ZZ_python', 'ZZ_gmpy', 'QQ_python', 'QQ_gmpy', 'GF', 'FF', 'ZZ', 'QQ', 'ZZ_I', 'QQ_I', 'RR', 'CC', 'EX', 'EXRAW', 'construct_domain', 'swinnerton_dyer_poly', 'cyclotomic_poly', 'symmetric_poly', 'random_poly', 'interpolating_poly', 'jacobi_poly', 'chebyshevt_poly', 'chebyshevu_poly', 'hermite_poly', 'hermite_prob_poly', 'legendre_poly', 'laguerre_poly', 'apart', 'apart_list', 'assemble_partfrac_list', 'Options', 'ring', 'xring', 'vring', 'sring', 'field', 'xfield', 'vfield', 'sfield',
# sympy.series 'Order', 'O', 'limit', 'Limit', 'gruntz', 'series', 'approximants', 'residue', 'EmptySequence', 'SeqPer', 'SeqFormula', 'sequence', 'SeqAdd', 'SeqMul', 'fourier_series', 'fps', 'difference_delta', 'limit_seq',
# sympy.functions 'factorial', 'factorial2', 'rf', 'ff', 'binomial', 'RisingFactorial', 'FallingFactorial', 'subfactorial', 'carmichael', 'fibonacci', 'lucas', 'motzkin', 'tribonacci', 'harmonic', 'bernoulli', 'bell', 'euler', 'catalan', 'genocchi', 'andre', 'partition', 'divisor_sigma', 'legendre_symbol', 'jacobi_symbol', 'kronecker_symbol', 'mobius', 'primenu', 'primeomega', 'totient', 'primepi', 'reduced_totient', 'sqrt', 'root', 'Min', 'Max', 'Id', 'real_root', 'Rem', 'cbrt', 're', 'im', 'sign', 'Abs', 'conjugate', 'arg', 'polar_lift', 'periodic_argument', 'unbranched_argument', 'principal_branch', 'transpose', 'adjoint', 'polarify', 'unpolarify', 'sin', 'cos', 'tan', 'sec', 'csc', 'cot', 'sinc', 'asin', 'acos', 'atan', 'asec', 'acsc', 'acot', 'atan2', 'exp_polar', 'exp', 'ln', 'log', 'LambertW', 'sinh', 'cosh', 'tanh', 'coth', 'sech', 'csch', 'asinh', 'acosh', 'atanh', 'acoth', 'asech', 'acsch', 'floor', 'ceiling', 'frac', 'Piecewise', 'piecewise_fold', 'piecewise_exclusive', 'erf', 'erfc', 'erfi', 'erf2', 'erfinv', 'erfcinv', 'erf2inv', 'Ei', 'expint', 'E1', 'li', 'Li', 'Si', 'Ci', 'Shi', 'Chi', 'fresnels', 'fresnelc', 'gamma', 'lowergamma', 'uppergamma', 'polygamma', 'loggamma', 'digamma', 'trigamma', 'multigamma', 'dirichlet_eta', 'zeta', 'lerchphi', 'polylog', 'stieltjes', 'Eijk', 'LeviCivita', 'KroneckerDelta', 'SingularityFunction', 'DiracDelta', 'Heaviside', 'bspline_basis', 'bspline_basis_set', 'interpolating_spline', 'besselj', 'bessely', 'besseli', 'besselk', 'hankel1', 'hankel2', 'jn', 'yn', 'jn_zeros', 'hn1', 'hn2', 'airyai', 'airybi', 'airyaiprime', 'airybiprime', 'marcumq', 'hyper', 'meijerg', 'appellf1', 'legendre', 'assoc_legendre', 'hermite', 'hermite_prob', 'chebyshevt', 'chebyshevu', 'chebyshevu_root', 'chebyshevt_root', 'laguerre', 'assoc_laguerre', 'gegenbauer', 'jacobi', 'jacobi_normalized', 'Ynm', 'Ynm_c', 'Znm', 'elliptic_k', 'elliptic_f', 'elliptic_e', 'elliptic_pi', 'beta', 'mathieus', 'mathieuc', 'mathieusprime', 'mathieucprime', 'riemann_xi','betainc', 'betainc_regularized',
# sympy.ntheory 'nextprime', 'prevprime', 'prime', 'primerange', 'randprime', 'Sieve', 'sieve', 'primorial', 'cycle_length', 'composite', 'compositepi', 'isprime', 'divisors', 'proper_divisors', 'factorint', 'multiplicity', 'perfect_power', 'pollard_pm1', 'pollard_rho', 'primefactors', 'divisor_count', 'proper_divisor_count', 'factorrat', 'mersenne_prime_exponent', 'is_perfect', 'is_mersenne_prime', 'is_abundant', 'is_deficient', 'is_amicable', 'is_carmichael', 'abundance', 'npartitions', 'is_primitive_root', 'is_quad_residue', 'n_order', 'sqrt_mod', 'quadratic_residues', 'primitive_root', 'nthroot_mod', 'is_nthpow_residue', 'sqrt_mod_iter', 'discrete_log', 'quadratic_congruence', 'binomial_coefficients', 'binomial_coefficients_list', 'multinomial_coefficients', 'continued_fraction_periodic', 'continued_fraction_iterator', 'continued_fraction_reduce', 'continued_fraction_convergents', 'continued_fraction', 'egyptian_fraction',
# sympy.concrete 'product', 'Product', 'summation', 'Sum',
# sympy.discrete 'fft', 'ifft', 'ntt', 'intt', 'fwht', 'ifwht', 'mobius_transform', 'inverse_mobius_transform', 'convolution', 'covering_product', 'intersecting_product',
# sympy.simplify 'simplify', 'hypersimp', 'hypersimilar', 'logcombine', 'separatevars', 'posify', 'besselsimp', 'kroneckersimp', 'signsimp', 'nsimplify', 'FU', 'fu', 'sqrtdenest', 'cse', 'epath', 'EPath', 'hyperexpand', 'collect', 'rcollect', 'radsimp', 'collect_const', 'fraction', 'numer', 'denom', 'trigsimp', 'exptrigsimp', 'powsimp', 'powdenest', 'combsimp', 'gammasimp', 'ratsimp', 'ratsimpmodprime',
# sympy.sets 'Set', 'Interval', 'Union', 'EmptySet', 'FiniteSet', 'ProductSet', 'Intersection', 'imageset', 'DisjointUnion', 'Complement', 'SymmetricDifference', 'ImageSet', 'Range', 'ComplexRegion', 'Reals', 'Contains', 'ConditionSet', 'Ordinal', 'OmegaPower', 'ord0', 'PowerSet', 'Naturals', 'Naturals0', 'UniversalSet', 'Integers', 'Rationals', 'Complexes',
# sympy.solvers 'solve', 'solve_linear_system', 'solve_linear_system_LU', 'solve_undetermined_coeffs', 'nsolve', 'solve_linear', 'checksol', 'det_quick', 'inv_quick', 'check_assumptions', 'failing_assumptions', 'diophantine', 'rsolve', 'rsolve_poly', 'rsolve_ratio', 'rsolve_hyper', 'checkodesol', 'classify_ode', 'dsolve', 'homogeneous_order', 'solve_poly_system', 'solve_triangulated', 'pde_separate', 'pde_separate_add', 'pde_separate_mul', 'pdsolve', 'classify_pde', 'checkpdesol', 'ode_order', 'reduce_inequalities', 'reduce_abs_inequality', 'reduce_abs_inequalities', 'solve_poly_inequality', 'solve_rational_inequalities', 'solve_univariate_inequality', 'decompogen', 'solveset', 'linsolve', 'linear_eq_to_matrix', 'nonlinsolve', 'substitution',
# sympy.matrices 'ShapeError', 'NonSquareMatrixError', 'GramSchmidt', 'casoratian', 'diag', 'eye', 'hessian', 'jordan_cell', 'list2numpy', 'matrix2numpy', 'matrix_multiply_elementwise', 'ones', 'randMatrix', 'rot_axis1', 'rot_axis2', 'rot_axis3', 'symarray', 'wronskian', 'zeros', 'MutableDenseMatrix', 'DeferredVector', 'MatrixBase', 'Matrix', 'MutableMatrix', 'MutableSparseMatrix', 'banded', 'ImmutableDenseMatrix', 'ImmutableSparseMatrix', 'ImmutableMatrix', 'SparseMatrix', 'MatrixSlice', 'BlockDiagMatrix', 'BlockMatrix', 'FunctionMatrix', 'Identity', 'Inverse', 'MatAdd', 'MatMul', 'MatPow', 'MatrixExpr', 'MatrixSymbol', 'Trace', 'Transpose', 'ZeroMatrix', 'OneMatrix', 'blockcut', 'block_collapse', 'matrix_symbols', 'Adjoint', 'hadamard_product', 'HadamardProduct', 'HadamardPower', 'Determinant', 'det', 'diagonalize_vector', 'DiagMatrix', 'DiagonalMatrix', 'DiagonalOf', 'trace', 'DotProduct', 'kronecker_product', 'KroneckerProduct', 'PermutationMatrix', 'MatrixPermute', 'Permanent', 'per', 'rot_ccw_axis1', 'rot_ccw_axis2', 'rot_ccw_axis3', 'rot_givens',
# sympy.geometry 'Point', 'Point2D', 'Point3D', 'Line', 'Ray', 'Segment', 'Line2D', 'Segment2D', 'Ray2D', 'Line3D', 'Segment3D', 'Ray3D', 'Plane', 'Ellipse', 'Circle', 'Polygon', 'RegularPolygon', 'Triangle', 'rad', 'deg', 'are_similar', 'centroid', 'convex_hull', 'idiff', 'intersection', 'closest_points', 'farthest_points', 'GeometryError', 'Curve', 'Parabola',
# sympy.utilities 'flatten', 'group', 'take', 'subsets', 'variations', 'numbered_symbols', 'cartes', 'capture', 'dict_merge', 'prefixes', 'postfixes', 'sift', 'topological_sort', 'unflatten', 'has_dups', 'has_variety', 'reshape', 'rotations', 'filldedent', 'lambdify', 'threaded', 'xthreaded', 'public', 'memoize_property', 'timed',
# sympy.integrals 'integrate', 'Integral', 'line_integrate', 'mellin_transform', 'inverse_mellin_transform', 'MellinTransform', 'InverseMellinTransform', 'laplace_transform', 'inverse_laplace_transform', 'LaplaceTransform', 'laplace_correspondence', 'laplace_initial_conds', 'InverseLaplaceTransform', 'fourier_transform', 'inverse_fourier_transform', 'FourierTransform', 'InverseFourierTransform', 'sine_transform', 'inverse_sine_transform', 'SineTransform', 'InverseSineTransform', 'cosine_transform', 'inverse_cosine_transform', 'CosineTransform', 'InverseCosineTransform', 'hankel_transform', 'inverse_hankel_transform', 'HankelTransform', 'InverseHankelTransform', 'singularityintegrate',
# sympy.tensor 'IndexedBase', 'Idx', 'Indexed', 'get_contraction_structure', 'get_indices', 'shape', 'MutableDenseNDimArray', 'ImmutableDenseNDimArray', 'MutableSparseNDimArray', 'ImmutableSparseNDimArray', 'NDimArray', 'tensorproduct', 'tensorcontraction', 'tensordiagonal', 'derive_by_array', 'permutedims', 'Array', 'DenseNDimArray', 'SparseNDimArray',
# sympy.parsing 'parse_expr',
# sympy.calculus 'euler_equations', 'singularities', 'is_increasing', 'is_strictly_increasing', 'is_decreasing', 'is_strictly_decreasing', 'is_monotonic', 'finite_diff_weights', 'apply_finite_diff', 'differentiate_finite', 'periodicity', 'not_empty_in', 'AccumBounds', 'is_convex', 'stationary_points', 'minimum', 'maximum',
# sympy.algebras 'Quaternion',
# sympy.printing 'pager_print', 'pretty', 'pretty_print', 'pprint', 'pprint_use_unicode', 'pprint_try_use_unicode', 'latex', 'print_latex', 'multiline_latex', 'mathml', 'print_mathml', 'python', 'print_python', 'pycode', 'ccode', 'print_ccode', 'smtlib_code', 'glsl_code', 'print_glsl', 'cxxcode', 'fcode', 'print_fcode', 'rcode', 'print_rcode', 'jscode', 'print_jscode', 'julia_code', 'mathematica_code', 'octave_code', 'rust_code', 'print_gtk', 'preview', 'srepr', 'print_tree', 'StrPrinter', 'sstr', 'sstrrepr', 'TableForm', 'dotprint', 'maple_code', 'print_maple_code',
# sympy.plotting 'plot', 'textplot', 'plot_backends', 'plot_implicit', 'plot_parametric',
# sympy.interactive 'init_session', 'init_printing', 'interactive_traversal',
# sympy.testing 'test', 'doctest',]
#===========================================================================## ## XXX: The names below were importable before SymPy 1.6 using ## ## from sympy import * ## ## This happened implicitly because there was no __all__ defined in this ## __init__.py file. Not every package is imported. The list matches what ## would have been imported before. It is possible that these packages will ## not be imported by a star-import from sympy in future. ## ##===========================================================================#
__all__.extend(( 'algebras', 'assumptions', 'calculus', 'concrete', 'discrete', 'external', 'functions', 'geometry', 'interactive', 'multipledispatch', 'ntheory', 'parsing', 'plotting', 'polys', 'printing', 'release', 'strategies', 'tensor', 'utilities',))123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111"""This module exports all latin and greek letters as Symbols, so you canconveniently do
>>> from sympy.abc import x, y
instead of the slightly more clunky-looking
>>> from sympy import symbols >>> x, y = symbols('x y')
Caveats=======
1. As of the time of writing this, the names ``O``, ``S``, ``I``, ``N``,``E``, and ``Q`` are colliding with names defined in SymPy. If you import themfrom both ``sympy.abc`` and ``sympy``, the second import will "win".This is an issue only for * imports, which should only be used for short-livedcode such as interactive sessions and throwaway scripts that do not surviveuntil the next SymPy upgrade, where ``sympy`` may contain a different set ofnames.
2. This module does not define symbol names on demand, i.e.``from sympy.abc import foo`` will be reported as an error because``sympy.abc`` does not contain the name ``foo``. To get a symbol named ``foo``,you still need to use ``Symbol('foo')`` or ``symbols('foo')``.You can freely mix usage of ``sympy.abc`` and ``Symbol``/``symbols``, thoughsticking with one and only one way to get the symbols does tend to make the codemore readable.
The module also defines some special names to help detect which names clashwith the default SymPy namespace.
``_clash1`` defines all the single letter variables that clash withSymPy objects; ``_clash2`` defines the multi-letter clashing symbols;and ``_clash`` is the union of both. These can be passed for ``locals``during sympification if one desires Symbols rather than the non-Symbolobjects for those names.
Examples========
>>> from sympy import S>>> from sympy.abc import _clash1, _clash2, _clash>>> S("Q & C", locals=_clash1)C & Q>>> S('pi(x)', locals=_clash2)pi(x)>>> S('pi(C, Q)', locals=_clash)pi(C, Q)
"""
from typing import Any, Dict as tDict
import string
from .core import Symbol, symbolsfrom .core.alphabets import greeksfrom sympy.parsing.sympy_parser import null
##### Symbol definitions #####
# Implementation note: The easiest way to avoid typos in the symbols()# parameter is to copy it from the left-hand side of the assignment.
a, b, c, d, e, f, g, h, i, j = symbols('a, b, c, d, e, f, g, h, i, j')k, l, m, n, o, p, q, r, s, t = symbols('k, l, m, n, o, p, q, r, s, t')u, v, w, x, y, z = symbols('u, v, w, x, y, z')
A, B, C, D, E, F, G, H, I, J = symbols('A, B, C, D, E, F, G, H, I, J')K, L, M, N, O, P, Q, R, S, T = symbols('K, L, M, N, O, P, Q, R, S, T')U, V, W, X, Y, Z = symbols('U, V, W, X, Y, Z')
alpha, beta, gamma, delta = symbols('alpha, beta, gamma, delta')epsilon, zeta, eta, theta = symbols('epsilon, zeta, eta, theta')iota, kappa, lamda, mu = symbols('iota, kappa, lamda, mu')nu, xi, omicron, pi = symbols('nu, xi, omicron, pi')rho, sigma, tau, upsilon = symbols('rho, sigma, tau, upsilon')phi, chi, psi, omega = symbols('phi, chi, psi, omega')
##### Clashing-symbols diagnostics #####
# We want to know which names in SymPy collide with those in here.# This is mostly for diagnosing SymPy's namespace during SymPy development.
_latin = list(string.ascii_letters)# QOSINE should not be imported as they clash; gamma, pi and zeta clash, too_greek = list(greeks) # make a copy, so we can mutate it# Note: We import lamda since lambda is a reserved keyword in Python_greek.remove("lambda")_greek.append("lamda")
ns: tDict[str, Any] = {}exec('from sympy import *', ns)_clash1: tDict[str, Any] = {}_clash2: tDict[str, Any] = {}while ns: _k, _ = ns.popitem() if _k in _greek: _clash2[_k] = null _greek.remove(_k) elif _k in _latin: _clash1[_k] = null _latin.remove(_k)_clash = {}_clash.update(_clash1)_clash.update(_clash2)
del _latin, _greek, Symbol, _k, null123from .quaternion import Quaternion
__all__ = ["Quaternion",]12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667from sympy.core.numbers import Rationalfrom sympy.core.singleton import Sfrom sympy.core.relational import is_eqfrom sympy.functions.elementary.complexes import (conjugate, im, re, sign)from sympy.functions.elementary.exponential import (exp, log as ln)from sympy.functions.elementary.miscellaneous import sqrtfrom sympy.functions.elementary.trigonometric import (acos, asin, atan2)from sympy.functions.elementary.trigonometric import (cos, sin)from sympy.simplify.trigsimp import trigsimpfrom sympy.integrals.integrals import integratefrom sympy.matrices.dense import MutableDenseMatrix as Matrixfrom sympy.core.sympify import sympify, _sympifyfrom sympy.core.expr import Exprfrom sympy.core.logic import fuzzy_not, fuzzy_orfrom sympy.utilities.misc import as_int
from mpmath.libmp.libmpf import prec_to_dps
def _check_norm(elements, norm): """validate if input norm is consistent""" if norm is not None and norm.is_number: if norm.is_positive is False: raise ValueError("Input norm must be positive.")
numerical = all(i.is_number and i.is_real is True for i in elements) if numerical and is_eq(norm**2, sum(i**2 for i in elements)) is False: raise ValueError("Incompatible value for norm.")
def _is_extrinsic(seq): """validate seq and return True if seq is lowercase and False if uppercase""" if type(seq) != str: raise ValueError('Expected seq to be a string.') if len(seq) != 3: raise ValueError("Expected 3 axes, got `{}`.".format(seq))
intrinsic = seq.isupper() extrinsic = seq.islower() if not (intrinsic or extrinsic): raise ValueError("seq must either be fully uppercase (for extrinsic " "rotations), or fully lowercase, for intrinsic " "rotations).")
i, j, k = seq.lower() if (i == j) or (j == k): raise ValueError("Consecutive axes must be different")
bad = set(seq) - set('xyzXYZ') if bad: raise ValueError("Expected axes from `seq` to be from " "['x', 'y', 'z'] or ['X', 'Y', 'Z'], " "got {}".format(''.join(bad)))
return extrinsic
class Quaternion(Expr): """Provides basic quaternion operations. Quaternion objects can be instantiated as ``Quaternion(a, b, c, d)`` as in $q = a + bi + cj + dk$.
Parameters ==========
norm : None or number Pre-defined quaternion norm. If a value is given, Quaternion.norm returns this pre-defined value instead of calculating the norm
Examples ========
>>> from sympy import Quaternion >>> q = Quaternion(1, 2, 3, 4) >>> q 1 + 2*i + 3*j + 4*k
Quaternions over complex fields can be defined as:
>>> from sympy import Quaternion >>> from sympy import symbols, I >>> x = symbols('x') >>> q1 = Quaternion(x, x**3, x, x**2, real_field = False) >>> q2 = Quaternion(3 + 4*I, 2 + 5*I, 0, 7 + 8*I, real_field = False) >>> q1 x + x**3*i + x*j + x**2*k >>> q2 (3 + 4*I) + (2 + 5*I)*i + 0*j + (7 + 8*I)*k
Defining symbolic unit quaternions:
>>> from sympy import Quaternion >>> from sympy.abc import w, x, y, z >>> q = Quaternion(w, x, y, z, norm=1) >>> q w + x*i + y*j + z*k >>> q.norm() 1
References ==========
.. [1] https://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/ .. [2] https://en.wikipedia.org/wiki/Quaternion
""" _op_priority = 11.0
is_commutative = False
def __new__(cls, a=0, b=0, c=0, d=0, real_field=True, norm=None): a, b, c, d = map(sympify, (a, b, c, d))
if any(i.is_commutative is False for i in [a, b, c, d]): raise ValueError("arguments have to be commutative") obj = super().__new__(cls, a, b, c, d) obj._real_field = real_field obj.set_norm(norm) return obj
def set_norm(self, norm): """Sets norm of an already instantiated quaternion.
Parameters ==========
norm : None or number Pre-defined quaternion norm. If a value is given, Quaternion.norm returns this pre-defined value instead of calculating the norm
Examples ========
>>> from sympy import Quaternion >>> from sympy.abc import a, b, c, d >>> q = Quaternion(a, b, c, d) >>> q.norm() sqrt(a**2 + b**2 + c**2 + d**2)
Setting the norm:
>>> q.set_norm(1) >>> q.norm() 1
Removing set norm:
>>> q.set_norm(None) >>> q.norm() sqrt(a**2 + b**2 + c**2 + d**2)
""" norm = sympify(norm) _check_norm(self.args, norm) self._norm = norm
@property def a(self): return self.args[0]
@property def b(self): return self.args[1]
@property def c(self): return self.args[2]
@property def d(self): return self.args[3]
@property def real_field(self): return self._real_field
@property def product_matrix_left(self): r"""Returns 4 x 4 Matrix equivalent to a Hamilton product from the left. This can be useful when treating quaternion elements as column vectors. Given a quaternion $q = a + bi + cj + dk$ where a, b, c and d are real numbers, the product matrix from the left is:
.. math::
M = \begin{bmatrix} a &-b &-c &-d \\ b & a &-d & c \\ c & d & a &-b \\ d &-c & b & a \end{bmatrix}
Examples ========
>>> from sympy import Quaternion >>> from sympy.abc import a, b, c, d >>> q1 = Quaternion(1, 0, 0, 1) >>> q2 = Quaternion(a, b, c, d) >>> q1.product_matrix_left Matrix([ [1, 0, 0, -1], [0, 1, -1, 0], [0, 1, 1, 0], [1, 0, 0, 1]])
>>> q1.product_matrix_left * q2.to_Matrix() Matrix([ [a - d], [b - c], [b + c], [a + d]])
This is equivalent to:
>>> (q1 * q2).to_Matrix() Matrix([ [a - d], [b - c], [b + c], [a + d]]) """ return Matrix([ [self.a, -self.b, -self.c, -self.d], [self.b, self.a, -self.d, self.c], [self.c, self.d, self.a, -self.b], [self.d, -self.c, self.b, self.a]])
@property def product_matrix_right(self): r"""Returns 4 x 4 Matrix equivalent to a Hamilton product from the right. This can be useful when treating quaternion elements as column vectors. Given a quaternion $q = a + bi + cj + dk$ where a, b, c and d are real numbers, the product matrix from the left is:
.. math::
M = \begin{bmatrix} a &-b &-c &-d \\ b & a & d &-c \\ c &-d & a & b \\ d & c &-b & a \end{bmatrix}
Examples ========
>>> from sympy import Quaternion >>> from sympy.abc import a, b, c, d >>> q1 = Quaternion(a, b, c, d) >>> q2 = Quaternion(1, 0, 0, 1) >>> q2.product_matrix_right Matrix([ [1, 0, 0, -1], [0, 1, 1, 0], [0, -1, 1, 0], [1, 0, 0, 1]])
Note the switched arguments: the matrix represents the quaternion on the right, but is still considered as a matrix multiplication from the left.
>>> q2.product_matrix_right * q1.to_Matrix() Matrix([ [ a - d], [ b + c], [-b + c], [ a + d]])
This is equivalent to:
>>> (q1 * q2).to_Matrix() Matrix([ [ a - d], [ b + c], [-b + c], [ a + d]]) """ return Matrix([ [self.a, -self.b, -self.c, -self.d], [self.b, self.a, self.d, -self.c], [self.c, -self.d, self.a, self.b], [self.d, self.c, -self.b, self.a]])
def to_Matrix(self, vector_only=False): """Returns elements of quaternion as a column vector. By default, a ``Matrix`` of length 4 is returned, with the real part as the first element. If ``vector_only`` is ``True``, returns only imaginary part as a Matrix of length 3.
Parameters ==========
vector_only : bool If True, only imaginary part is returned. Default value: False
Returns =======
Matrix A column vector constructed by the elements of the quaternion.
Examples ========
>>> from sympy import Quaternion >>> from sympy.abc import a, b, c, d >>> q = Quaternion(a, b, c, d) >>> q a + b*i + c*j + d*k
>>> q.to_Matrix() Matrix([ [a], [b], [c], [d]])
>>> q.to_Matrix(vector_only=True) Matrix([ [b], [c], [d]])
""" if vector_only: return Matrix(self.args[1:]) else: return Matrix(self.args)
@classmethod def from_Matrix(cls, elements): """Returns quaternion from elements of a column vector`. If vector_only is True, returns only imaginary part as a Matrix of length 3.
Parameters ==========
elements : Matrix, list or tuple of length 3 or 4. If length is 3, assume real part is zero. Default value: False
Returns =======
Quaternion A quaternion created from the input elements.
Examples ========
>>> from sympy import Quaternion >>> from sympy.abc import a, b, c, d >>> q = Quaternion.from_Matrix([a, b, c, d]) >>> q a + b*i + c*j + d*k
>>> q = Quaternion.from_Matrix([b, c, d]) >>> q 0 + b*i + c*j + d*k
""" length = len(elements) if length != 3 and length != 4: raise ValueError("Input elements must have length 3 or 4, got {} " "elements".format(length))
if length == 3: return Quaternion(0, *elements) else: return Quaternion(*elements)
@classmethod def from_euler(cls, angles, seq): """Returns quaternion equivalent to rotation represented by the Euler angles, in the sequence defined by ``seq``.
Parameters ==========
angles : list, tuple or Matrix of 3 numbers The Euler angles (in radians). seq : string of length 3 Represents the sequence of rotations. For extrinsic rotations, seq must be all lowercase and its elements must be from the set ``{'x', 'y', 'z'}`` For intrinsic rotations, seq must be all uppercase and its elements must be from the set ``{'X', 'Y', 'Z'}``
Returns =======
Quaternion The normalized rotation quaternion calculated from the Euler angles in the given sequence.
Examples ========
>>> from sympy import Quaternion >>> from sympy import pi >>> q = Quaternion.from_euler([pi/2, 0, 0], 'xyz') >>> q sqrt(2)/2 + sqrt(2)/2*i + 0*j + 0*k
>>> q = Quaternion.from_euler([0, pi/2, pi] , 'zyz') >>> q 0 + (-sqrt(2)/2)*i + 0*j + sqrt(2)/2*k
>>> q = Quaternion.from_euler([0, pi/2, pi] , 'ZYZ') >>> q 0 + sqrt(2)/2*i + 0*j + sqrt(2)/2*k
"""
if len(angles) != 3: raise ValueError("3 angles must be given.")
extrinsic = _is_extrinsic(seq) i, j, k = seq.lower()
# get elementary basis vectors ei = [1 if n == i else 0 for n in 'xyz'] ej = [1 if n == j else 0 for n in 'xyz'] ek = [1 if n == k else 0 for n in 'xyz']
# calculate distinct quaternions qi = cls.from_axis_angle(ei, angles[0]) qj = cls.from_axis_angle(ej, angles[1]) qk = cls.from_axis_angle(ek, angles[2])
if extrinsic: return trigsimp(qk * qj * qi) else: return trigsimp(qi * qj * qk)
def to_euler(self, seq, angle_addition=True, avoid_square_root=False): r"""Returns Euler angles representing same rotation as the quaternion, in the sequence given by ``seq``. This implements the method described in [1]_.
For degenerate cases (gymbal lock cases), the third angle is set to zero.
Parameters ==========
seq : string of length 3 Represents the sequence of rotations. For extrinsic rotations, seq must be all lowercase and its elements must be from the set ``{'x', 'y', 'z'}`` For intrinsic rotations, seq must be all uppercase and its elements must be from the set ``{'X', 'Y', 'Z'}``
angle_addition : bool When True, first and third angles are given as an addition and subtraction of two simpler ``atan2`` expressions. When False, the first and third angles are each given by a single more complicated ``atan2`` expression. This equivalent expression is given by:
.. math::
\operatorname{atan_2} (b,a) \pm \operatorname{atan_2} (d,c) = \operatorname{atan_2} (bc\pm ad, ac\mp bd)
Default value: True
avoid_square_root : bool When True, the second angle is calculated with an expression based on ``acos``, which is slightly more complicated but avoids a square root. When False, second angle is calculated with ``atan2``, which is simpler and can be better for numerical reasons (some numerical implementations of ``acos`` have problems near zero). Default value: False
Returns =======
Tuple The Euler angles calculated from the quaternion
Examples ========
>>> from sympy import Quaternion >>> from sympy.abc import a, b, c, d >>> euler = Quaternion(a, b, c, d).to_euler('zyz') >>> euler (-atan2(-b, c) + atan2(d, a), 2*atan2(sqrt(b**2 + c**2), sqrt(a**2 + d**2)), atan2(-b, c) + atan2(d, a))
References ==========
.. [1] https://doi.org/10.1371/journal.pone.0276302
""" if self.is_zero_quaternion(): raise ValueError('Cannot convert a quaternion with norm 0.')
angles = [0, 0, 0]
extrinsic = _is_extrinsic(seq) i, j, k = seq.lower()
# get index corresponding to elementary basis vectors i = 'xyz'.index(i) + 1 j = 'xyz'.index(j) + 1 k = 'xyz'.index(k) + 1
if not extrinsic: i, k = k, i
# check if sequence is symmetric symmetric = i == k if symmetric: k = 6 - i - j
# parity of the permutation sign = (i - j) * (j - k) * (k - i) // 2
# permutate elements elements = [self.a, self.b, self.c, self.d] a = elements[0] b = elements[i] c = elements[j] d = elements[k] * sign
if not symmetric: a, b, c, d = a - c, b + d, c + a, d - b
if avoid_square_root: if symmetric: n2 = self.norm()**2 angles[1] = acos((a * a + b * b - c * c - d * d) / n2) else: n2 = 2 * self.norm()**2 angles[1] = asin((c * c + d * d - a * a - b * b) / n2) else: angles[1] = 2 * atan2(sqrt(c * c + d * d), sqrt(a * a + b * b)) if not symmetric: angles[1] -= S.Pi / 2
# Check for singularities in numerical cases case = 0 if is_eq(c, S.Zero) and is_eq(d, S.Zero): case = 1 if is_eq(a, S.Zero) and is_eq(b, S.Zero): case = 2
if case == 0: if angle_addition: angles[0] = atan2(b, a) + atan2(d, c) angles[2] = atan2(b, a) - atan2(d, c) else: angles[0] = atan2(b*c + a*d, a*c - b*d) angles[2] = atan2(b*c - a*d, a*c + b*d)
else: # any degenerate case angles[2 * (not extrinsic)] = S.Zero if case == 1: angles[2 * extrinsic] = 2 * atan2(b, a) else: angles[2 * extrinsic] = 2 * atan2(d, c) angles[2 * extrinsic] *= (-1 if extrinsic else 1)
# for Tait-Bryan angles if not symmetric: angles[0] *= sign
if extrinsic: return tuple(angles[::-1]) else: return tuple(angles)
@classmethod def from_axis_angle(cls, vector, angle): """Returns a rotation quaternion given the axis and the angle of rotation.
Parameters ==========
vector : tuple of three numbers The vector representation of the given axis. angle : number The angle by which axis is rotated (in radians).
Returns =======
Quaternion The normalized rotation quaternion calculated from the given axis and the angle of rotation.
Examples ========
>>> from sympy import Quaternion >>> from sympy import pi, sqrt >>> q = Quaternion.from_axis_angle((sqrt(3)/3, sqrt(3)/3, sqrt(3)/3), 2*pi/3) >>> q 1/2 + 1/2*i + 1/2*j + 1/2*k
""" (x, y, z) = vector norm = sqrt(x**2 + y**2 + z**2) (x, y, z) = (x / norm, y / norm, z / norm) s = sin(angle * S.Half) a = cos(angle * S.Half) b = x * s c = y * s d = z * s
# note that this quaternion is already normalized by construction: # c^2 + (s*x)^2 + (s*y)^2 + (s*z)^2 = c^2 + s^2*(x^2 + y^2 + z^2) = c^2 + s^2 * 1 = c^2 + s^2 = 1 # so, what we return is a normalized quaternion
return cls(a, b, c, d)
@classmethod def from_rotation_matrix(cls, M): """Returns the equivalent quaternion of a matrix. The quaternion will be normalized only if the matrix is special orthogonal (orthogonal and det(M) = 1).
Parameters ==========
M : Matrix Input matrix to be converted to equivalent quaternion. M must be special orthogonal (orthogonal and det(M) = 1) for the quaternion to be normalized.
Returns =======
Quaternion The quaternion equivalent to given matrix.
Examples ========
>>> from sympy import Quaternion >>> from sympy import Matrix, symbols, cos, sin, trigsimp >>> x = symbols('x') >>> M = Matrix([[cos(x), -sin(x), 0], [sin(x), cos(x), 0], [0, 0, 1]]) >>> q = trigsimp(Quaternion.from_rotation_matrix(M)) >>> q sqrt(2)*sqrt(cos(x) + 1)/2 + 0*i + 0*j + sqrt(2 - 2*cos(x))*sign(sin(x))/2*k
"""
absQ = M.det()**Rational(1, 3)
a = sqrt(absQ + M[0, 0] + M[1, 1] + M[2, 2]) / 2 b = sqrt(absQ + M[0, 0] - M[1, 1] - M[2, 2]) / 2 c = sqrt(absQ - M[0, 0] + M[1, 1] - M[2, 2]) / 2 d = sqrt(absQ - M[0, 0] - M[1, 1] + M[2, 2]) / 2
b = b * sign(M[2, 1] - M[1, 2]) c = c * sign(M[0, 2] - M[2, 0]) d = d * sign(M[1, 0] - M[0, 1])
return Quaternion(a, b, c, d)
def __add__(self, other): return self.add(other)
def __radd__(self, other): return self.add(other)
def __sub__(self, other): return self.add(other*-1)
def __mul__(self, other): return self._generic_mul(self, _sympify(other))
def __rmul__(self, other): return self._generic_mul(_sympify(other), self)
def __pow__(self, p): return self.pow(p)
def __neg__(self): return Quaternion(-self.a, -self.b, -self.c, -self.d)
def __truediv__(self, other): return self * sympify(other)**-1
def __rtruediv__(self, other): return sympify(other) * self**-1
def _eval_Integral(self, *args): return self.integrate(*args)
def diff(self, *symbols, **kwargs): kwargs.setdefault('evaluate', True) return self.func(*[a.diff(*symbols, **kwargs) for a in self.args])
def add(self, other): """Adds quaternions.
Parameters ==========
other : Quaternion The quaternion to add to current (self) quaternion.
Returns =======
Quaternion The resultant quaternion after adding self to other
Examples ========
>>> from sympy import Quaternion >>> from sympy import symbols >>> q1 = Quaternion(1, 2, 3, 4) >>> q2 = Quaternion(5, 6, 7, 8) >>> q1.add(q2) 6 + 8*i + 10*j + 12*k >>> q1 + 5 6 + 2*i + 3*j + 4*k >>> x = symbols('x', real = True) >>> q1.add(x) (x + 1) + 2*i + 3*j + 4*k
Quaternions over complex fields :
>>> from sympy import Quaternion >>> from sympy import I >>> q3 = Quaternion(3 + 4*I, 2 + 5*I, 0, 7 + 8*I, real_field = False) >>> q3.add(2 + 3*I) (5 + 7*I) + (2 + 5*I)*i + 0*j + (7 + 8*I)*k
""" q1 = self q2 = sympify(other)
# If q2 is a number or a SymPy expression instead of a quaternion if not isinstance(q2, Quaternion): if q1.real_field and q2.is_complex: return Quaternion(re(q2) + q1.a, im(q2) + q1.b, q1.c, q1.d) elif q2.is_commutative: return Quaternion(q1.a + q2, q1.b, q1.c, q1.d) else: raise ValueError("Only commutative expressions can be added with a Quaternion.")
return Quaternion(q1.a + q2.a, q1.b + q2.b, q1.c + q2.c, q1.d + q2.d)
def mul(self, other): """Multiplies quaternions.
Parameters ==========
other : Quaternion or symbol The quaternion to multiply to current (self) quaternion.
Returns =======
Quaternion The resultant quaternion after multiplying self with other
Examples ========
>>> from sympy import Quaternion >>> from sympy import symbols >>> q1 = Quaternion(1, 2, 3, 4) >>> q2 = Quaternion(5, 6, 7, 8) >>> q1.mul(q2) (-60) + 12*i + 30*j + 24*k >>> q1.mul(2) 2 + 4*i + 6*j + 8*k >>> x = symbols('x', real = True) >>> q1.mul(x) x + 2*x*i + 3*x*j + 4*x*k
Quaternions over complex fields :
>>> from sympy import Quaternion >>> from sympy import I >>> q3 = Quaternion(3 + 4*I, 2 + 5*I, 0, 7 + 8*I, real_field = False) >>> q3.mul(2 + 3*I) (2 + 3*I)*(3 + 4*I) + (2 + 3*I)*(2 + 5*I)*i + 0*j + (2 + 3*I)*(7 + 8*I)*k
""" return self._generic_mul(self, _sympify(other))
@staticmethod def _generic_mul(q1, q2): """Generic multiplication.
Parameters ==========
q1 : Quaternion or symbol q2 : Quaternion or symbol
It is important to note that if neither q1 nor q2 is a Quaternion, this function simply returns q1 * q2.
Returns =======
Quaternion The resultant quaternion after multiplying q1 and q2
Examples ========
>>> from sympy import Quaternion >>> from sympy import Symbol, S >>> q1 = Quaternion(1, 2, 3, 4) >>> q2 = Quaternion(5, 6, 7, 8) >>> Quaternion._generic_mul(q1, q2) (-60) + 12*i + 30*j + 24*k >>> Quaternion._generic_mul(q1, S(2)) 2 + 4*i + 6*j + 8*k >>> x = Symbol('x', real = True) >>> Quaternion._generic_mul(q1, x) x + 2*x*i + 3*x*j + 4*x*k
Quaternions over complex fields :
>>> from sympy import I >>> q3 = Quaternion(3 + 4*I, 2 + 5*I, 0, 7 + 8*I, real_field = False) >>> Quaternion._generic_mul(q3, 2 + 3*I) (2 + 3*I)*(3 + 4*I) + (2 + 3*I)*(2 + 5*I)*i + 0*j + (2 + 3*I)*(7 + 8*I)*k
""" # None is a Quaternion: if not isinstance(q1, Quaternion) and not isinstance(q2, Quaternion): return q1 * q2
# If q1 is a number or a SymPy expression instead of a quaternion if not isinstance(q1, Quaternion): if q2.real_field and q1.is_complex: return Quaternion(re(q1), im(q1), 0, 0) * q2 elif q1.is_commutative: return Quaternion(q1 * q2.a, q1 * q2.b, q1 * q2.c, q1 * q2.d) else: raise ValueError("Only commutative expressions can be multiplied with a Quaternion.")
# If q2 is a number or a SymPy expression instead of a quaternion if not isinstance(q2, Quaternion): if q1.real_field and q2.is_complex: return q1 * Quaternion(re(q2), im(q2), 0, 0) elif q2.is_commutative: return Quaternion(q2 * q1.a, q2 * q1.b, q2 * q1.c, q2 * q1.d) else: raise ValueError("Only commutative expressions can be multiplied with a Quaternion.")
# If any of the quaternions has a fixed norm, pre-compute norm if q1._norm is None and q2._norm is None: norm = None else: norm = q1.norm() * q2.norm()
return Quaternion(-q1.b*q2.b - q1.c*q2.c - q1.d*q2.d + q1.a*q2.a, q1.b*q2.a + q1.c*q2.d - q1.d*q2.c + q1.a*q2.b, -q1.b*q2.d + q1.c*q2.a + q1.d*q2.b + q1.a*q2.c, q1.b*q2.c - q1.c*q2.b + q1.d*q2.a + q1.a * q2.d, norm=norm)
def _eval_conjugate(self): """Returns the conjugate of the quaternion.""" q = self return Quaternion(q.a, -q.b, -q.c, -q.d, norm=q._norm)
def norm(self): """Returns the norm of the quaternion.""" if self._norm is None: # check if norm is pre-defined q = self # trigsimp is used to simplify sin(x)^2 + cos(x)^2 (these terms # arise when from_axis_angle is used). return sqrt(trigsimp(q.a**2 + q.b**2 + q.c**2 + q.d**2))
return self._norm
def normalize(self): """Returns the normalized form of the quaternion.""" q = self return q * (1/q.norm())
def inverse(self): """Returns the inverse of the quaternion.""" q = self if not q.norm(): raise ValueError("Cannot compute inverse for a quaternion with zero norm") return conjugate(q) * (1/q.norm()**2)
def pow(self, p): """Finds the pth power of the quaternion.
Parameters ==========
p : int Power to be applied on quaternion.
Returns =======
Quaternion Returns the p-th power of the current quaternion. Returns the inverse if p = -1.
Examples ========
>>> from sympy import Quaternion >>> q = Quaternion(1, 2, 3, 4) >>> q.pow(4) 668 + (-224)*i + (-336)*j + (-448)*k
""" try: q, p = self, as_int(p) except ValueError: return NotImplemented
if p < 0: q, p = q.inverse(), -p
if p == 1: return q
res = Quaternion(1, 0, 0, 0) while p > 0: if p & 1: res *= q q *= q p >>= 1
return res
def exp(self): """Returns the exponential of $q$, given by $e^q$.
Returns =======
Quaternion The exponential of the quaternion.
Examples ========
>>> from sympy import Quaternion >>> q = Quaternion(1, 2, 3, 4) >>> q.exp() E*cos(sqrt(29)) + 2*sqrt(29)*E*sin(sqrt(29))/29*i + 3*sqrt(29)*E*sin(sqrt(29))/29*j + 4*sqrt(29)*E*sin(sqrt(29))/29*k
""" # exp(q) = e^a(cos||v|| + v/||v||*sin||v||) q = self vector_norm = sqrt(q.b**2 + q.c**2 + q.d**2) a = exp(q.a) * cos(vector_norm) b = exp(q.a) * sin(vector_norm) * q.b / vector_norm c = exp(q.a) * sin(vector_norm) * q.c / vector_norm d = exp(q.a) * sin(vector_norm) * q.d / vector_norm
return Quaternion(a, b, c, d)
def log(self): r"""Returns the logarithm of the quaternion, given by $\log q$.
Examples ========
>>> from sympy import Quaternion >>> q = Quaternion(1, 2, 3, 4) >>> q.log() log(sqrt(30)) + 2*sqrt(29)*acos(sqrt(30)/30)/29*i + 3*sqrt(29)*acos(sqrt(30)/30)/29*j + 4*sqrt(29)*acos(sqrt(30)/30)/29*k
""" # log(q) = log||q|| + v/||v||*arccos(a/||q||) q = self vector_norm = sqrt(q.b**2 + q.c**2 + q.d**2) q_norm = q.norm() a = ln(q_norm) b = q.b * acos(q.a / q_norm) / vector_norm c = q.c * acos(q.a / q_norm) / vector_norm d = q.d * acos(q.a / q_norm) / vector_norm
return Quaternion(a, b, c, d)
def _eval_subs(self, *args): elements = [i.subs(*args) for i in self.args] norm = self._norm if norm is not None: norm = norm.subs(*args) _check_norm(elements, norm) return Quaternion(*elements, norm=norm)
def _eval_evalf(self, prec): """Returns the floating point approximations (decimal numbers) of the quaternion.
Returns =======
Quaternion Floating point approximations of quaternion(self)
Examples ========
>>> from sympy import Quaternion >>> from sympy import sqrt >>> q = Quaternion(1/sqrt(1), 1/sqrt(2), 1/sqrt(3), 1/sqrt(4)) >>> q.evalf() 1.00000000000000 + 0.707106781186547*i + 0.577350269189626*j + 0.500000000000000*k
""" nprec = prec_to_dps(prec) return Quaternion(*[arg.evalf(n=nprec) for arg in self.args])
def pow_cos_sin(self, p): """Computes the pth power in the cos-sin form.
Parameters ==========
p : int Power to be applied on quaternion.
Returns =======
Quaternion The p-th power in the cos-sin form.
Examples ========
>>> from sympy import Quaternion >>> q = Quaternion(1, 2, 3, 4) >>> q.pow_cos_sin(4) 900*cos(4*acos(sqrt(30)/30)) + 1800*sqrt(29)*sin(4*acos(sqrt(30)/30))/29*i + 2700*sqrt(29)*sin(4*acos(sqrt(30)/30))/29*j + 3600*sqrt(29)*sin(4*acos(sqrt(30)/30))/29*k
""" # q = ||q||*(cos(a) + u*sin(a)) # q^p = ||q||^p * (cos(p*a) + u*sin(p*a))
q = self (v, angle) = q.to_axis_angle() q2 = Quaternion.from_axis_angle(v, p * angle) return q2 * (q.norm()**p)
def integrate(self, *args): """Computes integration of quaternion.
Returns =======
Quaternion Integration of the quaternion(self) with the given variable.
Examples ========
Indefinite Integral of quaternion :
>>> from sympy import Quaternion >>> from sympy.abc import x >>> q = Quaternion(1, 2, 3, 4) >>> q.integrate(x) x + 2*x*i + 3*x*j + 4*x*k
Definite integral of quaternion :
>>> from sympy import Quaternion >>> from sympy.abc import x >>> q = Quaternion(1, 2, 3, 4) >>> q.integrate((x, 1, 5)) 4 + 8*i + 12*j + 16*k
""" # TODO: is this expression correct? return Quaternion(integrate(self.a, *args), integrate(self.b, *args), integrate(self.c, *args), integrate(self.d, *args))
@staticmethod def rotate_point(pin, r): """Returns the coordinates of the point pin (a 3 tuple) after rotation.
Parameters ==========
pin : tuple A 3-element tuple of coordinates of a point which needs to be rotated. r : Quaternion or tuple Axis and angle of rotation.
It's important to note that when r is a tuple, it must be of the form (axis, angle)
Returns =======
tuple The coordinates of the point after rotation.
Examples ========
>>> from sympy import Quaternion >>> from sympy import symbols, trigsimp, cos, sin >>> x = symbols('x') >>> q = Quaternion(cos(x/2), 0, 0, sin(x/2)) >>> trigsimp(Quaternion.rotate_point((1, 1, 1), q)) (sqrt(2)*cos(x + pi/4), sqrt(2)*sin(x + pi/4), 1) >>> (axis, angle) = q.to_axis_angle() >>> trigsimp(Quaternion.rotate_point((1, 1, 1), (axis, angle))) (sqrt(2)*cos(x + pi/4), sqrt(2)*sin(x + pi/4), 1)
""" if isinstance(r, tuple): # if r is of the form (vector, angle) q = Quaternion.from_axis_angle(r[0], r[1]) else: # if r is a quaternion q = r.normalize() pout = q * Quaternion(0, pin[0], pin[1], pin[2]) * conjugate(q) return (pout.b, pout.c, pout.d)
def to_axis_angle(self): """Returns the axis and angle of rotation of a quaternion.
Returns =======
tuple Tuple of (axis, angle)
Examples ========
>>> from sympy import Quaternion >>> q = Quaternion(1, 1, 1, 1) >>> (axis, angle) = q.to_axis_angle() >>> axis (sqrt(3)/3, sqrt(3)/3, sqrt(3)/3) >>> angle 2*pi/3
""" q = self if q.a.is_negative: q = q * -1
q = q.normalize() angle = trigsimp(2 * acos(q.a))
# Since quaternion is normalised, q.a is less than 1. s = sqrt(1 - q.a*q.a)
x = trigsimp(q.b / s) y = trigsimp(q.c / s) z = trigsimp(q.d / s)
v = (x, y, z) t = (v, angle)
return t
def to_rotation_matrix(self, v=None, homogeneous=True): """Returns the equivalent rotation transformation matrix of the quaternion which represents rotation about the origin if ``v`` is not passed.
Parameters ==========
v : tuple or None Default value: None homogeneous : bool When True, gives an expression that may be more efficient for symbolic calculations but less so for direct evaluation. Both formulas are mathematically equivalent. Default value: True
Returns =======
tuple Returns the equivalent rotation transformation matrix of the quaternion which represents rotation about the origin if v is not passed.
Examples ========
>>> from sympy import Quaternion >>> from sympy import symbols, trigsimp, cos, sin >>> x = symbols('x') >>> q = Quaternion(cos(x/2), 0, 0, sin(x/2)) >>> trigsimp(q.to_rotation_matrix()) Matrix([ [cos(x), -sin(x), 0], [sin(x), cos(x), 0], [ 0, 0, 1]])
Generates a 4x4 transformation matrix (used for rotation about a point other than the origin) if the point(v) is passed as an argument. """
q = self s = q.norm()**-2
# diagonal elements are different according to parameter normal if homogeneous: m00 = s*(q.a**2 + q.b**2 - q.c**2 - q.d**2) m11 = s*(q.a**2 - q.b**2 + q.c**2 - q.d**2) m22 = s*(q.a**2 - q.b**2 - q.c**2 + q.d**2) else: m00 = 1 - 2*s*(q.c**2 + q.d**2) m11 = 1 - 2*s*(q.b**2 + q.d**2) m22 = 1 - 2*s*(q.b**2 + q.c**2)
m01 = 2*s*(q.b*q.c - q.d*q.a) m02 = 2*s*(q.b*q.d + q.c*q.a)
m10 = 2*s*(q.b*q.c + q.d*q.a) m12 = 2*s*(q.c*q.d - q.b*q.a)
m20 = 2*s*(q.b*q.d - q.c*q.a) m21 = 2*s*(q.c*q.d + q.b*q.a)
if not v: return Matrix([[m00, m01, m02], [m10, m11, m12], [m20, m21, m22]])
else: (x, y, z) = v
m03 = x - x*m00 - y*m01 - z*m02 m13 = y - x*m10 - y*m11 - z*m12 m23 = z - x*m20 - y*m21 - z*m22 m30 = m31 = m32 = 0 m33 = 1
return Matrix([[m00, m01, m02, m03], [m10, m11, m12, m13], [m20, m21, m22, m23], [m30, m31, m32, m33]])
def scalar_part(self): r"""Returns scalar part($\mathbf{S}(q)$) of the quaternion q.
Explanation ===========
Given a quaternion $q = a + bi + cj + dk$, returns $\mathbf{S}(q) = a$.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q = Quaternion(4, 8, 13, 12) >>> q.scalar_part() 4
"""
return self.a
def vector_part(self): r""" Returns $\mathbf{V}(q)$, the vector part of the quaternion $q$.
Explanation ===========
Given a quaternion $q = a + bi + cj + dk$, returns $\mathbf{V}(q) = bi + cj + dk$.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q = Quaternion(1, 1, 1, 1) >>> q.vector_part() 0 + 1*i + 1*j + 1*k
>>> q = Quaternion(4, 8, 13, 12) >>> q.vector_part() 0 + 8*i + 13*j + 12*k
"""
return Quaternion(0, self.b, self.c, self.d)
def axis(self): r""" Returns $\mathbf{Ax}(q)$, the axis of the quaternion $q$.
Explanation ===========
Given a quaternion $q = a + bi + cj + dk$, returns $\mathbf{Ax}(q)$ i.e., the versor of the vector part of that quaternion equal to $\mathbf{U}[\mathbf{V}(q)]$. The axis is always an imaginary unit with square equal to $-1 + 0i + 0j + 0k$.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q = Quaternion(1, 1, 1, 1) >>> q.axis() 0 + sqrt(3)/3*i + sqrt(3)/3*j + sqrt(3)/3*k
See Also ========
vector_part
""" axis = self.vector_part().normalize()
return Quaternion(0, axis.b, axis.c, axis.d)
def is_pure(self): """ Returns true if the quaternion is pure, false if the quaternion is not pure or returns none if it is unknown.
Explanation ===========
A pure quaternion (also a vector quaternion) is a quaternion with scalar part equal to 0.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q = Quaternion(0, 8, 13, 12) >>> q.is_pure() True
See Also ======== scalar_part
"""
return self.a.is_zero
def is_zero_quaternion(self): """ Returns true if the quaternion is a zero quaternion or false if it is not a zero quaternion and None if the value is unknown.
Explanation ===========
A zero quaternion is a quaternion with both scalar part and vector part equal to 0.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q = Quaternion(1, 0, 0, 0) >>> q.is_zero_quaternion() False
>>> q = Quaternion(0, 0, 0, 0) >>> q.is_zero_quaternion() True
See Also ======== scalar_part vector_part
"""
return self.norm().is_zero
def angle(self): r""" Returns the angle of the quaternion measured in the real-axis plane.
Explanation ===========
Given a quaternion $q = a + bi + cj + dk$ where $a$, $b$, $c$ and $d$ are real numbers, returns the angle of the quaternion given by
.. math:: \theta := 2 \operatorname{atan_2}\left(\sqrt{b^2 + c^2 + d^2}, {a}\right)
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q = Quaternion(1, 4, 4, 4) >>> q.angle() 2*atan(4*sqrt(3))
"""
return 2 * atan2(self.vector_part().norm(), self.scalar_part())
def arc_coplanar(self, other): """ Returns True if the transformation arcs represented by the input quaternions happen in the same plane.
Explanation ===========
Two quaternions are said to be coplanar (in this arc sense) when their axes are parallel. The plane of a quaternion is the one normal to its axis.
Parameters ==========
other : a Quaternion
Returns =======
True : if the planes of the two quaternions are the same, apart from its orientation/sign. False : if the planes of the two quaternions are not the same, apart from its orientation/sign. None : if plane of either of the quaternion is unknown.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q1 = Quaternion(1, 4, 4, 4) >>> q2 = Quaternion(3, 8, 8, 8) >>> Quaternion.arc_coplanar(q1, q2) True
>>> q1 = Quaternion(2, 8, 13, 12) >>> Quaternion.arc_coplanar(q1, q2) False
See Also ========
vector_coplanar is_pure
""" if (self.is_zero_quaternion()) or (other.is_zero_quaternion()): raise ValueError('Neither of the given quaternions can be 0')
return fuzzy_or([(self.axis() - other.axis()).is_zero_quaternion(), (self.axis() + other.axis()).is_zero_quaternion()])
@classmethod def vector_coplanar(cls, q1, q2, q3): r""" Returns True if the axis of the pure quaternions seen as 3D vectors ``q1``, ``q2``, and ``q3`` are coplanar.
Explanation ===========
Three pure quaternions are vector coplanar if the quaternions seen as 3D vectors are coplanar.
Parameters ==========
q1 A pure Quaternion. q2 A pure Quaternion. q3 A pure Quaternion.
Returns =======
True : if the axis of the pure quaternions seen as 3D vectors q1, q2, and q3 are coplanar. False : if the axis of the pure quaternions seen as 3D vectors q1, q2, and q3 are not coplanar. None : if the axis of the pure quaternions seen as 3D vectors q1, q2, and q3 are coplanar is unknown.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q1 = Quaternion(0, 4, 4, 4) >>> q2 = Quaternion(0, 8, 8, 8) >>> q3 = Quaternion(0, 24, 24, 24) >>> Quaternion.vector_coplanar(q1, q2, q3) True
>>> q1 = Quaternion(0, 8, 16, 8) >>> q2 = Quaternion(0, 8, 3, 12) >>> Quaternion.vector_coplanar(q1, q2, q3) False
See Also ========
axis is_pure
"""
if fuzzy_not(q1.is_pure()) or fuzzy_not(q2.is_pure()) or fuzzy_not(q3.is_pure()): raise ValueError('The given quaternions must be pure')
M = Matrix([[q1.b, q1.c, q1.d], [q2.b, q2.c, q2.d], [q3.b, q3.c, q3.d]]).det() return M.is_zero
def parallel(self, other): """ Returns True if the two pure quaternions seen as 3D vectors are parallel.
Explanation ===========
Two pure quaternions are called parallel when their vector product is commutative which implies that the quaternions seen as 3D vectors have same direction.
Parameters ==========
other : a Quaternion
Returns =======
True : if the two pure quaternions seen as 3D vectors are parallel. False : if the two pure quaternions seen as 3D vectors are not parallel. None : if the two pure quaternions seen as 3D vectors are parallel is unknown.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q = Quaternion(0, 4, 4, 4) >>> q1 = Quaternion(0, 8, 8, 8) >>> q.parallel(q1) True
>>> q1 = Quaternion(0, 8, 13, 12) >>> q.parallel(q1) False
"""
if fuzzy_not(self.is_pure()) or fuzzy_not(other.is_pure()): raise ValueError('The provided quaternions must be pure')
return (self*other - other*self).is_zero_quaternion()
def orthogonal(self, other): """ Returns the orthogonality of two quaternions.
Explanation ===========
Two pure quaternions are called orthogonal when their product is anti-commutative.
Parameters ==========
other : a Quaternion
Returns =======
True : if the two pure quaternions seen as 3D vectors are orthogonal. False : if the two pure quaternions seen as 3D vectors are not orthogonal. None : if the two pure quaternions seen as 3D vectors are orthogonal is unknown.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q = Quaternion(0, 4, 4, 4) >>> q1 = Quaternion(0, 8, 8, 8) >>> q.orthogonal(q1) False
>>> q1 = Quaternion(0, 2, 2, 0) >>> q = Quaternion(0, 2, -2, 0) >>> q.orthogonal(q1) True
"""
if fuzzy_not(self.is_pure()) or fuzzy_not(other.is_pure()): raise ValueError('The given quaternions must be pure')
return (self*other + other*self).is_zero_quaternion()
def index_vector(self): r""" Returns the index vector of the quaternion.
Explanation ===========
The index vector is given by $\mathbf{T}(q)$, the norm (or magnitude) of the quaternion $q$, multiplied by $\mathbf{Ax}(q)$, the axis of $q$.
Returns =======
Quaternion: representing index vector of the provided quaternion.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q = Quaternion(2, 4, 2, 4) >>> q.index_vector() 0 + 4*sqrt(10)/3*i + 2*sqrt(10)/3*j + 4*sqrt(10)/3*k
See Also ========
axis norm
"""
return self.norm() * self.axis()
def mensor(self): """ Returns the natural logarithm of the norm(magnitude) of the quaternion.
Examples ========
>>> from sympy.algebras.quaternion import Quaternion >>> q = Quaternion(2, 4, 2, 4) >>> q.mensor() log(2*sqrt(10)) >>> q.norm() 2*sqrt(10)
See Also ========
norm
"""
return ln(self.norm())123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428from sympy.testing.pytest import slowfrom sympy.core.function import difffrom sympy.core.function import expandfrom sympy.core.numbers import (E, I, Rational, pi)from sympy.core.singleton import Sfrom sympy.core.symbol import (Symbol, symbols)from sympy.functions.elementary.complexes import (Abs, conjugate, im, re, sign)from sympy.functions.elementary.exponential import logfrom sympy.functions.elementary.miscellaneous import sqrtfrom sympy.functions.elementary.trigonometric import (acos, asin, cos, sin, atan2, atan)from sympy.integrals.integrals import integratefrom sympy.matrices.dense import Matrixfrom sympy.simplify import simplifyfrom sympy.simplify.trigsimp import trigsimpfrom sympy.algebras.quaternion import Quaternionfrom sympy.testing.pytest import raisesimport mathfrom itertools import permutations, product
w, x, y, z = symbols('w:z')phi = symbols('phi')
def test_quaternion_construction(): q = Quaternion(w, x, y, z) assert q + q == Quaternion(2*w, 2*x, 2*y, 2*z)
q2 = Quaternion.from_axis_angle((sqrt(3)/3, sqrt(3)/3, sqrt(3)/3), pi*Rational(2, 3)) assert q2 == Quaternion(S.Half, S.Half, S.Half, S.Half)
M = Matrix([[cos(phi), -sin(phi), 0], [sin(phi), cos(phi), 0], [0, 0, 1]]) q3 = trigsimp(Quaternion.from_rotation_matrix(M)) assert q3 == Quaternion( sqrt(2)*sqrt(cos(phi) + 1)/2, 0, 0, sqrt(2 - 2*cos(phi))*sign(sin(phi))/2)
nc = Symbol('nc', commutative=False) raises(ValueError, lambda: Quaternion(w, x, nc, z))
def test_quaternion_construction_norm(): q1 = Quaternion(*symbols('a:d'))
q2 = Quaternion(w, x, y, z) assert expand((q1*q2).norm()**2 - (q1.norm()**2 * q2.norm()**2)) == 0
q3 = Quaternion(w, x, y, z, norm=1) assert (q1 * q3).norm() == q1.norm()
def test_issue_25254(): # calculating the inverse cached the norm which caused problems # when multiplying p = Quaternion(1, 0, 0, 0) q = Quaternion.from_axis_angle((1, 1, 1), 3 * math.pi/4) qi = q.inverse() # this operation cached the norm test = q * p * qi assert ((test - p).norm() < 1E-10)
def test_to_and_from_Matrix(): q = Quaternion(w, x, y, z) q_full = Quaternion.from_Matrix(q.to_Matrix()) q_vect = Quaternion.from_Matrix(q.to_Matrix(True)) assert (q - q_full).is_zero_quaternion() assert (q.vector_part() - q_vect).is_zero_quaternion()
def test_product_matrices(): q1 = Quaternion(w, x, y, z) q2 = Quaternion(*(symbols("a:d"))) assert (q1 * q2).to_Matrix() == q1.product_matrix_left * q2.to_Matrix() assert (q1 * q2).to_Matrix() == q2.product_matrix_right * q1.to_Matrix()
R1 = (q1.product_matrix_left * q1.product_matrix_right.T)[1:, 1:] R2 = simplify(q1.to_rotation_matrix()*q1.norm()**2) assert R1 == R2
def test_quaternion_axis_angle():
test_data = [ # axis, angle, expected_quaternion ((1, 0, 0), 0, (1, 0, 0, 0)), ((1, 0, 0), pi/2, (sqrt(2)/2, sqrt(2)/2, 0, 0)), ((0, 1, 0), pi/2, (sqrt(2)/2, 0, sqrt(2)/2, 0)), ((0, 0, 1), pi/2, (sqrt(2)/2, 0, 0, sqrt(2)/2)), ((1, 0, 0), pi, (0, 1, 0, 0)), ((0, 1, 0), pi, (0, 0, 1, 0)), ((0, 0, 1), pi, (0, 0, 0, 1)), ((1, 1, 1), pi, (0, 1/sqrt(3),1/sqrt(3),1/sqrt(3))), ((sqrt(3)/3, sqrt(3)/3, sqrt(3)/3), pi*2/3, (S.Half, S.Half, S.Half, S.Half)) ]
for axis, angle, expected in test_data: assert Quaternion.from_axis_angle(axis, angle) == Quaternion(*expected)
def test_quaternion_axis_angle_simplification(): result = Quaternion.from_axis_angle((1, 2, 3), asin(4)) assert result.a == cos(asin(4)/2) assert result.b == sqrt(14)*sin(asin(4)/2)/14 assert result.c == sqrt(14)*sin(asin(4)/2)/7 assert result.d == 3*sqrt(14)*sin(asin(4)/2)/14
def test_quaternion_complex_real_addition(): a = symbols("a", complex=True) b = symbols("b", real=True) # This symbol is not complex: c = symbols("c", commutative=False)
q = Quaternion(w, x, y, z) assert a + q == Quaternion(w + re(a), x + im(a), y, z) assert 1 + q == Quaternion(1 + w, x, y, z) assert I + q == Quaternion(w, 1 + x, y, z) assert b + q == Quaternion(w + b, x, y, z) raises(ValueError, lambda: c + q) raises(ValueError, lambda: q * c) raises(ValueError, lambda: c * q)
assert -q == Quaternion(-w, -x, -y, -z)
q1 = Quaternion(3 + 4*I, 2 + 5*I, 0, 7 + 8*I, real_field = False) q2 = Quaternion(1, 4, 7, 8)
assert q1 + (2 + 3*I) == Quaternion(5 + 7*I, 2 + 5*I, 0, 7 + 8*I) assert q2 + (2 + 3*I) == Quaternion(3, 7, 7, 8) assert q1 * (2 + 3*I) == \ Quaternion((2 + 3*I)*(3 + 4*I), (2 + 3*I)*(2 + 5*I), 0, (2 + 3*I)*(7 + 8*I)) assert q2 * (2 + 3*I) == Quaternion(-10, 11, 38, -5)
q1 = Quaternion(1, 2, 3, 4) q0 = Quaternion(0, 0, 0, 0) assert q1 + q0 == q1 assert q1 - q0 == q1 assert q1 - q1 == q0
def test_quaternion_subs(): q = Quaternion.from_axis_angle((0, 0, 1), phi) assert q.subs(phi, 0) == Quaternion(1, 0, 0, 0)
def test_quaternion_evalf(): assert (Quaternion(sqrt(2), 0, 0, sqrt(3)).evalf() == Quaternion(sqrt(2).evalf(), 0, 0, sqrt(3).evalf())) assert (Quaternion(1/sqrt(2), 0, 0, 1/sqrt(2)).evalf() == Quaternion((1/sqrt(2)).evalf(), 0, 0, (1/sqrt(2)).evalf()))
def test_quaternion_functions(): q = Quaternion(w, x, y, z) q1 = Quaternion(1, 2, 3, 4) q0 = Quaternion(0, 0, 0, 0)
assert conjugate(q) == Quaternion(w, -x, -y, -z) assert q.norm() == sqrt(w**2 + x**2 + y**2 + z**2) assert q.normalize() == Quaternion(w, x, y, z) / sqrt(w**2 + x**2 + y**2 + z**2) assert q.inverse() == Quaternion(w, -x, -y, -z) / (w**2 + x**2 + y**2 + z**2) assert q.inverse() == q.pow(-1) raises(ValueError, lambda: q0.inverse()) assert q.pow(2) == Quaternion(w**2 - x**2 - y**2 - z**2, 2*w*x, 2*w*y, 2*w*z) assert q**(2) == Quaternion(w**2 - x**2 - y**2 - z**2, 2*w*x, 2*w*y, 2*w*z) assert q1.pow(-2) == Quaternion( Rational(-7, 225), Rational(-1, 225), Rational(-1, 150), Rational(-2, 225)) assert q1**(-2) == Quaternion( Rational(-7, 225), Rational(-1, 225), Rational(-1, 150), Rational(-2, 225)) assert q1.pow(-0.5) == NotImplemented raises(TypeError, lambda: q1**(-0.5))
assert q1.exp() == \ Quaternion(E * cos(sqrt(29)), 2 * sqrt(29) * E * sin(sqrt(29)) / 29, 3 * sqrt(29) * E * sin(sqrt(29)) / 29, 4 * sqrt(29) * E * sin(sqrt(29)) / 29) assert q1.log() == \ Quaternion(log(sqrt(30)), 2 * sqrt(29) * acos(sqrt(30)/30) / 29, 3 * sqrt(29) * acos(sqrt(30)/30) / 29, 4 * sqrt(29) * acos(sqrt(30)/30) / 29)
assert q1.pow_cos_sin(2) == \ Quaternion(30 * cos(2 * acos(sqrt(30)/30)), 60 * sqrt(29) * sin(2 * acos(sqrt(30)/30)) / 29, 90 * sqrt(29) * sin(2 * acos(sqrt(30)/30)) / 29, 120 * sqrt(29) * sin(2 * acos(sqrt(30)/30)) / 29)
assert diff(Quaternion(x, x, x, x), x) == Quaternion(1, 1, 1, 1)
assert integrate(Quaternion(x, x, x, x), x) == \ Quaternion(x**2 / 2, x**2 / 2, x**2 / 2, x**2 / 2)
assert Quaternion.rotate_point((1, 1, 1), q1) == (S.One / 5, 1, S(7) / 5) n = Symbol('n') raises(TypeError, lambda: q1**n) n = Symbol('n', integer=True) raises(TypeError, lambda: q1**n)
assert Quaternion(22, 23, 55, 8).scalar_part() == 22 assert Quaternion(w, x, y, z).scalar_part() == w
assert Quaternion(22, 23, 55, 8).vector_part() == Quaternion(0, 23, 55, 8) assert Quaternion(w, x, y, z).vector_part() == Quaternion(0, x, y, z)
assert q1.axis() == Quaternion(0, 2*sqrt(29)/29, 3*sqrt(29)/29, 4*sqrt(29)/29) assert q1.axis().pow(2) == Quaternion(-1, 0, 0, 0) assert q0.axis().scalar_part() == 0 assert (q.axis() == Quaternion(0, x/sqrt(x**2 + y**2 + z**2), y/sqrt(x**2 + y**2 + z**2), z/sqrt(x**2 + y**2 + z**2)))
assert q0.is_pure() is True assert q1.is_pure() is False assert Quaternion(0, 0, 0, 3).is_pure() is True assert Quaternion(0, 2, 10, 3).is_pure() is True assert Quaternion(w, 2, 10, 3).is_pure() is None
assert q1.angle() == 2*atan(sqrt(29)) assert q.angle() == 2*atan2(sqrt(x**2 + y**2 + z**2), w)
assert Quaternion.arc_coplanar(q1, Quaternion(2, 4, 6, 8)) is True assert Quaternion.arc_coplanar(q1, Quaternion(1, -2, -3, -4)) is True assert Quaternion.arc_coplanar(q1, Quaternion(1, 8, 12, 16)) is True assert Quaternion.arc_coplanar(q1, Quaternion(1, 2, 3, 4)) is True assert Quaternion.arc_coplanar(q1, Quaternion(w, 4, 6, 8)) is True assert Quaternion.arc_coplanar(q1, Quaternion(2, 7, 4, 1)) is False assert Quaternion.arc_coplanar(q1, Quaternion(w, x, y, z)) is None raises(ValueError, lambda: Quaternion.arc_coplanar(q1, q0))
assert Quaternion.vector_coplanar( Quaternion(0, 8, 12, 16), Quaternion(0, 4, 6, 8), Quaternion(0, 2, 3, 4)) is True assert Quaternion.vector_coplanar( Quaternion(0, 0, 0, 0), Quaternion(0, 4, 6, 8), Quaternion(0, 2, 3, 4)) is True assert Quaternion.vector_coplanar( Quaternion(0, 8, 2, 6), Quaternion(0, 1, 6, 6), Quaternion(0, 0, 3, 4)) is False assert Quaternion.vector_coplanar( Quaternion(0, 1, 3, 4), Quaternion(0, 4, w, 6), Quaternion(0, 6, 8, 1)) is None raises(ValueError, lambda: Quaternion.vector_coplanar(q0, Quaternion(0, 4, 6, 8), q1))
assert Quaternion(0, 1, 2, 3).parallel(Quaternion(0, 2, 4, 6)) is True assert Quaternion(0, 1, 2, 3).parallel(Quaternion(0, 2, 2, 6)) is False assert Quaternion(0, 1, 2, 3).parallel(Quaternion(w, x, y, 6)) is None raises(ValueError, lambda: q0.parallel(q1))
assert Quaternion(0, 1, 2, 3).orthogonal(Quaternion(0, -2, 1, 0)) is True assert Quaternion(0, 2, 4, 7).orthogonal(Quaternion(0, 2, 2, 6)) is False assert Quaternion(0, 2, 4, 7).orthogonal(Quaternion(w, x, y, 6)) is None raises(ValueError, lambda: q0.orthogonal(q1))
assert q1.index_vector() == Quaternion( 0, 2*sqrt(870)/29, 3*sqrt(870)/29, 4*sqrt(870)/29) assert Quaternion(0, 3, 9, 4).index_vector() == Quaternion(0, 3, 9, 4)
assert Quaternion(4, 3, 9, 4).mensor() == log(sqrt(122)) assert Quaternion(3, 3, 0, 2).mensor() == log(sqrt(22))
assert q0.is_zero_quaternion() is True assert q1.is_zero_quaternion() is False assert Quaternion(w, 0, 0, 0).is_zero_quaternion() is None
def test_quaternion_conversions(): q1 = Quaternion(1, 2, 3, 4)
assert q1.to_axis_angle() == ((2 * sqrt(29)/29, 3 * sqrt(29)/29, 4 * sqrt(29)/29), 2 * acos(sqrt(30)/30))
assert (q1.to_rotation_matrix() == Matrix([[Rational(-2, 3), Rational(2, 15), Rational(11, 15)], [Rational(2, 3), Rational(-1, 3), Rational(2, 3)], [Rational(1, 3), Rational(14, 15), Rational(2, 15)]]))
assert (q1.to_rotation_matrix((1, 1, 1)) == Matrix([ [Rational(-2, 3), Rational(2, 15), Rational(11, 15), Rational(4, 5)], [Rational(2, 3), Rational(-1, 3), Rational(2, 3), S.Zero], [Rational(1, 3), Rational(14, 15), Rational(2, 15), Rational(-2, 5)], [S.Zero, S.Zero, S.Zero, S.One]]))
theta = symbols("theta", real=True) q2 = Quaternion(cos(theta/2), 0, 0, sin(theta/2))
assert trigsimp(q2.to_rotation_matrix()) == Matrix([ [cos(theta), -sin(theta), 0], [sin(theta), cos(theta), 0], [0, 0, 1]])
assert q2.to_axis_angle() == ((0, 0, sin(theta/2)/Abs(sin(theta/2))), 2*acos(cos(theta/2)))
assert trigsimp(q2.to_rotation_matrix((1, 1, 1))) == Matrix([ [cos(theta), -sin(theta), 0, sin(theta) - cos(theta) + 1], [sin(theta), cos(theta), 0, -sin(theta) - cos(theta) + 1], [0, 0, 1, 0], [0, 0, 0, 1]])
def test_rotation_matrix_homogeneous(): q = Quaternion(w, x, y, z) R1 = q.to_rotation_matrix(homogeneous=True) * q.norm()**2 R2 = simplify(q.to_rotation_matrix(homogeneous=False) * q.norm()**2) assert R1 == R2
def test_quaternion_rotation_iss1593(): """ There was a sign mistake in the definition, of the rotation matrix. This tests that particular sign mistake. See issue 1593 for reference. See wikipedia https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Quaternion-derived_rotation_matrix for the correct definition """ q = Quaternion(cos(phi/2), sin(phi/2), 0, 0) assert(trigsimp(q.to_rotation_matrix()) == Matrix([ [1, 0, 0], [0, cos(phi), -sin(phi)], [0, sin(phi), cos(phi)]]))
def test_quaternion_multiplication(): q1 = Quaternion(3 + 4*I, 2 + 5*I, 0, 7 + 8*I, real_field = False) q2 = Quaternion(1, 2, 3, 5) q3 = Quaternion(1, 1, 1, y)
assert Quaternion._generic_mul(S(4), S.One) == 4 assert (Quaternion._generic_mul(S(4), q1) == Quaternion(12 + 16*I, 8 + 20*I, 0, 28 + 32*I)) assert q2.mul(2) == Quaternion(2, 4, 6, 10) assert q2.mul(q3) == Quaternion(-5*y - 4, 3*y - 2, 9 - 2*y, y + 4) assert q2.mul(q3) == q2*q3
z = symbols('z', complex=True) z_quat = Quaternion(re(z), im(z), 0, 0) q = Quaternion(*symbols('q:4', real=True))
assert z * q == z_quat * q assert q * z == q * z_quat
def test_issue_16318(): #for rtruediv q0 = Quaternion(0, 0, 0, 0) raises(ValueError, lambda: 1/q0) #for rotate_point q = Quaternion(1, 2, 3, 4) (axis, angle) = q.to_axis_angle() assert Quaternion.rotate_point((1, 1, 1), (axis, angle)) == (S.One / 5, 1, S(7) / 5) #test for to_axis_angle q = Quaternion(-1, 1, 1, 1) axis = (-sqrt(3)/3, -sqrt(3)/3, -sqrt(3)/3) angle = 2*pi/3 assert (axis, angle) == q.to_axis_angle()
@slowdef test_to_euler(): q = Quaternion(w, x, y, z) q_normalized = q.normalize()
seqs = ['zxy', 'zyx', 'zyz', 'zxz'] seqs += [seq.upper() for seq in seqs]
for seq in seqs: euler_from_q = q.to_euler(seq) q_back = simplify(Quaternion.from_euler(euler_from_q, seq)) assert q_back == q_normalized
def test_to_euler_iss24504(): """ There was a mistake in the degenerate case testing See issue 24504 for reference. """ q = Quaternion.from_euler((phi, 0, 0), 'zyz') assert trigsimp(q.to_euler('zyz'), inverse=True) == (phi, 0, 0)
def test_to_euler_numerical_singilarities():
def test_one_case(angles, seq): q = Quaternion.from_euler(angles, seq) assert q.to_euler(seq) == angles
# symmetric test_one_case((pi/2, 0, 0), 'zyz') test_one_case((pi/2, 0, 0), 'ZYZ') test_one_case((pi/2, pi, 0), 'zyz') test_one_case((pi/2, pi, 0), 'ZYZ')
# asymmetric test_one_case((pi/2, pi/2, 0), 'zyx') test_one_case((pi/2, -pi/2, 0), 'zyx') test_one_case((pi/2, pi/2, 0), 'ZYX') test_one_case((pi/2, -pi/2, 0), 'ZYX')
@slowdef test_to_euler_options(): def test_one_case(q): angles1 = Matrix(q.to_euler(seq, True, True)) angles2 = Matrix(q.to_euler(seq, False, False)) angle_errors = simplify(angles1-angles2).evalf() for angle_error in angle_errors: # forcing angles to set {-pi, pi} angle_error = (angle_error + pi) % (2 * pi) - pi assert angle_error < 10e-7
for xyz in ('xyz', 'XYZ'): for seq_tuple in permutations(xyz): for symmetric in (True, False): if symmetric: seq = ''.join([seq_tuple[0], seq_tuple[1], seq_tuple[0]]) else: seq = ''.join(seq_tuple)
for elements in product([-1, 0, 1], repeat=4): q = Quaternion(*elements) if not q.is_zero_quaternion(): test_one_case(q)123456789101112131415161718"""A module to implement logical predicates and assumption system."""
from .assume import ( AppliedPredicate, Predicate, AssumptionsContext, assuming, global_assumptions)from .ask import Q, ask, register_handler, remove_handlerfrom .refine import refinefrom .relation import BinaryRelation, AppliedBinaryRelation
__all__ = [ 'AppliedPredicate', 'Predicate', 'AssumptionsContext', 'assuming', 'global_assumptions', 'Q', 'ask', 'register_handler', 'remove_handler', 'refine', 'BinaryRelation', 'AppliedBinaryRelation']123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651"""Module for querying SymPy objects about assumptions."""
from sympy.assumptions.assume import (global_assumptions, Predicate, AppliedPredicate)from sympy.assumptions.cnf import CNF, EncodedCNF, Literalfrom sympy.core import sympifyfrom sympy.core.kind import BooleanKindfrom sympy.core.relational import Eq, Ne, Gt, Lt, Ge, Lefrom sympy.logic.inference import satisfiablefrom sympy.utilities.decorator import memoize_propertyfrom sympy.utilities.exceptions import (sympy_deprecation_warning, SymPyDeprecationWarning, ignore_warnings)
# Memoization is necessary for the properties of AssumptionKeys to# ensure that only one object of Predicate objects are created.# This is because assumption handlers are registered on those objects.
class AssumptionKeys: """ This class contains all the supported keys by ``ask``. It should be accessed via the instance ``sympy.Q``.
"""
# DO NOT add methods or properties other than predicate keys. # SAT solver checks the properties of Q and use them to compute the # fact system. Non-predicate attributes will break this.
@memoize_property def hermitian(self): from .handlers.sets import HermitianPredicate return HermitianPredicate()
@memoize_property def antihermitian(self): from .handlers.sets import AntihermitianPredicate return AntihermitianPredicate()
@memoize_property def real(self): from .handlers.sets import RealPredicate return RealPredicate()
@memoize_property def extended_real(self): from .handlers.sets import ExtendedRealPredicate return ExtendedRealPredicate()
@memoize_property def imaginary(self): from .handlers.sets import ImaginaryPredicate return ImaginaryPredicate()
@memoize_property def complex(self): from .handlers.sets import ComplexPredicate return ComplexPredicate()
@memoize_property def algebraic(self): from .handlers.sets import AlgebraicPredicate return AlgebraicPredicate()
@memoize_property def transcendental(self): from .predicates.sets import TranscendentalPredicate return TranscendentalPredicate()
@memoize_property def integer(self): from .handlers.sets import IntegerPredicate return IntegerPredicate()
@memoize_property def noninteger(self): from .predicates.sets import NonIntegerPredicate return NonIntegerPredicate()
@memoize_property def rational(self): from .handlers.sets import RationalPredicate return RationalPredicate()
@memoize_property def irrational(self): from .handlers.sets import IrrationalPredicate return IrrationalPredicate()
@memoize_property def finite(self): from .handlers.calculus import FinitePredicate return FinitePredicate()
@memoize_property def infinite(self): from .handlers.calculus import InfinitePredicate return InfinitePredicate()
@memoize_property def positive_infinite(self): from .handlers.calculus import PositiveInfinitePredicate return PositiveInfinitePredicate()
@memoize_property def negative_infinite(self): from .handlers.calculus import NegativeInfinitePredicate return NegativeInfinitePredicate()
@memoize_property def positive(self): from .handlers.order import PositivePredicate return PositivePredicate()
@memoize_property def negative(self): from .handlers.order import NegativePredicate return NegativePredicate()
@memoize_property def zero(self): from .handlers.order import ZeroPredicate return ZeroPredicate()
@memoize_property def extended_positive(self): from .handlers.order import ExtendedPositivePredicate return ExtendedPositivePredicate()
@memoize_property def extended_negative(self): from .handlers.order import ExtendedNegativePredicate return ExtendedNegativePredicate()
@memoize_property def nonzero(self): from .handlers.order import NonZeroPredicate return NonZeroPredicate()
@memoize_property def nonpositive(self): from .handlers.order import NonPositivePredicate return NonPositivePredicate()
@memoize_property def nonnegative(self): from .handlers.order import NonNegativePredicate return NonNegativePredicate()
@memoize_property def extended_nonzero(self): from .handlers.order import ExtendedNonZeroPredicate return ExtendedNonZeroPredicate()
@memoize_property def extended_nonpositive(self): from .handlers.order import ExtendedNonPositivePredicate return ExtendedNonPositivePredicate()
@memoize_property def extended_nonnegative(self): from .handlers.order import ExtendedNonNegativePredicate return ExtendedNonNegativePredicate()
@memoize_property def even(self): from .handlers.ntheory import EvenPredicate return EvenPredicate()
@memoize_property def odd(self): from .handlers.ntheory import OddPredicate return OddPredicate()
@memoize_property def prime(self): from .handlers.ntheory import PrimePredicate return PrimePredicate()
@memoize_property def composite(self): from .handlers.ntheory import CompositePredicate return CompositePredicate()
@memoize_property def commutative(self): from .handlers.common import CommutativePredicate return CommutativePredicate()
@memoize_property def is_true(self): from .handlers.common import IsTruePredicate return IsTruePredicate()
@memoize_property def symmetric(self): from .handlers.matrices import SymmetricPredicate return SymmetricPredicate()
@memoize_property def invertible(self): from .handlers.matrices import InvertiblePredicate return InvertiblePredicate()
@memoize_property def orthogonal(self): from .handlers.matrices import OrthogonalPredicate return OrthogonalPredicate()
@memoize_property def unitary(self): from .handlers.matrices import UnitaryPredicate return UnitaryPredicate()
@memoize_property def positive_definite(self): from .handlers.matrices import PositiveDefinitePredicate return PositiveDefinitePredicate()
@memoize_property def upper_triangular(self): from .handlers.matrices import UpperTriangularPredicate return UpperTriangularPredicate()
@memoize_property def lower_triangular(self): from .handlers.matrices import LowerTriangularPredicate return LowerTriangularPredicate()
@memoize_property def diagonal(self): from .handlers.matrices import DiagonalPredicate return DiagonalPredicate()
@memoize_property def fullrank(self): from .handlers.matrices import FullRankPredicate return FullRankPredicate()
@memoize_property def square(self): from .handlers.matrices import SquarePredicate return SquarePredicate()
@memoize_property def integer_elements(self): from .handlers.matrices import IntegerElementsPredicate return IntegerElementsPredicate()
@memoize_property def real_elements(self): from .handlers.matrices import RealElementsPredicate return RealElementsPredicate()
@memoize_property def complex_elements(self): from .handlers.matrices import ComplexElementsPredicate return ComplexElementsPredicate()
@memoize_property def singular(self): from .predicates.matrices import SingularPredicate return SingularPredicate()
@memoize_property def normal(self): from .predicates.matrices import NormalPredicate return NormalPredicate()
@memoize_property def triangular(self): from .predicates.matrices import TriangularPredicate return TriangularPredicate()
@memoize_property def unit_triangular(self): from .predicates.matrices import UnitTriangularPredicate return UnitTriangularPredicate()
@memoize_property def eq(self): from .relation.equality import EqualityPredicate return EqualityPredicate()
@memoize_property def ne(self): from .relation.equality import UnequalityPredicate return UnequalityPredicate()
@memoize_property def gt(self): from .relation.equality import StrictGreaterThanPredicate return StrictGreaterThanPredicate()
@memoize_property def ge(self): from .relation.equality import GreaterThanPredicate return GreaterThanPredicate()
@memoize_property def lt(self): from .relation.equality import StrictLessThanPredicate return StrictLessThanPredicate()
@memoize_property def le(self): from .relation.equality import LessThanPredicate return LessThanPredicate()
Q = AssumptionKeys()
def _extract_all_facts(assump, exprs): """ Extract all relevant assumptions from *assump* with respect to given *exprs*.
Parameters ==========
assump : sympy.assumptions.cnf.CNF
exprs : tuple of expressions
Returns =======
sympy.assumptions.cnf.CNF
Examples ========
>>> from sympy import Q >>> from sympy.assumptions.cnf import CNF >>> from sympy.assumptions.ask import _extract_all_facts >>> from sympy.abc import x, y >>> assump = CNF.from_prop(Q.positive(x) & Q.integer(y)) >>> exprs = (x,) >>> cnf = _extract_all_facts(assump, exprs) >>> cnf.clauses {frozenset({Literal(Q.positive, False)})}
""" facts = set()
for clause in assump.clauses: args = [] for literal in clause: if isinstance(literal.lit, AppliedPredicate) and len(literal.lit.arguments) == 1: if literal.lit.arg in exprs: # Add literal if it has matching in it args.append(Literal(literal.lit.function, literal.is_Not)) else: # If any of the literals doesn't have matching expr don't add the whole clause. break else: # If any of the literals aren't unary predicate don't add the whole clause. break
else: if args: facts.add(frozenset(args)) return CNF(facts)
def ask(proposition, assumptions=True, context=global_assumptions): """ Function to evaluate the proposition with assumptions.
Explanation ===========
This function evaluates the proposition to ``True`` or ``False`` if the truth value can be determined. If not, it returns ``None``.
It should be discerned from :func:`~.refine()` which, when applied to a proposition, simplifies the argument to symbolic ``Boolean`` instead of Python built-in ``True``, ``False`` or ``None``.
**Syntax**
* ask(proposition) Evaluate the *proposition* in global assumption context.
* ask(proposition, assumptions) Evaluate the *proposition* with respect to *assumptions* in global assumption context.
Parameters ==========
proposition : Boolean Proposition which will be evaluated to boolean value. If this is not ``AppliedPredicate``, it will be wrapped by ``Q.is_true``.
assumptions : Boolean, optional Local assumptions to evaluate the *proposition*.
context : AssumptionsContext, optional Default assumptions to evaluate the *proposition*. By default, this is ``sympy.assumptions.global_assumptions`` variable.
Returns =======
``True``, ``False``, or ``None``
Raises ======
TypeError : *proposition* or *assumptions* is not valid logical expression.
ValueError : assumptions are inconsistent.
Examples ========
>>> from sympy import ask, Q, pi >>> from sympy.abc import x, y >>> ask(Q.rational(pi)) False >>> ask(Q.even(x*y), Q.even(x) & Q.integer(y)) True >>> ask(Q.prime(4*x), Q.integer(x)) False
If the truth value cannot be determined, ``None`` will be returned.
>>> print(ask(Q.odd(3*x))) # cannot determine unless we know x None
``ValueError`` is raised if assumptions are inconsistent.
>>> ask(Q.integer(x), Q.even(x) & Q.odd(x)) Traceback (most recent call last): ... ValueError: inconsistent assumptions Q.even(x) & Q.odd(x)
Notes =====
Relations in assumptions are not implemented (yet), so the following will not give a meaningful result.
>>> ask(Q.positive(x), x > 0)
It is however a work in progress.
See Also ========
sympy.assumptions.refine.refine : Simplification using assumptions. Proposition is not reduced to ``None`` if the truth value cannot be determined. """ from sympy.assumptions.satask import satask from sympy.assumptions.lra_satask import lra_satask from sympy.logic.algorithms.lra_theory import UnhandledInput
proposition = sympify(proposition) assumptions = sympify(assumptions)
if isinstance(proposition, Predicate) or proposition.kind is not BooleanKind: raise TypeError("proposition must be a valid logical expression")
if isinstance(assumptions, Predicate) or assumptions.kind is not BooleanKind: raise TypeError("assumptions must be a valid logical expression")
binrelpreds = {Eq: Q.eq, Ne: Q.ne, Gt: Q.gt, Lt: Q.lt, Ge: Q.ge, Le: Q.le} if isinstance(proposition, AppliedPredicate): key, args = proposition.function, proposition.arguments elif proposition.func in binrelpreds: key, args = binrelpreds[type(proposition)], proposition.args else: key, args = Q.is_true, (proposition,)
# convert local and global assumptions to CNF assump_cnf = CNF.from_prop(assumptions) assump_cnf.extend(context)
# extract the relevant facts from assumptions with respect to args local_facts = _extract_all_facts(assump_cnf, args)
# convert default facts and assumed facts to encoded CNF known_facts_cnf = get_all_known_facts() enc_cnf = EncodedCNF() enc_cnf.from_cnf(CNF(known_facts_cnf)) enc_cnf.add_from_cnf(local_facts)
# check the satisfiability of given assumptions if local_facts.clauses and satisfiable(enc_cnf) is False: raise ValueError("inconsistent assumptions %s" % assumptions)
# quick computation for single fact res = _ask_single_fact(key, local_facts) if res is not None: return res
# direct resolution method, no logic res = key(*args)._eval_ask(assumptions) if res is not None: return bool(res)
# using satask (still costly) res = satask(proposition, assumptions=assumptions, context=context) if res is not None: return res
try: res = lra_satask(proposition, assumptions=assumptions, context=context) except UnhandledInput: return None
return res
def _ask_single_fact(key, local_facts): """ Compute the truth value of single predicate using assumptions.
Parameters ==========
key : sympy.assumptions.assume.Predicate Proposition predicate.
local_facts : sympy.assumptions.cnf.CNF Local assumption in CNF form.
Returns =======
``True``, ``False`` or ``None``
Examples ========
>>> from sympy import Q >>> from sympy.assumptions.cnf import CNF >>> from sympy.assumptions.ask import _ask_single_fact
If prerequisite of proposition is rejected by the assumption, return ``False``.
>>> key, assump = Q.zero, ~Q.zero >>> local_facts = CNF.from_prop(assump) >>> _ask_single_fact(key, local_facts) False >>> key, assump = Q.zero, ~Q.even >>> local_facts = CNF.from_prop(assump) >>> _ask_single_fact(key, local_facts) False
If assumption implies the proposition, return ``True``.
>>> key, assump = Q.even, Q.zero >>> local_facts = CNF.from_prop(assump) >>> _ask_single_fact(key, local_facts) True
If proposition rejects the assumption, return ``False``.
>>> key, assump = Q.even, Q.odd >>> local_facts = CNF.from_prop(assump) >>> _ask_single_fact(key, local_facts) False """ if local_facts.clauses:
known_facts_dict = get_known_facts_dict()
if len(local_facts.clauses) == 1: cl, = local_facts.clauses if len(cl) == 1: f, = cl prop_facts = known_facts_dict.get(key, None) prop_req = prop_facts[0] if prop_facts is not None else set() if f.is_Not and f.arg in prop_req: # the prerequisite of proposition is rejected return False
for clause in local_facts.clauses: if len(clause) == 1: f, = clause prop_facts = known_facts_dict.get(f.arg, None) if not f.is_Not else None if prop_facts is None: continue
prop_req, prop_rej = prop_facts if key in prop_req: # assumption implies the proposition return True elif key in prop_rej: # proposition rejects the assumption return False
return None
def register_handler(key, handler): """ Register a handler in the ask system. key must be a string and handler a class inheriting from AskHandler.
.. deprecated:: 1.8. Use multipledispatch handler instead. See :obj:`~.Predicate`.
""" sympy_deprecation_warning( """ The AskHandler system is deprecated. The register_handler() function should be replaced with the multipledispatch handler of Predicate. """, deprecated_since_version="1.8", active_deprecations_target='deprecated-askhandler', ) if isinstance(key, Predicate): key = key.name.name Qkey = getattr(Q, key, None) if Qkey is not None: Qkey.add_handler(handler) else: setattr(Q, key, Predicate(key, handlers=[handler]))
def remove_handler(key, handler): """ Removes a handler from the ask system.
.. deprecated:: 1.8. Use multipledispatch handler instead. See :obj:`~.Predicate`.
""" sympy_deprecation_warning( """ The AskHandler system is deprecated. The remove_handler() function should be replaced with the multipledispatch handler of Predicate. """, deprecated_since_version="1.8", active_deprecations_target='deprecated-askhandler', ) if isinstance(key, Predicate): key = key.name.name # Don't show the same warning again recursively with ignore_warnings(SymPyDeprecationWarning): getattr(Q, key).remove_handler(handler)
from sympy.assumptions.ask_generated import (get_all_known_facts, get_known_facts_dict)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352"""Do NOT manually edit this file.Instead, run ./bin/ask_update.py."""
from sympy.assumptions.ask import Qfrom sympy.assumptions.cnf import Literalfrom sympy.core.cache import cacheit
@cacheitdef get_all_known_facts(): """ Known facts between unary predicates as CNF clauses. """ return { frozenset((Literal(Q.algebraic, False), Literal(Q.imaginary, True), Literal(Q.transcendental, False))), frozenset((Literal(Q.algebraic, False), Literal(Q.negative, True), Literal(Q.transcendental, False))), frozenset((Literal(Q.algebraic, False), Literal(Q.positive, True), Literal(Q.transcendental, False))), frozenset((Literal(Q.algebraic, False), Literal(Q.rational, True))), frozenset((Literal(Q.algebraic, False), Literal(Q.transcendental, False), Literal(Q.zero, True))), frozenset((Literal(Q.algebraic, True), Literal(Q.finite, False))), frozenset((Literal(Q.algebraic, True), Literal(Q.transcendental, True))), frozenset((Literal(Q.antihermitian, False), Literal(Q.hermitian, False), Literal(Q.zero, True))), frozenset((Literal(Q.antihermitian, False), Literal(Q.imaginary, True))), frozenset((Literal(Q.commutative, False), Literal(Q.finite, True))), frozenset((Literal(Q.commutative, False), Literal(Q.infinite, True))), frozenset((Literal(Q.complex_elements, False), Literal(Q.real_elements, True))), frozenset((Literal(Q.composite, False), Literal(Q.even, True), Literal(Q.positive, True), Literal(Q.prime, False))), frozenset((Literal(Q.composite, True), Literal(Q.even, False), Literal(Q.odd, False))), frozenset((Literal(Q.composite, True), Literal(Q.positive, False))), frozenset((Literal(Q.composite, True), Literal(Q.prime, True))), frozenset((Literal(Q.diagonal, False), Literal(Q.lower_triangular, True), Literal(Q.upper_triangular, True))), frozenset((Literal(Q.diagonal, True), Literal(Q.lower_triangular, False))), frozenset((Literal(Q.diagonal, True), Literal(Q.normal, False))), frozenset((Literal(Q.diagonal, True), Literal(Q.symmetric, False))), frozenset((Literal(Q.diagonal, True), Literal(Q.upper_triangular, False))), frozenset((Literal(Q.even, False), Literal(Q.odd, False), Literal(Q.prime, True))), frozenset((Literal(Q.even, False), Literal(Q.zero, True))), frozenset((Literal(Q.even, True), Literal(Q.odd, True))), frozenset((Literal(Q.even, True), Literal(Q.rational, False))), frozenset((Literal(Q.finite, False), Literal(Q.transcendental, True))), frozenset((Literal(Q.finite, True), Literal(Q.infinite, True))), frozenset((Literal(Q.fullrank, False), Literal(Q.invertible, True))), frozenset((Literal(Q.fullrank, True), Literal(Q.invertible, False), Literal(Q.square, True))), frozenset((Literal(Q.hermitian, False), Literal(Q.negative, True))), frozenset((Literal(Q.hermitian, False), Literal(Q.positive, True))), frozenset((Literal(Q.hermitian, False), Literal(Q.zero, True))), frozenset((Literal(Q.imaginary, True), Literal(Q.negative, True))), frozenset((Literal(Q.imaginary, True), Literal(Q.positive, True))), frozenset((Literal(Q.imaginary, True), Literal(Q.zero, True))), frozenset((Literal(Q.infinite, False), Literal(Q.negative_infinite, True))), frozenset((Literal(Q.infinite, False), Literal(Q.positive_infinite, True))), frozenset((Literal(Q.integer_elements, True), Literal(Q.real_elements, False))), frozenset((Literal(Q.invertible, False), Literal(Q.positive_definite, True))), frozenset((Literal(Q.invertible, False), Literal(Q.singular, False))), frozenset((Literal(Q.invertible, False), Literal(Q.unitary, True))), frozenset((Literal(Q.invertible, True), Literal(Q.singular, True))), frozenset((Literal(Q.invertible, True), Literal(Q.square, False))), frozenset((Literal(Q.irrational, False), Literal(Q.negative, True), Literal(Q.rational, False))), frozenset((Literal(Q.irrational, False), Literal(Q.positive, True), Literal(Q.rational, False))), frozenset((Literal(Q.irrational, False), Literal(Q.rational, False), Literal(Q.zero, True))), frozenset((Literal(Q.irrational, True), Literal(Q.negative, False), Literal(Q.positive, False), Literal(Q.zero, False))), frozenset((Literal(Q.irrational, True), Literal(Q.rational, True))), frozenset((Literal(Q.lower_triangular, False), Literal(Q.triangular, True), Literal(Q.upper_triangular, False))), frozenset((Literal(Q.lower_triangular, True), Literal(Q.triangular, False))), frozenset((Literal(Q.negative, False), Literal(Q.positive, False), Literal(Q.rational, True), Literal(Q.zero, False))), frozenset((Literal(Q.negative, True), Literal(Q.negative_infinite, True))), frozenset((Literal(Q.negative, True), Literal(Q.positive, True))), frozenset((Literal(Q.negative, True), Literal(Q.positive_infinite, True))), frozenset((Literal(Q.negative, True), Literal(Q.zero, True))), frozenset((Literal(Q.negative_infinite, True), Literal(Q.positive, True))), frozenset((Literal(Q.negative_infinite, True), Literal(Q.positive_infinite, True))), frozenset((Literal(Q.negative_infinite, True), Literal(Q.zero, True))), frozenset((Literal(Q.normal, False), Literal(Q.unitary, True))), frozenset((Literal(Q.normal, True), Literal(Q.square, False))), frozenset((Literal(Q.odd, True), Literal(Q.rational, False))), frozenset((Literal(Q.orthogonal, False), Literal(Q.real_elements, True), Literal(Q.unitary, True))), frozenset((Literal(Q.orthogonal, True), Literal(Q.positive_definite, False))), frozenset((Literal(Q.orthogonal, True), Literal(Q.unitary, False))), frozenset((Literal(Q.positive, False), Literal(Q.prime, True))), frozenset((Literal(Q.positive, True), Literal(Q.positive_infinite, True))), frozenset((Literal(Q.positive, True), Literal(Q.zero, True))), frozenset((Literal(Q.positive_infinite, True), Literal(Q.zero, True))), frozenset((Literal(Q.square, False), Literal(Q.symmetric, True))), frozenset((Literal(Q.triangular, False), Literal(Q.unit_triangular, True))), frozenset((Literal(Q.triangular, False), Literal(Q.upper_triangular, True))) }
@cacheitdef get_all_known_matrix_facts(): """ Known facts between unary predicates for matrices as CNF clauses. """ return { frozenset((Literal(Q.complex_elements, False), Literal(Q.real_elements, True))), frozenset((Literal(Q.diagonal, False), Literal(Q.lower_triangular, True), Literal(Q.upper_triangular, True))), frozenset((Literal(Q.diagonal, True), Literal(Q.lower_triangular, False))), frozenset((Literal(Q.diagonal, True), Literal(Q.normal, False))), frozenset((Literal(Q.diagonal, True), Literal(Q.symmetric, False))), frozenset((Literal(Q.diagonal, True), Literal(Q.upper_triangular, False))), frozenset((Literal(Q.fullrank, False), Literal(Q.invertible, True))), frozenset((Literal(Q.fullrank, True), Literal(Q.invertible, False), Literal(Q.square, True))), frozenset((Literal(Q.integer_elements, True), Literal(Q.real_elements, False))), frozenset((Literal(Q.invertible, False), Literal(Q.positive_definite, True))), frozenset((Literal(Q.invertible, False), Literal(Q.singular, False))), frozenset((Literal(Q.invertible, False), Literal(Q.unitary, True))), frozenset((Literal(Q.invertible, True), Literal(Q.singular, True))), frozenset((Literal(Q.invertible, True), Literal(Q.square, False))), frozenset((Literal(Q.lower_triangular, False), Literal(Q.triangular, True), Literal(Q.upper_triangular, False))), frozenset((Literal(Q.lower_triangular, True), Literal(Q.triangular, False))), frozenset((Literal(Q.normal, False), Literal(Q.unitary, True))), frozenset((Literal(Q.normal, True), Literal(Q.square, False))), frozenset((Literal(Q.orthogonal, False), Literal(Q.real_elements, True), Literal(Q.unitary, True))), frozenset((Literal(Q.orthogonal, True), Literal(Q.positive_definite, False))), frozenset((Literal(Q.orthogonal, True), Literal(Q.unitary, False))), frozenset((Literal(Q.square, False), Literal(Q.symmetric, True))), frozenset((Literal(Q.triangular, False), Literal(Q.unit_triangular, True))), frozenset((Literal(Q.triangular, False), Literal(Q.upper_triangular, True))) }
@cacheitdef get_all_known_number_facts(): """ Known facts between unary predicates for numbers as CNF clauses. """ return { frozenset((Literal(Q.algebraic, False), Literal(Q.imaginary, True), Literal(Q.transcendental, False))), frozenset((Literal(Q.algebraic, False), Literal(Q.negative, True), Literal(Q.transcendental, False))), frozenset((Literal(Q.algebraic, False), Literal(Q.positive, True), Literal(Q.transcendental, False))), frozenset((Literal(Q.algebraic, False), Literal(Q.rational, True))), frozenset((Literal(Q.algebraic, False), Literal(Q.transcendental, False), Literal(Q.zero, True))), frozenset((Literal(Q.algebraic, True), Literal(Q.finite, False))), frozenset((Literal(Q.algebraic, True), Literal(Q.transcendental, True))), frozenset((Literal(Q.antihermitian, False), Literal(Q.hermitian, False), Literal(Q.zero, True))), frozenset((Literal(Q.antihermitian, False), Literal(Q.imaginary, True))), frozenset((Literal(Q.commutative, False), Literal(Q.finite, True))), frozenset((Literal(Q.commutative, False), Literal(Q.infinite, True))), frozenset((Literal(Q.composite, False), Literal(Q.even, True), Literal(Q.positive, True), Literal(Q.prime, False))), frozenset((Literal(Q.composite, True), Literal(Q.even, False), Literal(Q.odd, False))), frozenset((Literal(Q.composite, True), Literal(Q.positive, False))), frozenset((Literal(Q.composite, True), Literal(Q.prime, True))), frozenset((Literal(Q.even, False), Literal(Q.odd, False), Literal(Q.prime, True))), frozenset((Literal(Q.even, False), Literal(Q.zero, True))), frozenset((Literal(Q.even, True), Literal(Q.odd, True))), frozenset((Literal(Q.even, True), Literal(Q.rational, False))), frozenset((Literal(Q.finite, False), Literal(Q.transcendental, True))), frozenset((Literal(Q.finite, True), Literal(Q.infinite, True))), frozenset((Literal(Q.hermitian, False), Literal(Q.negative, True))), frozenset((Literal(Q.hermitian, False), Literal(Q.positive, True))), frozenset((Literal(Q.hermitian, False), Literal(Q.zero, True))), frozenset((Literal(Q.imaginary, True), Literal(Q.negative, True))), frozenset((Literal(Q.imaginary, True), Literal(Q.positive, True))), frozenset((Literal(Q.imaginary, True), Literal(Q.zero, True))), frozenset((Literal(Q.infinite, False), Literal(Q.negative_infinite, True))), frozenset((Literal(Q.infinite, False), Literal(Q.positive_infinite, True))), frozenset((Literal(Q.irrational, False), Literal(Q.negative, True), Literal(Q.rational, False))), frozenset((Literal(Q.irrational, False), Literal(Q.positive, True), Literal(Q.rational, False))), frozenset((Literal(Q.irrational, False), Literal(Q.rational, False), Literal(Q.zero, True))), frozenset((Literal(Q.irrational, True), Literal(Q.negative, False), Literal(Q.positive, False), Literal(Q.zero, False))), frozenset((Literal(Q.irrational, True), Literal(Q.rational, True))), frozenset((Literal(Q.negative, False), Literal(Q.positive, False), Literal(Q.rational, True), Literal(Q.zero, False))), frozenset((Literal(Q.negative, True), Literal(Q.negative_infinite, True))), frozenset((Literal(Q.negative, True), Literal(Q.positive, True))), frozenset((Literal(Q.negative, True), Literal(Q.positive_infinite, True))), frozenset((Literal(Q.negative, True), Literal(Q.zero, True))), frozenset((Literal(Q.negative_infinite, True), Literal(Q.positive, True))), frozenset((Literal(Q.negative_infinite, True), Literal(Q.positive_infinite, True))), frozenset((Literal(Q.negative_infinite, True), Literal(Q.zero, True))), frozenset((Literal(Q.odd, True), Literal(Q.rational, False))), frozenset((Literal(Q.positive, False), Literal(Q.prime, True))), frozenset((Literal(Q.positive, True), Literal(Q.positive_infinite, True))), frozenset((Literal(Q.positive, True), Literal(Q.zero, True))), frozenset((Literal(Q.positive_infinite, True), Literal(Q.zero, True))) }
@cacheitdef get_known_facts_dict(): """ Logical relations between unary predicates as dictionary.
Each key is a predicate, and item is two groups of predicates. First group contains the predicates which are implied by the key, and second group contains the predicates which are rejected by the key.
""" return { Q.algebraic: (set([Q.algebraic, Q.commutative, Q.complex, Q.finite]), set([Q.infinite, Q.negative_infinite, Q.positive_infinite, Q.transcendental])), Q.antihermitian: (set([Q.antihermitian]), set([])), Q.commutative: (set([Q.commutative]), set([])), Q.complex: (set([Q.commutative, Q.complex, Q.finite]), set([Q.infinite, Q.negative_infinite, Q.positive_infinite])), Q.complex_elements: (set([Q.complex_elements]), set([])), Q.composite: (set([Q.algebraic, Q.commutative, Q.complex, Q.composite, Q.extended_nonnegative, Q.extended_nonzero, Q.extended_positive, Q.extended_real, Q.finite, Q.hermitian, Q.integer, Q.nonnegative, Q.nonzero, Q.positive, Q.rational, Q.real]), set([Q.extended_negative, Q.extended_nonpositive, Q.imaginary, Q.infinite, Q.irrational, Q.negative, Q.negative_infinite, Q.nonpositive, Q.positive_infinite, Q.prime, Q.transcendental, Q.zero])), Q.diagonal: (set([Q.diagonal, Q.lower_triangular, Q.normal, Q.square, Q.symmetric, Q.triangular, Q.upper_triangular]), set([])), Q.even: (set([Q.algebraic, Q.commutative, Q.complex, Q.even, Q.extended_real, Q.finite, Q.hermitian, Q.integer, Q.rational, Q.real]), set([Q.imaginary, Q.infinite, Q.irrational, Q.negative_infinite, Q.odd, Q.positive_infinite, Q.transcendental])), Q.extended_negative: (set([Q.commutative, Q.extended_negative, Q.extended_nonpositive, Q.extended_nonzero, Q.extended_real]), set([Q.composite, Q.extended_nonnegative, Q.extended_positive, Q.imaginary, Q.nonnegative, Q.positive, Q.positive_infinite, Q.prime, Q.zero])), Q.extended_nonnegative: (set([Q.commutative, Q.extended_nonnegative, Q.extended_real]), set([Q.extended_negative, Q.imaginary, Q.negative, Q.negative_infinite])), Q.extended_nonpositive: (set([Q.commutative, Q.extended_nonpositive, Q.extended_real]), set([Q.composite, Q.extended_positive, Q.imaginary, Q.positive, Q.positive_infinite, Q.prime])), Q.extended_nonzero: (set([Q.commutative, Q.extended_nonzero, Q.extended_real]), set([Q.imaginary, Q.zero])), Q.extended_positive: (set([Q.commutative, Q.extended_nonnegative, Q.extended_nonzero, Q.extended_positive, Q.extended_real]), set([Q.extended_negative, Q.extended_nonpositive, Q.imaginary, Q.negative, Q.negative_infinite, Q.nonpositive, Q.zero])), Q.extended_real: (set([Q.commutative, Q.extended_real]), set([Q.imaginary])), Q.finite: (set([Q.commutative, Q.finite]), set([Q.infinite, Q.negative_infinite, Q.positive_infinite])), Q.fullrank: (set([Q.fullrank]), set([])), Q.hermitian: (set([Q.hermitian]), set([])), Q.imaginary: (set([Q.antihermitian, Q.commutative, Q.complex, Q.finite, Q.imaginary]), set([Q.composite, Q.even, Q.extended_negative, Q.extended_nonnegative, Q.extended_nonpositive, Q.extended_nonzero, Q.extended_positive, Q.extended_real, Q.infinite, Q.integer, Q.irrational, Q.negative, Q.negative_infinite, Q.nonnegative, Q.nonpositive, Q.nonzero, Q.odd, Q.positive, Q.positive_infinite, Q.prime, Q.rational, Q.real, Q.zero])), Q.infinite: (set([Q.commutative, Q.infinite]), set([Q.algebraic, Q.complex, Q.composite, Q.even, Q.finite, Q.imaginary, Q.integer, Q.irrational, Q.negative, Q.nonnegative, Q.nonpositive, Q.nonzero, Q.odd, Q.positive, Q.prime, Q.rational, Q.real, Q.transcendental, Q.zero])), Q.integer: (set([Q.algebraic, Q.commutative, Q.complex, Q.extended_real, Q.finite, Q.hermitian, Q.integer, Q.rational, Q.real]), set([Q.imaginary, Q.infinite, Q.irrational, Q.negative_infinite, Q.positive_infinite, Q.transcendental])), Q.integer_elements: (set([Q.complex_elements, Q.integer_elements, Q.real_elements]), set([])), Q.invertible: (set([Q.fullrank, Q.invertible, Q.square]), set([Q.singular])), Q.irrational: (set([Q.commutative, Q.complex, Q.extended_nonzero, Q.extended_real, Q.finite, Q.hermitian, Q.irrational, Q.nonzero, Q.real]), set([Q.composite, Q.even, Q.imaginary, Q.infinite, Q.integer, Q.negative_infinite, Q.odd, Q.positive_infinite, Q.prime, Q.rational, Q.zero])), Q.is_true: (set([Q.is_true]), set([])), Q.lower_triangular: (set([Q.lower_triangular, Q.triangular]), set([])), Q.negative: (set([Q.commutative, Q.complex, Q.extended_negative, Q.extended_nonpositive, Q.extended_nonzero, Q.extended_real, Q.finite, Q.hermitian, Q.negative, Q.nonpositive, Q.nonzero, Q.real]), set([Q.composite, Q.extended_nonnegative, Q.extended_positive, Q.imaginary, Q.infinite, Q.negative_infinite, Q.nonnegative, Q.positive, Q.positive_infinite, Q.prime, Q.zero])), Q.negative_infinite: (set([Q.commutative, Q.extended_negative, Q.extended_nonpositive, Q.extended_nonzero, Q.extended_real, Q.infinite, Q.negative_infinite]), set([Q.algebraic, Q.complex, Q.composite, Q.even, Q.extended_nonnegative, Q.extended_positive, Q.finite, Q.imaginary, Q.integer, Q.irrational, Q.negative, Q.nonnegative, Q.nonpositive, Q.nonzero, Q.odd, Q.positive, Q.positive_infinite, Q.prime, Q.rational, Q.real, Q.transcendental, Q.zero])), Q.noninteger: (set([Q.noninteger]), set([])), Q.nonnegative: (set([Q.commutative, Q.complex, Q.extended_nonnegative, Q.extended_real, Q.finite, Q.hermitian, Q.nonnegative, Q.real]), set([Q.extended_negative, Q.imaginary, Q.infinite, Q.negative, Q.negative_infinite, Q.positive_infinite])), Q.nonpositive: (set([Q.commutative, Q.complex, Q.extended_nonpositive, Q.extended_real, Q.finite, Q.hermitian, Q.nonpositive, Q.real]), set([Q.composite, Q.extended_positive, Q.imaginary, Q.infinite, Q.negative_infinite, Q.positive, Q.positive_infinite, Q.prime])), Q.nonzero: (set([Q.commutative, Q.complex, Q.extended_nonzero, Q.extended_real, Q.finite, Q.hermitian, Q.nonzero, Q.real]), set([Q.imaginary, Q.infinite, Q.negative_infinite, Q.positive_infinite, Q.zero])), Q.normal: (set([Q.normal, Q.square]), set([])), Q.odd: (set([Q.algebraic, Q.commutative, Q.complex, Q.extended_nonzero, Q.extended_real, Q.finite, Q.hermitian, Q.integer, Q.nonzero, Q.odd, Q.rational, Q.real]), set([Q.even, Q.imaginary, Q.infinite, Q.irrational, Q.negative_infinite, Q.positive_infinite, Q.transcendental, Q.zero])), Q.orthogonal: (set([Q.fullrank, Q.invertible, Q.normal, Q.orthogonal, Q.positive_definite, Q.square, Q.unitary]), set([Q.singular])), Q.positive: (set([Q.commutative, Q.complex, Q.extended_nonnegative, Q.extended_nonzero, Q.extended_positive, Q.extended_real, Q.finite, Q.hermitian, Q.nonnegative, Q.nonzero, Q.positive, Q.real]), set([Q.extended_negative, Q.extended_nonpositive, Q.imaginary, Q.infinite, Q.negative, Q.negative_infinite, Q.nonpositive, Q.positive_infinite, Q.zero])), Q.positive_definite: (set([Q.fullrank, Q.invertible, Q.positive_definite, Q.square]), set([Q.singular])), Q.positive_infinite: (set([Q.commutative, Q.extended_nonnegative, Q.extended_nonzero, Q.extended_positive, Q.extended_real, Q.infinite, Q.positive_infinite]), set([Q.algebraic, Q.complex, Q.composite, Q.even, Q.extended_negative, Q.extended_nonpositive, Q.finite, Q.imaginary, Q.integer, Q.irrational, Q.negative, Q.negative_infinite, Q.nonnegative, Q.nonpositive, Q.nonzero, Q.odd, Q.positive, Q.prime, Q.rational, Q.real, Q.transcendental, Q.zero])), Q.prime: (set([Q.algebraic, Q.commutative, Q.complex, Q.extended_nonnegative, Q.extended_nonzero, Q.extended_positive, Q.extended_real, Q.finite, Q.hermitian, Q.integer, Q.nonnegative, Q.nonzero, Q.positive, Q.prime, Q.rational, Q.real]), set([Q.composite, Q.extended_negative, Q.extended_nonpositive, Q.imaginary, Q.infinite, Q.irrational, Q.negative, Q.negative_infinite, Q.nonpositive, Q.positive_infinite, Q.transcendental, Q.zero])), Q.rational: (set([Q.algebraic, Q.commutative, Q.complex, Q.extended_real, Q.finite, Q.hermitian, Q.rational, Q.real]), set([Q.imaginary, Q.infinite, Q.irrational, Q.negative_infinite, Q.positive_infinite, Q.transcendental])), Q.real: (set([Q.commutative, Q.complex, Q.extended_real, Q.finite, Q.hermitian, Q.real]), set([Q.imaginary, Q.infinite, Q.negative_infinite, Q.positive_infinite])), Q.real_elements: (set([Q.complex_elements, Q.real_elements]), set([])), Q.singular: (set([Q.singular]), set([Q.invertible, Q.orthogonal, Q.positive_definite, Q.unitary])), Q.square: (set([Q.square]), set([])), Q.symmetric: (set([Q.square, Q.symmetric]), set([])), Q.transcendental: (set([Q.commutative, Q.complex, Q.finite, Q.transcendental]), set([Q.algebraic, Q.composite, Q.even, Q.infinite, Q.integer, Q.negative_infinite, Q.odd, Q.positive_infinite, Q.prime, Q.rational, Q.zero])), Q.triangular: (set([Q.triangular]), set([])), Q.unit_triangular: (set([Q.triangular, Q.unit_triangular]), set([])), Q.unitary: (set([Q.fullrank, Q.invertible, Q.normal, Q.square, Q.unitary]), set([Q.singular])), Q.upper_triangular: (set([Q.triangular, Q.upper_triangular]), set([])), Q.zero: (set([Q.algebraic, Q.commutative, Q.complex, Q.even, Q.extended_nonnegative, Q.extended_nonpositive, Q.extended_real, Q.finite, Q.hermitian, Q.integer, Q.nonnegative, Q.nonpositive, Q.rational, Q.real, Q.zero]), set([Q.composite, Q.extended_negative, Q.extended_nonzero, Q.extended_positive, Q.imaginary, Q.infinite, Q.irrational, Q.negative, Q.negative_infinite, Q.nonzero, Q.odd, Q.positive, Q.positive_infinite, Q.prime, Q.transcendental])), }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485"""A module which implements predicates and assumption context."""
from contextlib import contextmanagerimport inspectfrom sympy.core.symbol import Strfrom sympy.core.sympify import _sympifyfrom sympy.logic.boolalg import Boolean, false, truefrom sympy.multipledispatch.dispatcher import Dispatcher, str_signaturefrom sympy.utilities.exceptions import sympy_deprecation_warningfrom sympy.utilities.iterables import is_sequencefrom sympy.utilities.source import get_class
class AssumptionsContext(set): """ Set containing default assumptions which are applied to the ``ask()`` function.
Explanation ===========
This is used to represent global assumptions, but you can also use this class to create your own local assumptions contexts. It is basically a thin wrapper to Python's set, so see its documentation for advanced usage.
Examples ========
The default assumption context is ``global_assumptions``, which is initially empty:
>>> from sympy import ask, Q >>> from sympy.assumptions import global_assumptions >>> global_assumptions AssumptionsContext()
You can add default assumptions:
>>> from sympy.abc import x >>> global_assumptions.add(Q.real(x)) >>> global_assumptions AssumptionsContext({Q.real(x)}) >>> ask(Q.real(x)) True
And remove them:
>>> global_assumptions.remove(Q.real(x)) >>> print(ask(Q.real(x))) None
The ``clear()`` method removes every assumption:
>>> global_assumptions.add(Q.positive(x)) >>> global_assumptions AssumptionsContext({Q.positive(x)}) >>> global_assumptions.clear() >>> global_assumptions AssumptionsContext()
See Also ========
assuming
"""
def add(self, *assumptions): """Add assumptions.""" for a in assumptions: super().add(a)
def _sympystr(self, printer): if not self: return "%s()" % self.__class__.__name__ return "{}({})".format(self.__class__.__name__, printer._print_set(self))
global_assumptions = AssumptionsContext()
class AppliedPredicate(Boolean): """ The class of expressions resulting from applying ``Predicate`` to the arguments. ``AppliedPredicate`` merely wraps its argument and remain unevaluated. To evaluate it, use the ``ask()`` function.
Examples ========
>>> from sympy import Q, ask >>> Q.integer(1) Q.integer(1)
The ``function`` attribute returns the predicate, and the ``arguments`` attribute returns the tuple of arguments.
>>> type(Q.integer(1)) <class 'sympy.assumptions.assume.AppliedPredicate'> >>> Q.integer(1).function Q.integer >>> Q.integer(1).arguments (1,)
Applied predicates can be evaluated to a boolean value with ``ask``:
>>> ask(Q.integer(1)) True
""" __slots__ = ()
def __new__(cls, predicate, *args): if not isinstance(predicate, Predicate): raise TypeError("%s is not a Predicate." % predicate) args = map(_sympify, args) return super().__new__(cls, predicate, *args)
@property def arg(self): """ Return the expression used by this assumption.
Examples ========
>>> from sympy import Q, Symbol >>> x = Symbol('x') >>> a = Q.integer(x + 1) >>> a.arg x + 1
""" # Will be deprecated args = self._args if len(args) == 2: # backwards compatibility return args[1] raise TypeError("'arg' property is allowed only for unary predicates.")
@property def function(self): """ Return the predicate. """ # Will be changed to self.args[0] after args overriding is removed return self._args[0]
@property def arguments(self): """ Return the arguments which are applied to the predicate. """ # Will be changed to self.args[1:] after args overriding is removed return self._args[1:]
def _eval_ask(self, assumptions): return self.function.eval(self.arguments, assumptions)
@property def binary_symbols(self): from .ask import Q if self.function == Q.is_true: i = self.arguments[0] if i.is_Boolean or i.is_Symbol: return i.binary_symbols if self.function in (Q.eq, Q.ne): if true in self.arguments or false in self.arguments: if self.arguments[0].is_Symbol: return {self.arguments[0]} elif self.arguments[1].is_Symbol: return {self.arguments[1]} return set()
class PredicateMeta(type): def __new__(cls, clsname, bases, dct): # If handler is not defined, assign empty dispatcher. if "handler" not in dct: name = f"Ask{clsname.capitalize()}Handler" handler = Dispatcher(name, doc="Handler for key %s" % name) dct["handler"] = handler
dct["_orig_doc"] = dct.get("__doc__", "")
return super().__new__(cls, clsname, bases, dct)
@property def __doc__(cls): handler = cls.handler doc = cls._orig_doc if cls is not Predicate and handler is not None: doc += "Handler\n" doc += " =======\n\n"
# Append the handler's doc without breaking sphinx documentation. docs = [" Multiply dispatched method: %s" % handler.name] if handler.doc: for line in handler.doc.splitlines(): if not line: continue docs.append(" %s" % line) other = [] for sig in handler.ordering[::-1]: func = handler.funcs[sig] if func.__doc__: s = ' Inputs: <%s>' % str_signature(sig) lines = [] for line in func.__doc__.splitlines(): lines.append(" %s" % line) s += "\n".join(lines) docs.append(s) else: other.append(str_signature(sig)) if other: othersig = " Other signatures:" for line in other: othersig += "\n * %s" % line docs.append(othersig)
doc += '\n\n'.join(docs)
return doc
class Predicate(Boolean, metaclass=PredicateMeta): """ Base class for mathematical predicates. It also serves as a constructor for undefined predicate objects.
Explanation ===========
Predicate is a function that returns a boolean value [1].
Predicate function is object, and it is instance of predicate class. When a predicate is applied to arguments, ``AppliedPredicate`` instance is returned. This merely wraps the argument and remain unevaluated. To obtain the truth value of applied predicate, use the function ``ask``.
Evaluation of predicate is done by multiple dispatching. You can register new handler to the predicate to support new types.
Every predicate in SymPy can be accessed via the property of ``Q``. For example, ``Q.even`` returns the predicate which checks if the argument is even number.
To define a predicate which can be evaluated, you must subclass this class, make an instance of it, and register it to ``Q``. After then, dispatch the handler by argument types.
If you directly construct predicate using this class, you will get ``UndefinedPredicate`` which cannot be dispatched. This is useful when you are building boolean expressions which do not need to be evaluated.
Examples ========
Applying and evaluating to boolean value:
>>> from sympy import Q, ask >>> ask(Q.prime(7)) True
You can define a new predicate by subclassing and dispatching. Here, we define a predicate for sexy primes [2] as an example.
>>> from sympy import Predicate, Integer >>> class SexyPrimePredicate(Predicate): ... name = "sexyprime" >>> Q.sexyprime = SexyPrimePredicate() >>> @Q.sexyprime.register(Integer, Integer) ... def _(int1, int2, assumptions): ... args = sorted([int1, int2]) ... if not all(ask(Q.prime(a), assumptions) for a in args): ... return False ... return args[1] - args[0] == 6 >>> ask(Q.sexyprime(5, 11)) True
Direct constructing returns ``UndefinedPredicate``, which can be applied but cannot be dispatched.
>>> from sympy import Predicate, Integer >>> Q.P = Predicate("P") >>> type(Q.P) <class 'sympy.assumptions.assume.UndefinedPredicate'> >>> Q.P(1) Q.P(1) >>> Q.P.register(Integer)(lambda expr, assump: True) Traceback (most recent call last): ... TypeError: <class 'sympy.assumptions.assume.UndefinedPredicate'> cannot be dispatched.
References ==========
.. [1] https://en.wikipedia.org/wiki/Predicate_%28mathematical_logic%29 .. [2] https://en.wikipedia.org/wiki/Sexy_prime
"""
is_Atom = True
def __new__(cls, *args, **kwargs): if cls is Predicate: return UndefinedPredicate(*args, **kwargs) obj = super().__new__(cls, *args) return obj
@property def name(self): # May be overridden return type(self).__name__
@classmethod def register(cls, *types, **kwargs): """ Register the signature to the handler. """ if cls.handler is None: raise TypeError("%s cannot be dispatched." % type(cls)) return cls.handler.register(*types, **kwargs)
@classmethod def register_many(cls, *types, **kwargs): """ Register multiple signatures to same handler. """ def _(func): for t in types: if not is_sequence(t): t = (t,) # for convenience, allow passing `type` to mean `(type,)` cls.register(*t, **kwargs)(func) return _
def __call__(self, *args): return AppliedPredicate(self, *args)
def eval(self, args, assumptions=True): """ Evaluate ``self(*args)`` under the given assumptions.
This uses only direct resolution methods, not logical inference. """ result = None try: result = self.handler(*args, assumptions=assumptions) except NotImplementedError: pass return result
def _eval_refine(self, assumptions): # When Predicate is no longer Boolean, delete this method return self
class UndefinedPredicate(Predicate): """ Predicate without handler.
Explanation ===========
This predicate is generated by using ``Predicate`` directly for construction. It does not have a handler, and evaluating this with arguments is done by SAT solver.
Examples ========
>>> from sympy import Predicate, Q >>> Q.P = Predicate('P') >>> Q.P.func <class 'sympy.assumptions.assume.UndefinedPredicate'> >>> Q.P.name Str('P')
"""
handler = None
def __new__(cls, name, handlers=None): # "handlers" parameter supports old design if not isinstance(name, Str): name = Str(name) obj = super(Boolean, cls).__new__(cls, name) obj.handlers = handlers or [] return obj
@property def name(self): return self.args[0]
def _hashable_content(self): return (self.name,)
def __getnewargs__(self): return (self.name,)
def __call__(self, expr): return AppliedPredicate(self, expr)
def add_handler(self, handler): sympy_deprecation_warning( """ The AskHandler system is deprecated. Predicate.add_handler() should be replaced with the multipledispatch handler of Predicate. """, deprecated_since_version="1.8", active_deprecations_target='deprecated-askhandler', ) self.handlers.append(handler)
def remove_handler(self, handler): sympy_deprecation_warning( """ The AskHandler system is deprecated. Predicate.remove_handler() should be replaced with the multipledispatch handler of Predicate. """, deprecated_since_version="1.8", active_deprecations_target='deprecated-askhandler', ) self.handlers.remove(handler)
def eval(self, args, assumptions=True): # Support for deprecated design # When old design is removed, this will always return None sympy_deprecation_warning( """ The AskHandler system is deprecated. Evaluating UndefinedPredicate objects should be replaced with the multipledispatch handler of Predicate. """, deprecated_since_version="1.8", active_deprecations_target='deprecated-askhandler', stacklevel=5, ) expr, = args res, _res = None, None mro = inspect.getmro(type(expr)) for handler in self.handlers: cls = get_class(handler) for subclass in mro: eval_ = getattr(cls, subclass.__name__, None) if eval_ is None: continue res = eval_(expr, assumptions) # Do not stop if value returned is None # Try to check for higher classes if res is None: continue if _res is None: _res = res else: # only check consistency if both resolutors have concluded if _res != res: raise ValueError('incompatible resolutors') break return res
@contextmanagerdef assuming(*assumptions): """ Context manager for assumptions.
Examples ========
>>> from sympy import assuming, Q, ask >>> from sympy.abc import x, y >>> print(ask(Q.integer(x + y))) None >>> with assuming(Q.integer(x), Q.integer(y)): ... print(ask(Q.integer(x + y))) True """ old_global_assumptions = global_assumptions.copy() global_assumptions.update(assumptions) try: yield finally: global_assumptions.clear() global_assumptions.update(old_global_assumptions)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445"""The classes used here are for the internal use of assumptions systemonly and should not be used anywhere else as these do not possess thesignatures common to SymPy objects. For general use of logic constructsplease refer to sympy.logic classes And, Or, Not, etc."""from itertools import combinations, product, zip_longestfrom sympy.assumptions.assume import AppliedPredicate, Predicatefrom sympy.core.relational import Eq, Ne, Gt, Lt, Ge, Lefrom sympy.core.singleton import Sfrom sympy.logic.boolalg import Or, And, Not, Xnorfrom sympy.logic.boolalg import (Equivalent, ITE, Implies, Nand, Nor, Xor)
class Literal: """ The smallest element of a CNF object.
Parameters ==========
lit : Boolean expression
is_Not : bool
Examples ========
>>> from sympy import Q >>> from sympy.assumptions.cnf import Literal >>> from sympy.abc import x >>> Literal(Q.even(x)) Literal(Q.even(x), False) >>> Literal(~Q.even(x)) Literal(Q.even(x), True) """
def __new__(cls, lit, is_Not=False): if isinstance(lit, Not): lit = lit.args[0] is_Not = True elif isinstance(lit, (AND, OR, Literal)): return ~lit if is_Not else lit obj = super().__new__(cls) obj.lit = lit obj.is_Not = is_Not return obj
@property def arg(self): return self.lit
def rcall(self, expr): if callable(self.lit): lit = self.lit(expr) else: lit = self.lit.apply(expr) return type(self)(lit, self.is_Not)
def __invert__(self): is_Not = not self.is_Not return Literal(self.lit, is_Not)
def __str__(self): return '{}({}, {})'.format(type(self).__name__, self.lit, self.is_Not)
__repr__ = __str__
def __eq__(self, other): return self.arg == other.arg and self.is_Not == other.is_Not
def __hash__(self): h = hash((type(self).__name__, self.arg, self.is_Not)) return h
class OR: """ A low-level implementation for Or """ def __init__(self, *args): self._args = args
@property def args(self): return sorted(self._args, key=str)
def rcall(self, expr): return type(self)(*[arg.rcall(expr) for arg in self._args ])
def __invert__(self): return AND(*[~arg for arg in self._args])
def __hash__(self): return hash((type(self).__name__,) + tuple(self.args))
def __eq__(self, other): return self.args == other.args
def __str__(self): s = '(' + ' | '.join([str(arg) for arg in self.args]) + ')' return s
__repr__ = __str__
class AND: """ A low-level implementation for And """ def __init__(self, *args): self._args = args
def __invert__(self): return OR(*[~arg for arg in self._args])
@property def args(self): return sorted(self._args, key=str)
def rcall(self, expr): return type(self)(*[arg.rcall(expr) for arg in self._args ])
def __hash__(self): return hash((type(self).__name__,) + tuple(self.args))
def __eq__(self, other): return self.args == other.args
def __str__(self): s = '('+' & '.join([str(arg) for arg in self.args])+')' return s
__repr__ = __str__
def to_NNF(expr, composite_map=None): """ Generates the Negation Normal Form of any boolean expression in terms of AND, OR, and Literal objects.
Examples ========
>>> from sympy import Q, Eq >>> from sympy.assumptions.cnf import to_NNF >>> from sympy.abc import x, y >>> expr = Q.even(x) & ~Q.positive(x) >>> to_NNF(expr) (Literal(Q.even(x), False) & Literal(Q.positive(x), True))
Supported boolean objects are converted to corresponding predicates.
>>> to_NNF(Eq(x, y)) Literal(Q.eq(x, y), False)
If ``composite_map`` argument is given, ``to_NNF`` decomposes the specified predicate into a combination of primitive predicates.
>>> cmap = {Q.nonpositive: Q.negative | Q.zero} >>> to_NNF(Q.nonpositive, cmap) (Literal(Q.negative, False) | Literal(Q.zero, False)) >>> to_NNF(Q.nonpositive(x), cmap) (Literal(Q.negative(x), False) | Literal(Q.zero(x), False)) """ from sympy.assumptions.ask import Q
if composite_map is None: composite_map = {}
binrelpreds = {Eq: Q.eq, Ne: Q.ne, Gt: Q.gt, Lt: Q.lt, Ge: Q.ge, Le: Q.le} if type(expr) in binrelpreds: pred = binrelpreds[type(expr)] expr = pred(*expr.args)
if isinstance(expr, Not): arg = expr.args[0] tmp = to_NNF(arg, composite_map) # Strategy: negate the NNF of expr return ~tmp
if isinstance(expr, Or): return OR(*[to_NNF(x, composite_map) for x in Or.make_args(expr)])
if isinstance(expr, And): return AND(*[to_NNF(x, composite_map) for x in And.make_args(expr)])
if isinstance(expr, Nand): tmp = AND(*[to_NNF(x, composite_map) for x in expr.args]) return ~tmp
if isinstance(expr, Nor): tmp = OR(*[to_NNF(x, composite_map) for x in expr.args]) return ~tmp
if isinstance(expr, Xor): cnfs = [] for i in range(0, len(expr.args) + 1, 2): for neg in combinations(expr.args, i): clause = [~to_NNF(s, composite_map) if s in neg else to_NNF(s, composite_map) for s in expr.args] cnfs.append(OR(*clause)) return AND(*cnfs)
if isinstance(expr, Xnor): cnfs = [] for i in range(0, len(expr.args) + 1, 2): for neg in combinations(expr.args, i): clause = [~to_NNF(s, composite_map) if s in neg else to_NNF(s, composite_map) for s in expr.args] cnfs.append(OR(*clause)) return ~AND(*cnfs)
if isinstance(expr, Implies): L, R = to_NNF(expr.args[0], composite_map), to_NNF(expr.args[1], composite_map) return OR(~L, R)
if isinstance(expr, Equivalent): cnfs = [] for a, b in zip_longest(expr.args, expr.args[1:], fillvalue=expr.args[0]): a = to_NNF(a, composite_map) b = to_NNF(b, composite_map) cnfs.append(OR(~a, b)) return AND(*cnfs)
if isinstance(expr, ITE): L = to_NNF(expr.args[0], composite_map) M = to_NNF(expr.args[1], composite_map) R = to_NNF(expr.args[2], composite_map) return AND(OR(~L, M), OR(L, R))
if isinstance(expr, AppliedPredicate): pred, args = expr.function, expr.arguments newpred = composite_map.get(pred, None) if newpred is not None: return to_NNF(newpred.rcall(*args), composite_map)
if isinstance(expr, Predicate): newpred = composite_map.get(expr, None) if newpred is not None: return to_NNF(newpred, composite_map)
return Literal(expr)
def distribute_AND_over_OR(expr): """ Distributes AND over OR in the NNF expression. Returns the result( Conjunctive Normal Form of expression) as a CNF object. """ if not isinstance(expr, (AND, OR)): tmp = set() tmp.add(frozenset((expr,))) return CNF(tmp)
if isinstance(expr, OR): return CNF.all_or(*[distribute_AND_over_OR(arg) for arg in expr._args])
if isinstance(expr, AND): return CNF.all_and(*[distribute_AND_over_OR(arg) for arg in expr._args])
class CNF: """ Class to represent CNF of a Boolean expression. Consists of set of clauses, which themselves are stored as frozenset of Literal objects.
Examples ========
>>> from sympy import Q >>> from sympy.assumptions.cnf import CNF >>> from sympy.abc import x >>> cnf = CNF.from_prop(Q.real(x) & ~Q.zero(x)) >>> cnf.clauses {frozenset({Literal(Q.zero(x), True)}), frozenset({Literal(Q.negative(x), False), Literal(Q.positive(x), False), Literal(Q.zero(x), False)})} """ def __init__(self, clauses=None): if not clauses: clauses = set() self.clauses = clauses
def add(self, prop): clauses = CNF.to_CNF(prop).clauses self.add_clauses(clauses)
def __str__(self): s = ' & '.join( ['(' + ' | '.join([str(lit) for lit in clause]) +')' for clause in self.clauses] ) return s
def extend(self, props): for p in props: self.add(p) return self
def copy(self): return CNF(set(self.clauses))
def add_clauses(self, clauses): self.clauses |= clauses
@classmethod def from_prop(cls, prop): res = cls() res.add(prop) return res
def __iand__(self, other): self.add_clauses(other.clauses) return self
def all_predicates(self): predicates = set() for c in self.clauses: predicates |= {arg.lit for arg in c} return predicates
def _or(self, cnf): clauses = set() for a, b in product(self.clauses, cnf.clauses): tmp = set(a) tmp.update(b) clauses.add(frozenset(tmp)) return CNF(clauses)
def _and(self, cnf): clauses = self.clauses.union(cnf.clauses) return CNF(clauses)
def _not(self): clss = list(self.clauses) ll = {frozenset((~x,)) for x in clss[-1]} ll = CNF(ll)
for rest in clss[:-1]: p = {frozenset((~x,)) for x in rest} ll = ll._or(CNF(p)) return ll
def rcall(self, expr): clause_list = [] for clause in self.clauses: lits = [arg.rcall(expr) for arg in clause] clause_list.append(OR(*lits)) expr = AND(*clause_list) return distribute_AND_over_OR(expr)
@classmethod def all_or(cls, *cnfs): b = cnfs[0].copy() for rest in cnfs[1:]: b = b._or(rest) return b
@classmethod def all_and(cls, *cnfs): b = cnfs[0].copy() for rest in cnfs[1:]: b = b._and(rest) return b
@classmethod def to_CNF(cls, expr): from sympy.assumptions.facts import get_composite_predicates expr = to_NNF(expr, get_composite_predicates()) expr = distribute_AND_over_OR(expr) return expr
@classmethod def CNF_to_cnf(cls, cnf): """ Converts CNF object to SymPy's boolean expression retaining the form of expression. """ def remove_literal(arg): return Not(arg.lit) if arg.is_Not else arg.lit
return And(*(Or(*(remove_literal(arg) for arg in clause)) for clause in cnf.clauses))
class EncodedCNF: """ Class for encoding the CNF expression. """ def __init__(self, data=None, encoding=None): if not data and not encoding: data = [] encoding = {} self.data = data self.encoding = encoding self._symbols = list(encoding.keys())
def from_cnf(self, cnf): self._symbols = list(cnf.all_predicates()) n = len(self._symbols) self.encoding = dict(zip(self._symbols, range(1, n + 1))) self.data = [self.encode(clause) for clause in cnf.clauses]
@property def symbols(self): return self._symbols
@property def variables(self): return range(1, len(self._symbols) + 1)
def copy(self): new_data = [set(clause) for clause in self.data] return EncodedCNF(new_data, dict(self.encoding))
def add_prop(self, prop): cnf = CNF.from_prop(prop) self.add_from_cnf(cnf)
def add_from_cnf(self, cnf): clauses = [self.encode(clause) for clause in cnf.clauses] self.data += clauses
def encode_arg(self, arg): literal = arg.lit value = self.encoding.get(literal, None) if value is None: n = len(self._symbols) self._symbols.append(literal) value = self.encoding[literal] = n + 1 if arg.is_Not: return -value else: return value
def encode(self, clause): return {self.encode_arg(arg) if not arg.lit == S.false else 0 for arg in clause}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270"""Known facts in assumptions module.
This module defines the facts between unary predicates in ``get_known_facts()``,and supports functions to generate the contents in``sympy.assumptions.ask_generated`` file."""
from sympy.assumptions.ask import Qfrom sympy.assumptions.assume import AppliedPredicatefrom sympy.core.cache import cacheitfrom sympy.core.symbol import Symbolfrom sympy.logic.boolalg import (to_cnf, And, Not, Implies, Equivalent, Exclusive,)from sympy.logic.inference import satisfiable
@cacheitdef get_composite_predicates(): # To reduce the complexity of sat solver, these predicates are # transformed into the combination of primitive predicates. return { Q.real : Q.negative | Q.zero | Q.positive, Q.integer : Q.even | Q.odd, Q.nonpositive : Q.negative | Q.zero, Q.nonzero : Q.negative | Q.positive, Q.nonnegative : Q.zero | Q.positive, Q.extended_real : Q.negative_infinite | Q.negative | Q.zero | Q.positive | Q.positive_infinite, Q.extended_positive: Q.positive | Q.positive_infinite, Q.extended_negative: Q.negative | Q.negative_infinite, Q.extended_nonzero: Q.negative_infinite | Q.negative | Q.positive | Q.positive_infinite, Q.extended_nonpositive: Q.negative_infinite | Q.negative | Q.zero, Q.extended_nonnegative: Q.zero | Q.positive | Q.positive_infinite, Q.complex : Q.algebraic | Q.transcendental }
@cacheitdef get_known_facts(x=None): """ Facts between unary predicates.
Parameters ==========
x : Symbol, optional Placeholder symbol for unary facts. Default is ``Symbol('x')``.
Returns =======
fact : Known facts in conjugated normal form.
""" if x is None: x = Symbol('x')
fact = And( get_number_facts(x), get_matrix_facts(x) ) return fact
@cacheitdef get_number_facts(x = None): """ Facts between unary number predicates.
Parameters ==========
x : Symbol, optional Placeholder symbol for unary facts. Default is ``Symbol('x')``.
Returns =======
fact : Known facts in conjugated normal form.
""" if x is None: x = Symbol('x')
fact = And( # primitive predicates for extended real exclude each other. Exclusive(Q.negative_infinite(x), Q.negative(x), Q.zero(x), Q.positive(x), Q.positive_infinite(x)),
# build complex plane Exclusive(Q.real(x), Q.imaginary(x)), Implies(Q.real(x) | Q.imaginary(x), Q.complex(x)),
# other subsets of complex Exclusive(Q.transcendental(x), Q.algebraic(x)), Equivalent(Q.real(x), Q.rational(x) | Q.irrational(x)), Exclusive(Q.irrational(x), Q.rational(x)), Implies(Q.rational(x), Q.algebraic(x)),
# integers Exclusive(Q.even(x), Q.odd(x)), Implies(Q.integer(x), Q.rational(x)), Implies(Q.zero(x), Q.even(x)), Exclusive(Q.composite(x), Q.prime(x)), Implies(Q.composite(x) | Q.prime(x), Q.integer(x) & Q.positive(x)), Implies(Q.even(x) & Q.positive(x) & ~Q.prime(x), Q.composite(x)),
# hermitian and antihermitian Implies(Q.real(x), Q.hermitian(x)), Implies(Q.imaginary(x), Q.antihermitian(x)), Implies(Q.zero(x), Q.hermitian(x) | Q.antihermitian(x)),
# define finity and infinity, and build extended real line Exclusive(Q.infinite(x), Q.finite(x)), Implies(Q.complex(x), Q.finite(x)), Implies(Q.negative_infinite(x) | Q.positive_infinite(x), Q.infinite(x)),
# commutativity Implies(Q.finite(x) | Q.infinite(x), Q.commutative(x)), ) return fact
@cacheitdef get_matrix_facts(x = None): """ Facts between unary matrix predicates.
Parameters ==========
x : Symbol, optional Placeholder symbol for unary facts. Default is ``Symbol('x')``.
Returns =======
fact : Known facts in conjugated normal form.
""" if x is None: x = Symbol('x')
fact = And( # matrices Implies(Q.orthogonal(x), Q.positive_definite(x)), Implies(Q.orthogonal(x), Q.unitary(x)), Implies(Q.unitary(x) & Q.real_elements(x), Q.orthogonal(x)), Implies(Q.unitary(x), Q.normal(x)), Implies(Q.unitary(x), Q.invertible(x)), Implies(Q.normal(x), Q.square(x)), Implies(Q.diagonal(x), Q.normal(x)), Implies(Q.positive_definite(x), Q.invertible(x)), Implies(Q.diagonal(x), Q.upper_triangular(x)), Implies(Q.diagonal(x), Q.lower_triangular(x)), Implies(Q.lower_triangular(x), Q.triangular(x)), Implies(Q.upper_triangular(x), Q.triangular(x)), Implies(Q.triangular(x), Q.upper_triangular(x) | Q.lower_triangular(x)), Implies(Q.upper_triangular(x) & Q.lower_triangular(x), Q.diagonal(x)), Implies(Q.diagonal(x), Q.symmetric(x)), Implies(Q.unit_triangular(x), Q.triangular(x)), Implies(Q.invertible(x), Q.fullrank(x)), Implies(Q.invertible(x), Q.square(x)), Implies(Q.symmetric(x), Q.square(x)), Implies(Q.fullrank(x) & Q.square(x), Q.invertible(x)), Equivalent(Q.invertible(x), ~Q.singular(x)), Implies(Q.integer_elements(x), Q.real_elements(x)), Implies(Q.real_elements(x), Q.complex_elements(x)), ) return fact
def generate_known_facts_dict(keys, fact): """ Computes and returns a dictionary which contains the relations between unary predicates.
Each key is a predicate, and item is two groups of predicates. First group contains the predicates which are implied by the key, and second group contains the predicates which are rejected by the key.
All predicates in *keys* and *fact* must be unary and have same placeholder symbol.
Parameters ==========
keys : list of AppliedPredicate instances.
fact : Fact between predicates in conjugated normal form.
Examples ========
>>> from sympy import Q, And, Implies >>> from sympy.assumptions.facts import generate_known_facts_dict >>> from sympy.abc import x >>> keys = [Q.even(x), Q.odd(x), Q.zero(x)] >>> fact = And(Implies(Q.even(x), ~Q.odd(x)), ... Implies(Q.zero(x), Q.even(x))) >>> generate_known_facts_dict(keys, fact) {Q.even: ({Q.even}, {Q.odd}), Q.odd: ({Q.odd}, {Q.even, Q.zero}), Q.zero: ({Q.even, Q.zero}, {Q.odd})} """ fact_cnf = to_cnf(fact) mapping = single_fact_lookup(keys, fact_cnf)
ret = {} for key, value in mapping.items(): implied = set() rejected = set() for expr in value: if isinstance(expr, AppliedPredicate): implied.add(expr.function) elif isinstance(expr, Not): pred = expr.args[0] rejected.add(pred.function) ret[key.function] = (implied, rejected) return ret
@cacheitdef get_known_facts_keys(): """ Return every unary predicates registered to ``Q``.
This function is used to generate the keys for ``generate_known_facts_dict``.
""" # exclude polyadic predicates exclude = {Q.eq, Q.ne, Q.gt, Q.lt, Q.ge, Q.le}
result = [] for attr in Q.__class__.__dict__: if attr.startswith('__'): continue pred = getattr(Q, attr) if pred in exclude: continue result.append(pred) return result
def single_fact_lookup(known_facts_keys, known_facts_cnf): # Return the dictionary for quick lookup of single fact mapping = {} for key in known_facts_keys: mapping[key] = {key} for other_key in known_facts_keys: if other_key != key: if ask_full_inference(other_key, key, known_facts_cnf): mapping[key].add(other_key) if ask_full_inference(~other_key, key, known_facts_cnf): mapping[key].add(~other_key) return mapping
def ask_full_inference(proposition, assumptions, known_facts_cnf): """ Method for inferring properties about objects.
""" if not satisfiable(And(known_facts_cnf, assumptions, proposition)): return False if not satisfiable(And(known_facts_cnf, assumptions, Not(proposition))): return True return None12345678910111213"""Multipledispatch handlers for ``Predicate`` are implemented here.Handlers in this module are not directly imported to other modules inorder to avoid circular import problem."""
from .common import (AskHandler, CommonHandler, test_closed_group)
__all__ = [ 'AskHandler', 'CommonHandler', 'test_closed_group']123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258"""This module contains query handlers responsible for calculus queries:infinitesimal, finite, etc."""
from sympy.assumptions import Q, askfrom sympy.core import Add, Mul, Pow, Symbolfrom sympy.core.numbers import (NegativeInfinity, GoldenRatio, Infinity, Exp1, ComplexInfinity, ImaginaryUnit, NaN, Number, Pi, E, TribonacciConstant)from sympy.functions import cos, exp, log, sign, sinfrom sympy.logic.boolalg import conjuncts
from ..predicates.calculus import (FinitePredicate, InfinitePredicate, PositiveInfinitePredicate, NegativeInfinitePredicate)
# FinitePredicate
@FinitePredicate.register(Symbol)def _(expr, assumptions): """ Handles Symbol. """ if expr.is_finite is not None: return expr.is_finite if Q.finite(expr) in conjuncts(assumptions): return True return None
@FinitePredicate.register(Add)def _(expr, assumptions): """ Return True if expr is bounded, False if not and None if unknown.
Truth Table:
+-------+-----+-----------+-----------+ | | | | | | | B | U | ? | | | | | | +-------+-----+---+---+---+---+---+---+ | | | | | | | | | | | |'+'|'-'|'x'|'+'|'-'|'x'| | | | | | | | | | +-------+-----+---+---+---+---+---+---+ | | | | | | B | B | U | ? | | | | | | +---+---+-----+---+---+---+---+---+---+ | | | | | | | | | | | |'+'| | U | ? | ? | U | ? | ? | | | | | | | | | | | | +---+-----+---+---+---+---+---+---+ | | | | | | | | | | | U |'-'| | ? | U | ? | ? | U | ? | | | | | | | | | | | | +---+-----+---+---+---+---+---+---+ | | | | | | | |'x'| | ? | ? | | | | | | | +---+---+-----+---+---+---+---+---+---+ | | | | | | ? | | | ? | | | | | | +-------+-----+-----------+---+---+---+
* 'B' = Bounded
* 'U' = Unbounded
* '?' = unknown boundedness
* '+' = positive sign
* '-' = negative sign
* 'x' = sign unknown
* All Bounded -> True
* 1 Unbounded and the rest Bounded -> False
* >1 Unbounded, all with same known sign -> False
* Any Unknown and unknown sign -> None
* Else -> None
When the signs are not the same you can have an undefined result as in oo - oo, hence 'bounded' is also undefined. """ sign = -1 # sign of unknown or infinite result = True for arg in expr.args: _bounded = ask(Q.finite(arg), assumptions) if _bounded: continue s = ask(Q.extended_positive(arg), assumptions) # if there has been more than one sign or if the sign of this arg # is None and Bounded is None or there was already # an unknown sign, return None if sign != -1 and s != sign or \ s is None and None in (_bounded, sign): return None else: sign = s # once False, do not change if result is not False: result = _bounded return result
@FinitePredicate.register(Mul)def _(expr, assumptions): """ Return True if expr is bounded, False if not and None if unknown.
Truth Table:
+---+---+---+--------+ | | | | | | | B | U | ? | | | | | | +---+---+---+---+----+ | | | | | | | | | | s | /s | | | | | | | +---+---+---+---+----+ | | | | | | B | B | U | ? | | | | | | +---+---+---+---+----+ | | | | | | | U | | U | U | ? | | | | | | | +---+---+---+---+----+ | | | | | | ? | | | ? | | | | | | +---+---+---+---+----+
* B = Bounded
* U = Unbounded
* ? = unknown boundedness
* s = signed (hence nonzero)
* /s = not signed """ result = True for arg in expr.args: _bounded = ask(Q.finite(arg), assumptions) if _bounded: continue elif _bounded is None: if result is None: return None if ask(Q.extended_nonzero(arg), assumptions) is None: return None if result is not False: result = None else: result = False return result
@FinitePredicate.register(Pow)def _(expr, assumptions): """ * Unbounded ** NonZero -> Unbounded
* Bounded ** Bounded -> Bounded
* Abs()<=1 ** Positive -> Bounded
* Abs()>=1 ** Negative -> Bounded
* Otherwise unknown """ if expr.base == E: return ask(Q.finite(expr.exp), assumptions)
base_bounded = ask(Q.finite(expr.base), assumptions) exp_bounded = ask(Q.finite(expr.exp), assumptions) if base_bounded is None and exp_bounded is None: # Common Case return None if base_bounded is False and ask(Q.extended_nonzero(expr.exp), assumptions): return False if base_bounded and exp_bounded: return True if (abs(expr.base) <= 1) == True and ask(Q.extended_positive(expr.exp), assumptions): return True if (abs(expr.base) >= 1) == True and ask(Q.extended_negative(expr.exp), assumptions): return True if (abs(expr.base) >= 1) == True and exp_bounded is False: return False return None
@FinitePredicate.register(exp)def _(expr, assumptions): return ask(Q.finite(expr.exp), assumptions)
@FinitePredicate.register(log)def _(expr, assumptions): # After complex -> finite fact is registered to new assumption system, # querying Q.infinite may be removed. if ask(Q.infinite(expr.args[0]), assumptions): return False return ask(~Q.zero(expr.args[0]), assumptions)
@FinitePredicate.register_many(cos, sin, Number, Pi, Exp1, GoldenRatio, TribonacciConstant, ImaginaryUnit, sign)def _(expr, assumptions): return True
@FinitePredicate.register_many(ComplexInfinity, Infinity, NegativeInfinity)def _(expr, assumptions): return False
@FinitePredicate.register(NaN)def _(expr, assumptions): return None
# InfinitePredicate
@InfinitePredicate.register_many(ComplexInfinity, Infinity, NegativeInfinity)def _(expr, assumptions): return True
# PositiveInfinitePredicate
@PositiveInfinitePredicate.register(Infinity)def _(expr, assumptions): return True
@PositiveInfinitePredicate.register_many(NegativeInfinity, ComplexInfinity)def _(expr, assumptions): return False
# NegativeInfinitePredicate
@NegativeInfinitePredicate.register(NegativeInfinity)def _(expr, assumptions): return True
@NegativeInfinitePredicate.register_many(Infinity, ComplexInfinity)def _(expr, assumptions): return FalseMLPY/Lib/site-packages/sympy-1.13.1.dist-info/AUTHORSAdded+1317
MLPY/Lib/site-packages/sympy-1.13.1.dist-info/INSTALLERAdded+1
MLPY/Lib/site-packages/sympy-1.13.1.dist-info/LICENSEAdded+153
MLPY/Lib/site-packages/sympy-1.13.1.dist-info/METADATAAdded+304
MLPY/Lib/site-packages/sympy-1.13.1.dist-info/RECORDAdded
MLPY/Lib/site-packages/sympy-1.13.1.dist-info/WHEELAdded+5
MLPY/Lib/site-packages/sympy-1.13.1.dist-info/entry_points.txtAdded+2
MLPY/Lib/site-packages/sympy-1.13.1.dist-info/top_level.txtAdded+2
MLPY/Lib/site-packages/sympy/__init__.pyAdded+542
MLPY/Lib/site-packages/sympy/__pycache__/__init__.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/__pycache__/abc.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/__pycache__/conftest.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/__pycache__/galgebra.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/__pycache__/release.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/__pycache__/this.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/abc.pyAdded+111
MLPY/Lib/site-packages/sympy/algebras/__init__.pyAdded+3
MLPY/Lib/site-packages/sympy/algebras/__pycache__/__init__.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/algebras/__pycache__/quaternion.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/algebras/quaternion.pyAdded+1667
MLPY/Lib/site-packages/sympy/algebras/tests/__init__.pyAdded
MLPY/Lib/site-packages/sympy/algebras/tests/__pycache__/__init__.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/algebras/tests/__pycache__/test_quaternion.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/algebras/tests/test_quaternion.pyAdded+428
MLPY/Lib/site-packages/sympy/assumptions/__init__.pyAdded+18
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/__init__.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/ask.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/ask_generated.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/assume.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/cnf.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/facts.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/lra_satask.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/refine.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/satask.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/sathandlers.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/__pycache__/wrapper.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/ask.pyAdded+651
MLPY/Lib/site-packages/sympy/assumptions/ask_generated.pyAdded+352
MLPY/Lib/site-packages/sympy/assumptions/assume.pyAdded+485
MLPY/Lib/site-packages/sympy/assumptions/cnf.pyAdded+445
MLPY/Lib/site-packages/sympy/assumptions/facts.pyAdded+270
MLPY/Lib/site-packages/sympy/assumptions/handlers/__init__.pyAdded+13
MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/__init__.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/calculus.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/common.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/matrices.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/ntheory.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/order.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/handlers/__pycache__/sets.cpython-39.pycAdded
MLPY/Lib/site-packages/sympy/assumptions/handlers/calculus.pyAdded+258