![]() |
![]() |
|||
|
Mathematica knows how to do many types of calculations, including those required for Linear Algebra and Calculus. Not only can Mathematica do numeric calculations, the definite integral of 2x-3 between 0 and 2 for instance, it can do symbolic calculations as well, such as the indefinite integral of 2x-3. In other words, it doesn't just handle numbers, but also equations and formulae with surprising ease. This is not terribly shocking, as it must know the anti-derivative of 2x-3 to evaluate it between 0 and 2, but as most calculators used in classrooms are not capable of doing symbolic math it is sometimes surprising that calculators and computers can handle such formats. As you saw in the graphics examples, in Mathematica a list is a set of data surrounded by curly brackets. A vector then is a list {a,b,c} while a matrix is a list of lists, one per row, such as {{a,b,c},{d,e,f},{g,h,i}}. Mathematica can do all of the standard matrix and vector operations, such as finding inverses, determinates, reduced row form, dot products, and the like. It can also do more complex calculations such as finding the Eigenvalues and Eigenvectors of a matrix. Lets start with a nice numeric example. {{1, 5, 2}, {-1, 1, 0}, {-4, 3, 1}} is a 3x3 matrix. To view it as such we can ask Mathematica to show us the MatrixForm[{{1, 5, 2}, {-1, 1, 0}, {-4, 3, 1}}].
{{1, 5, 2}, {-1, 1, 0}, {-4, 3, 1}} is quite a bit to type, and as we'll be doing several operations with it it would be nice to be able to reference it in a shorter manner. We will assign the matrix to the variable matrixA, by typing matrixA={{1, 5, 2}, {-1, 1, 0}, {-4, 3, 1}}. Now we only have to type MatrixForm[matrixA] to get the same result.
Since the Mathematica naming convention uses UpperCaseWordsStrungTogether it is safe to use any variable name that begins with a lower case letter. However, something generic like a might end up being used later, and if we had defined it to mean something we could get unpredictable results. When you are done with a variable you can unassign it by using the Clear function, eg Clear[a] or Clear[matrixA]. Note also that it is possible to assign the names of Mathematica's built-in functions as variables, and in such a case it would be neccessary to restart Mathematica to regain the full functionality of the software. It is also possible to Clear built-in functions as well, so your best bet is to just steer clear of any built-in function names. To find the inverse of our matrix, we can use the function Inverse. Inverse[matrixA] will give us our result. If we wanted to see the MatrixForm of the inverse, we could combine the functions with MatrixForm[Inverse[matrixA]].
As one would expect, the dot product of matrixA and its inverse is the 3x3 identity matrix.
It is not terribly important that Mathematica be able to do matrix manipulations, all graphing calculators can do that, but that you know how to enter them for when you need to use them. Something more impressive, however, is Mathematica's symbolic capability. Lets set matrixB={{a,b,c},{d,e,f},{g,h,i}}.
Mathematica warns us that matrixB is similar in spelling to matrixA, and suggests that perhaps we misspelled it and meant matrixA. It will also do this if you used a variable name like inverse, which will not replace the built-in Inverse since Mathematica is case sensitive, but is spelled the same. We meant to call it matrixB, so we can ignore the error message. We can do the usual matrix operations with this matrix as well, including taking its Inverse and finding the Dot product of matrixA and matrixB.
Note also that if we had named matrixA a, that matrixB would look like this:
To get Mathematica to take a derivative, we use the functions D and Dt. D gives the partial derivative and Dt gives the total derivative. For our examples, D will suffice. If we wanted to find the derivative of x^3+2, we would ask Mathematica for D[x^3+2,x]. The second derivative of x^3+2 can be obtained with D[x^3+2,x,x] or D[x^3+2,{x,2}].
Mathematica also knows how to work with more complicated expressions, such as the ArcSin[x-2].
And, as you may have guessed, the symbolic x^n is not a problem for Mathematica.
To find an antiderivative, Mathematica uses Integrate. Integrate[f,x] will find the indefinite integral of f with respect to x, while Integrate[f,{x,a,b}] will find the definite integral of f with respect to x between a and b.
Notice in the indefinite integral, Mathematica does not include the +C. As with D, Integrate[f,x,x] will find the second anti-derivative of f.
As you've no doubt guessed, there is not much that Mathematica doesn't know how to handle, as as you learned earlier, if it doesn't know exactly how to respond it will give you the input back instead of risking a wrong answer in most cases. This may give you a false sense of security. Read on for more information.
|
||||
| Tutorial
Home Table of Contents About this Site |
||||
| Previous: An overview of Mathematica's graphical capabilities | Next: A few cautionary notes |
Last updated:5/1/02
|
||