Maxima built-in object types and programming

Source: Internet
Author: User
Keywords function nbsp;
Tags apply function list programming returns set

List:

Like this to represent a list: [A, B, C].
If L is a list, then L[i] is its first element. L[1] is the first element.
Map (F, L) applies f to every element of L.
Apply ("+", L) sums all the elements of L.
For the X in L does expr, evaluate expr for each element in the L.
Length (l) is the number of elements in L.

Matrix:

Matrix like this definition: matrix (L1, ..., LN), where (L1, ..., LN) is a list of the matrices in each row of the matrix.
If M is a matrix, M [I, J] or M [I][j] is its first (I, j) matrix element. M [1, 1] is the upper-left matrix element.
operator. Represents an commutative multiplication. M.L, L.M and M.N are not easy multiplication, where L is a list, M and N are matrices.
Transpose (m) is a transpose of M.
Eigenhttp://www.aliyun.com/zixun/aggregation/9541.html ">values (m) returns the intrinsic value of M.
eigenvectors (m) returns the intrinsic vector of M.
Length (m) returns the number of rows M.
Length (Transpose (M)) returns the number of columns in M.

Collection:

Maxima understand the finite set of explicit definitions. Sets are different from lists if you want to change one to another, you need an explicit conversion.
The elements in the collection are A, B, C, ... , we specify the set: Set (A, B, C, ...)
Union (A, B) is the set of A and B.
Intersection (A, b) is the intersection of a and B.
Cardinality (a) is the number of elements in the set a.

Defining functions

1. Operator: = Define a function, reference function body.

In the following example, when the function is called, the diff is evaluated again. The argument is replaced with an X, and the last expression is evaluated. An error occurs when the variable is not a symbol: for foo (1) Maxima attempts to evaluate diff (sin (1) 2, 1).

(%I1) foo (x): = diff (Sin (x) ^2, x); 2 (%O1) foo (x): = diff (Sin (x), x) (%I2) foo (u);(%o2) 2 cos (u) sin (u) (1); Non-variable 2nd argument to Diff:1#0:foo (x=1)-an error.

2. Define defines a function and the function body is evaluated.

In this example, only the diff is evaluated once (when the function is defined). Foo (1) is now valid.

(%I1) define (foo (x), diff (Sin (x) ^2, x));(%o1) foo (x): = 2 cos (x) sin (x) (%I2) foo (u);(%o2) 2 cos (u) sin (u) (%I3) foo (1);(%o3) 2 cos (1) sin (1)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.