260 likes | 273 Views
Explore Maxima software, learn to craft precise arithmetic statements, functions, and arrays. Execute commands accurately and efficiently for algebraic equations. Enhance your mathematical prowess with this comprehensive guide to Maxima's syntax and semantics.
E N D
Arithmetic and algebra • Exact, unlimited precision • Standard arithmetic operators: + - * / • Use *, not juxtaposition, for multiplication • Use 2 * x, not 2 x • Use ^ for raising to a power • Many algebraic operators: • expand() • factor() • ratsimp • …
Execution of statements • Terminate with a semicolon and type <enter> in XMaxima • Terminate with a semicolon and type <shift-enter> in wxMaxima • Use a $ instead of a semicolon to suppress output
Variables and constants • Easy to name a variable and assign a value to it • Examples: x:3; abc:4! ; z3: 7 ; • Use % with standard constants • %pi, %e
Functions • Built-in functions are always in lower case: • sin, cos, exp, … • sin(%pi/2), log(%e^x) • Use sin(%pi/2) not Sin(%pi/2) • Maxima is case-sensitive
Assignments to variables, constants, and functions • x: 3; • z: x + y/2; • f(x,y,z) := x + 2 *y + 3 *z; • g(w) := w/2; • wow(a) := sin(%pi* a);
Formal and actual arguments • f(x,y,z) := x + 2 *y + 3 *z^2;
Formal and actual arguments • f(x,y,z) := x + 2 *y + 3 *z; Function definition
Formal and actual arguments • f(x,y,z) := x + 2 *y + 3 *z; Function definition Formal arguments
Formal and actual arguments • f(x,y,z) := x + 2 *y + 3 *z; • f(Fred, Ethel, 7) has the value Fred + 2 * Ethel + 3 *7 Function definition Formal arguments Actual arguments
Lists and arrays • Both data structures are needed in Maxima • There are drop-down menus in wxMaxima to help with creation of either lists or arrays.
Lists in Maxima Remove the %
Can also use the command makelist(i, i, 1, 20); to get the output [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] Also, A: makelist(i, i, 1, 20); assigns the result to the list named A
Can use lists for the polynomial algebra exercise Plus(p1, p2) := p1 + p2;(I used upper case to denote a user-defined function) Similarly, we need a function for subtracting Minus(p1,p2):= p1 – p2; • Remember, we needed to have the lists be the same length when adding or subtracting • Do this by appending [0] as much as necessary
Arrays in Maxima • Creation, other operations • Max # of dimensions is 5 (system limit) • Arrays and matrices are the same in Maxima • Unlike most programming languages, vectors are not precisely one-dimensional arrays • Vectors are akin to their use in graphics and mechanics for 2- and 3-d drawing
Two ways to create matrices in Maxima • Select Enter from the Algebra menu
Operations on arrays • They can be created, deleted, and have their entries listed • They can be added, subtracted, and multiplied by numbers and simple variables (scalars). • As with lists, two arrays must have the same size to be operated on together.
Other ways to create arrays • array(B,20); • C: make_array( any , 20); • Array(D, 20, 10); • E: make_array( any, 20, 10);
Other ways to create arrays array(B,20); C: make_array( any , 20); array(D, 20, 10); E: make_array( any, 20, 10);
Array entries • Array entries can be accessed by their indicies. • Warning: make sure each index stays within the appropriate range limit. • Often this will require programming.