Maple commands, packages, assistants, and even the whole user interface is accessible from MATLAB®. Using MATLAB® as your main interface you can use one of more than 200 native MATLAB® commands to do symbolic computation linking seamlessly to Maple's math engine. Launch the Maple graphical interface from MATLAB® and interact with both programs as they share the same variables and state.
The most basic symbolic object is a symbol. To start using Maple, create a sym object, x, in MATLAB®. More complicated expressions can then be formed using your declared symbolic variable, x.
>> x = sym('x')
x =
x
>> x^3+cos(2*x)-1
ans =
3
x + cos(2 x) - 1
Symbolic expressions and equations can then, among other things, be differentiated, integrated, factored, and solved exactly using MATLAB® front-ends to Maple commands.
>> diff(x^3)
ans =
2
3 x
>> int(3*x^2)
ans =
3
x
>> factor(x^4+10*x^3+35*x^2+50*x+24)
ans =
(x + 4) (x + 3) (x + 2) (x + 1)
>> expand(ans)
ans =
4 3 2
x + 10 x + 35 x + 50 x + 24
>> syms x y z
>> solve( 3*x+1*y+4*z-5, 8*x+19*y+11*z-94, x+y/4+z-11)
ans =
x: 39
y: 72/13
z: -382/13
New in Maple 16 is the ability to easily create symbolic matrices. The sym command now accepts options for specifying the size and format of a matrix to be filled with symbolic entries.
>> A = sym('A',[3 3])
A =
[A1_1 A1_2 A1_3]
[ ]
[A2_1 A2_2 A2_3]
[ ]
[A3_1 A3_2 A3_3]
The resulting matrices can be used to compute exact symbolic answers. For example, the determinant of the above matrix as an equation can be calculated like this:
>> det(A)
ans =
A1_1 A2_2 A3_3 - A1_1 A2_3 A3_2 + A2_1 A3_2 A1_3 - A2_1 A1_2 A3_3
+ A3_1 A1_2 A2_3 - A3_1 A2_2 A1_3
The format of the matrix entries can be customized using a string template. Standard operations like matrix multiplication are known to the package and overloaded accordingly.
>> B = sym('B%d%d',[2 3])
B =
[B11 B12 B13]
[ ]
[B21 B22 B23]
>> B * A
ans =
[B11 A1_1 + B12 A2_1 + B13 A3_1 , B11 A1_2 + B12 A2_2 + B13 A3_2 ,
B11 A1_3 + B12 A2_3 + B13 A3_3]
[B21 A1_1 + B22 A2_1 + B23 A3_1 , B21 A1_2 + B22 A2_2 + B23 A3_2 ,
B21 A1_3 + B22 A2_3 + B23 A3_3]