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).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |