![]() Maxima is a lightweight, open source alternative to Mathematica I’ve had friends recommend it as being small and easy to use. I still can’t wrap my head around the syntax - I would like it more if it behaved more like traditional languages - but I suppose I’ll get the hang of it after a while. The UI is fairly streamlined and intuitive, so I’m happy with that. ![]() However I ran across Partition which does the job, so I went with that.ĭespite the language oddities, the functions are very well documented, so I was able to complete the task fairly quickly. Initially I wanted to convert my flat list into a nested list by pattern matching Haskell style, ie f = ,], but I wasn’t sure how to do that, or if the language supports pattern matching on lists. ![]() To create a cartesian product of a list with itself n times, the function is called Tuples, which I found pretty counterintuitive.The preferred shorthand for Map is (although you can write the longhand Map).To use a pure function (equivalent of a lambda expression), you refer to the argument as #, and the function must end with the & character.I’ve worked with multiple procedural and functional languages before, and there are certain things that Mathematica simply does differently from everybody else. What I found most jarring about Mathematica is its syntax. Mathematica is probably the most powerful out of the three, with capabilities with working with data well beyond what I’d expect from a CAS. I started with Mathematica, a proprietary system by Wolfram Research and the engine behind Wolfram Alpha. I realize that my solutions will probably be redundant and inefficient because of my inexperience, but it will balance out in the end because I’m equally inexperienced in all of the languages. I have no prior experience in programming in any of the 3 languages, and I will try to solve this problem with the most straightforward way possible with each of the languages. These are the 8 matrices that satisfy the desired property. There are 5^4=625 matrices to check, so performance is not a concern I am focusing on ease of use.įor reference, here is the answer to this problem: This problem encompasses a lot of the challenges I have with CAS software, that is, utilize mathematical functions (in this case, we only use matrix multiplication and transpose), yet at the same time express a nontrivial control flow. Finally, multiply the matrices modulo 5 and check if it equals the identity matrix, and output.Figure out how to do control flow, either by looping over a list (procedural) or with a map and filter (functional).Figure out how to convert a list into a 2×2 matrix form that the system can perform matrix operations on.We will probably do this with a cartesian product or list comprehension. Enumerate all lists of length 4 of values between 0 to 4, that is, ,…,].We can break this problem into several steps: Let the field be (so all operations are taken modulo 5). ![]() This problem came up as a part of a recent linear algebra assignment. So I came up with a trial - I had a short (but nontrivial) problem representative of the type of problem I’d be looking at, and I would try to solve it in all 3 languages, to determine which one was easiest to work with. Here’s my setup (all running on Windows 7): I began to experiment with several systems, but after a few days I still couldn’t decide which one was the winner. To start off, there are many different competing computer algebra systems, all incompatible with each other, and it’s far from clear which one is best for my needs. I have no experience with symbolic computing, so it wasn’t clear to me where to begin. So I looked to learn a CAS (computer algebra system), so in the future I won’t have to hack together buggy code for common math operations. But I found this solution to be unsatisfactory: my Haskell programs worked with integers and floating numbers and I couldn’t easily generalize it to work with symbolic expressions. Usually I implemented an ad-hoc solution using Haskell, either using a simple library or rolling my own implementation if the library didn’t have it. I’ve never been very good at doing manual computations, and whenever I need to do a tedious computation for an assignment, I like to automate it by writing a computer program.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |