1 / 26

Review of some Maxima Syntax and Semantics

Review of some Maxima Syntax and Semantics. 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 ….

sladd
Download Presentation

Review of some Maxima Syntax and Semantics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Review of some Maxima Syntax and Semantics

  2. 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 • …

  3. 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

  4. 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

  5. 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

  6. 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);

  7. Formal and actual arguments • f(x,y,z) := x + 2 *y + 3 *z^2;

  8. Formal and actual arguments • f(x,y,z) := x + 2 *y + 3 *z; Function definition

  9. Formal and actual arguments • f(x,y,z) := x + 2 *y + 3 *z; Function definition Formal arguments

  10. 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

  11. 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.

  12. Lists in Maxima

  13. Lists in Maxima Remove the %

  14. 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

  15. 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

  16. Some useful array functions

  17. 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

  18. Two ways to create matrices in Maxima • Select Enter from the Algebra menu

  19. 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.

  20. One way to create them

  21. Other ways to create arrays • array(B,20); • C: make_array( any , 20); • Array(D, 20, 10); • E: make_array( any, 20, 10);

  22. Other ways to create arrays array(B,20); C: make_array( any , 20); array(D, 20, 10); E: make_array( any, 20, 10);

  23. 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.

More Related