Basics of MuPAD

Brown University Applied Mathematics


Summation, Substitution, and Systems of Equations

In most practical cases, numerical approximation to sums (particularly infinite sums) are the most useful tool. For more abstract summation techniques, please check out the MATLAB MuPAD documentation on the web.

The general format for summation will be sum(function, n = lowerbound..upperbound)

This is very similar to the other functions we have been using - hopefully you are starting to get a hang of how most of the syntax works. Sometimes MuPAD can calculate an answer from the simple "sum" function, but usually you will have to use "numeric::sum" to get an answer. Here is an example:

numeric::sum((-1)^n/n^2,n=1..infinity)

Thus, you can effectively try to start forgetting your summation rules for what converges and what doesn't and what has a sum and what doesn't. A sum that doesn’t converge will produce the following answer:
sum(1/n,n=1..infinity)

Substitution is a very powerful tool. Because you can solve many types of equations with letters and symbols in MuPad, when you reach the final answer, sometimes it is nice to substitute in numeric values to get a numerical answer. If you wait until the final step to substitute in these values, it becomes much easier to keep subbing in new values to produce different results.

Take for instance a simple quadratic equation to solve:
quadratic := a*x^2+b*x+c

quadsolved := solve(quadratic,x)
Notice all the special cases - it gives conditions for complex cases, special cases, and insolvable cases.

The general formula for the subs function: subs(function, variable = #)

Example using our solved quadratic function:
subs(%,[a=2,b=4,c=0])
Notice that subs only has 2 parameter spaces - one for the equation and one for the variable. Because the separate variables "a, b, c" are grouped together in brackets, it counts as one parameter.

To get rid of all these conditional statements, notice that we can't try to add another parameter to the subs function. This is what will happen:
subs(quadsolved,[a=2,b=4,c=0],IgnoreSpecialCases)
Error: The argument is invalid. [subs]
To fix this, we should add, "Ignore SpecialCases" as a parameter in the solve function like we have before:
quadsolved := solve(quadratic,x,IgnoreSpecialCases)

subs(%,[a=2,b=4,c=0])

To index an answer containing multiple values, you will place a bracket containing a positive integer directly next to the value you want to index. For example, using our previous solved values from the quadratic equation, we will index to different answers:
quadsolved[1]
yields the first result from the available answers from “qualsolved”

You already know how to define equations. Now we will be using the same "solve" function to solve this linear system of equations:
r1 := a+3*b-4*c - 5:
r2 := b + a - 19:
r3 := c - b + a - 12:
solve([r1=0,r2=0,r3=0],[a,b,c])

Notice that we don't set each equation equal to a value in the definition; rather we want to apply this condition at the end in a grouped parameter condition. Also notice that we suppressed the output of these statements, thus saving much more space so that we can work faster. You can work with as many equations and variables as you want - and if it doesn't have an answer, MuPAD will try, and then tell you!

Home

< Previous

Next >