Syntax Differences
Mathematica, Maple, Matlab, IDL syntax differences
Specific syntax differences between the four packages:| expression |
Mathematica | Maple | Matlab | IDL |
|---|---|---|---|---|
| assign value | c = 2 Pi r
delayed evaluation: |
c := 2 * Pi * r; | c = 2 * pi * 10 (doesn't handle symbolic values) |
c = 2 * !pi * 10 (doesn't handle symbolic values) |
| equality | If[i==j, ...] | if (i=j) then ... | if i==j ... | if (i eq j) then ... |
| parameters | in square brackets, e.g., Sqrt[ArcTan[2.3,0.19]] |
in parentheses, e.g., sqrt(arctan(2.3,0.19)); |
in parentheses, e.g., sqrt(atan2(2.3,0.19)); |
procedures: just comma-separated sURFace, z, X, y functions: in parentheses |
| capitalization | built-in functions are all Capitalized. (user-defined functions can be named lowercase) | function names usually lowercase | function names lowercase | case-insensitive |
| compound statements | a=1 ; b=2 ; c=3
all statements executed, but output is suppressed for those followed by semicolon (;) |
a=1: b=2; c=3:
all statements executed, but output is suppressed for those followed by colon (:) rather than semicolon (;) |
same as Mathematica. Semicolons end/separate statements and suppress output, e.g.,
a=1 ; b=2 ; c=3 |
a=1 & b=2 & c=3
separate commands with ``&'' |
| multiline statements | continues to next line if the end of one line leaves any brackets or parentheses unmatched, or arithmetic operators dangling | ignores newlines; looks for statements to end terminate with either `:' or `;' | xxx | append ``$'' to incomplete lines |
| multiplication | either juxtaposition (separate variables by space), or `*'
c = 2 Pi r |
requires `*'
c := 2 * Pi * r; |
requires `*' | requires `*' |
| defining matrix A= 1 2 3 4 5 6 Which element is ``6''? |
A=,}
A[[2,3]] |
A:=Matrix([[1,2,3],[4,5,6]]); A[2,3]; |
A = [1 2 3 ; 4 5 6] A(2,3) |
A=[[1,2,3],[4,5,6]]
A[2,1] |
| matrix multiplication vTAw |
v.A.w | Transpose(v).A.w | v*A*transpose(w) | transpose(v##A)#w |
| elementwise multiplication of matrices, e.g.,
A = 1 2 3 4 B = 9 8 7 6
|
A * B
9 16 21 24 |
? | A .* B
9 16 21 24 |
A * B
9 16 21 24 |
| xxx | xxx | xxx | xxx | xxx |
| xxx | xxx | xxx | xxx | xxx |
