A Free, Open-Source Alternative to Mathematica

A Free, Open-Source Alternative to Mathematica

A free, open-source alternative to Mathematica The Mathics Team July 31, 2021 Contents I. Manual 4 1. Introduction 5 2. Language Tutorials 7 3. Examples 20 4. Django-based Web Interface 23 II. Reference of Built-in Symbols 26 1. Date and Time 27 2. Input and Output 32 3. Procedural Programming 41 4. Global System Information 46 5. SparseArray Functions 50 6. Solving Recurrence Equations 51 7. Rules and Patterns 52 8. Mathematical Functions 59 9. Functional Programming 67 10. Code Compilation 69 11. Options and Default Arguments 71 12. Attributes of Definitions 74 13. Tensors 79 14. Structural Operations 83 15. Drawing Graphics 90 16. Strings and Characters - Miscellaneous 102 17. Mathematical Optimization 106 18. Drawing Options and Option Values 107 19. Physical and Chemical data 112 2 20. List Functions - Miscellaneous 114 21. Numeric Evaluation and Precision 124 22. Arithmetic Functions 130 23. Colors 134 24. Distance and Similarity Measures 151 25. Graphics, Drawing, and Images 153 26. Input/Output, Files, and Filesystem 174 27. Integer Functions 195 28. List Functions 201 29. Statistics, Moments, and Generating Functions 215 30. Integer and Number-Theoretical Functions 217 31. Special Functions 252 32. Strings and Characters 262 33. File Formats 271 III. License 273 A. GNU General Public License 274 B. Included software and data 407 Index 410 3 Part I. Manual 4 1. Introduction Mathics—to be pronounced like “Mathematics” affiliated or supported by Wolfram. Mathics will without the “emat”—is a general-purpose com- probably never have the power to compete with puter algebra system (CAS). It is meant to be a Mathematica® in industrial applications; yet, it is free, open-source alternative to Mathematica®. It an alternative for educational purposes. It also is free both as in “free beer” and as in “free- invites community development at all levels. dom”. Mathics can be run Mathics locally, and See https://mathics-development-guide. to facilitate installation of the vast amount of readthedocs.io/en/latest/installing/ software need to run this, there is a docker im- index.html for the most recent instructions for age available. See https://hub.docker.com/r/ installing from PyPI, source, or from docker. mathicsorg/mathics. For implementation details see https:// The programming language of Mathics is meant mathics-development-guide.readthedocs. to resemble Wolfram’s famous Mathematica® as io/en/latest/. much as possible. However, Mathics is in no way Contents What does Mathics Who is behind it? ... 6 Why yet another CAS, offer? ....... 6 one based on What is missing? 6 Mathematica? .. 5 ... Why yet another CAS, one • sympy https://sympy.org for symbolic based on Mathematica? mathematics, and • optionally scipy https://www.scipy. org/ Mathematica® is great, but it a couple of disad- for Scientific calculations. vantages. Performance of Mathics is not, right now, practi- cal in large-scale projects and calculations. How- • It is not open source. ever can be used as a tool for quick explorations • Its development is tightly controled and and to educate people who might later switch to centralized. Mathematica®. The last point some may find and advantage. Even if you are willing to pay hundreds of dol- lars for the software, would will not be able to What does Mathics offer? see what’s going on “inside” the program if that is your interest. That’s what free, open-source, Some of the features of Mathics are: and community-supported software is for! • a powerful functional programming lan- Mathics aims at combining the best of both guage, worlds: the beauty of Mathematica® backed by • a system driven by pattern matching and a free, extensible Python core which includes a rules application, rich set of Python tools including: • rationals, complex numbers, and • mpmath https://mpmath.org/ for arbitrary-precision arithmetic, floating-point arithmetic with arbitrary • lots of list and structure manipulation rou- precision, tines, • numpy https://numpy.org/numpy for nu- • an interactive graphical user interface meric computation, right in the Web browser using MathML 5 (apart from a command line interface), about about half of the features and libraries of • creation of graphics (e.g. plots) and dis- Mathematica®. play in the browser using SVG for 2D Graphics has always been lagging and in the fu- graphics and three.js for 3D graphics, ture we intend to decouple Graphics better so • export of results to LATEX (using Asymptote that the rich set of graphics packages that are out for graphics), there can be more easily used. • an easy way of defining new functions in Python and which hooks into Python li- braries Who is behind it? • an integrated documentation and testing system. Mathics was created by Jan Pöschk in 2011. From 2013 to about 2017 it had been main- tained mostly by Angus Griffith and Ben Jones. What is missing? Since then, a number of others have been peo- ple involved in Mathics; the list can be found There are lots of ways in which Mathics could in the AUTHORS.txt file, https://github.com/ still be improved. mathics/Mathics/blob/master/AUTHORS.txt. Most notably, performance is still slow. Al- If you have any ideas on how to improve Mathics though there are various ways to speed up or even want to help out yourself, please contact Python, some serious work is need in Mathics, to us! speed it up. This will be addressed in the future. Apart from performance issues, Mathics has Welcome to Mathics, have fun! 6 2. Language Tutorials The following sections are introductions to the Built-in Symbols. basic principles of the language of Mathics.A However if you google for “Mathematica Tuto- few examples and functions are presented. Only rials” you will find easily dozens of other tutori- their most common usages are listed; for a full als which are applicable. Be warned though that description of a Symbols possible arguments, Mathics does not yet offer the full range and fea- options, etc., see its entry in the Reference of tures and capabilities of Mathematica®. Contents Working with Lists .. 10 Formatting Output .. 16 Basic calculations ... 8 The Structure of Graphics Introduction Symbols and Mathics Objects . 11 Examples ..... 18 Assignments ... 9 Functions and Patterns 13 3D Graphics ...... 18 Comparisons and Program-Flow Control Plotting Introduction Boolean Logic .. 9 Statements .... 13 Examples ..... 19 Strings ......... 9 Scoping ........ 14 Basic calculations >> 6 / 4 3 Mathics can be used to calculate basic stuff: 2 >> 1 + 2 3 To convert the result to a floating point number, apply the function N: To submit a command to Mathics, press Shift >> N[6 / 4] +Return in the Web interface or Return in the 1.5 console interface. The result will be printed in a new line below your query. As you can see, functions are applied using Mathics understands all basic arithmetic opera- square braces [ and ], in contrast to the com- tors and applies the usual operator precedence. mon notation of ( and ). At first hand, this Use parentheses when needed: might seem strange, but this distinction between >> 1 - 2 * (3 + 5)/ 4 function application and precedence change is −3 necessary to allow some general syntax struc- tures, as you will see later. The multiplication can be omitted: Mathics provides many common mathematical >> 1 - 2 (3 + 5)/ 4 functions and constants, e.g.: −3 >> Log[E] 1 >> 2 4 8 >> Sin[Pi] 0 Powers can be entered using ^: >> 3 ^ 4 >> Cos[0.5] 81 0.877583 Integer divisions yield rational numbers: When entering floating point numbers in your query, Mathics will perform a numerical evalua- 7 tion and present a numerical result, pretty much >> 0 ^ 0 like if you had applied N. Indeterminateexpression00encountered. Of course, Mathics has complex numbers: Indeterminate >> Sqrt[-4] 2I The result of the previous query to Mathics can be accessed by %: >> I ^ 2 >> 3 + 4 − 1 7 >> (3 + 2 I)^ 4 >> % ^ 2 − 119 + 120I 49 >> (3 + 2 I)^ (2.5 - I) 43.663 + 8.28556I Symbols and Assignments >> Tan[I + 0.5] 0.195577 + 0.842966I Symbols need not be declared in Mathics, they can just be entered and remain variable: Abs calculates absolute values: >> x >> Abs[-3] x 3 Basic simplifications are performed: >> Abs[3 + 4 I] >> x + 2 x 5 3x Mathics can operate with pretty huge numbers: Symbols can have any name that consists of >> 100! characters and digits: 93 326 215 443 944 152 681 699 ˜ >> iAm1Symbol ^ 2 ˜238 856 266 700 490 715 968 ˜ iAm1Symbol2 ˜264 381 621 468 592 963 895 ˜ ˜217 599 993 229 915 608 941 ˜ You can assign values to symbols: ˜463 976 156 518 286 253 697 920 ˜ >> a = 2 ˜827 223 758 251 185 210 916 864 ˜ 2 ˜000 000 000 000 000 000 000 000 >> a ^ 3 (! denotes the factorial function.) The precision 8 of numerical evaluation can be set: >> a = 4 >> N[Pi, 100] 4 3.141592653589793238462643˜ >> a ^ 3 ˜383279502884197169399375˜ 64 ˜105820974944592307816406˜ ˜286208998628034825342117068 Assigning a value returns that value. If you want to suppress the output of any result, add Division by zero is forbidden: a ; to the end of your query: >> 1 / 0 >> a = 4; Infiniteexpression1=0encountered. ComplexInfinity Values can be copied from one variable to an- other: Other expressions involving Infinity are eval- >> b = a; uated: a b: >> Infinity + 2 Infinity Now changing does not affect ¥ >> a = 3; In contrast to combinatorial belief, 0^0 is unde- >> b fined: 4 8 Such a dependency can be achieved by us- Strings ing “delayed assignment” with the := operator (which does not return anything, as the right Strings can be entered with " as delimiters: side is not even evaluated): >> "Hello world!" >> b := a ^ 2 Hello world! >> b As you can see, quotation marks are not printed 9 in the output by default.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    418 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us