How to make a list in maple

1k Views Asked by At

I need to do some computations with maple which I don't know how to do it. So I thought I can ask you.

I am going to pick a simple function, as simple as possible. let's take $f(x,y):=x^2+y^2$. I want to make a list with maple to give me a list of numbers producing with $f(x,y)$ for integral value $x=1...5$, and $y=1...5$, in other word a list consists of $f(1,1), f(1,2), f(1,3),..., f(5,5)$.

Of course my function and the range is much more complicate, so I just took this particular function just to be more precise.

Thank you.

1

There are 1 best solutions below

0
On

Here's one way:

> f := (x,y) -> x^2 + y^2;

$$ f := (x,y) \to x^2 + y^2 $$

> M := Matrix(5, 5, f);

$$ M := \begin{bmatrix} 2 & 5 & 10 & 17 & 26 \\ 5 & 8 & 13 & 20 & 29 \\ 10 & 13 & 18 & 25 & 34 \\ 17 & 20 & 25 & 32 & 41 \\ 26 & 29 & 34 & 41 & 50 \end{bmatrix}$$

> ListTools:-Flatten( convert(M, listlist) );  

$$[2, 5, 10, 17, 26, 5, 8, 13, 20, 29, 10, 13, 18, 25, 34, 17, 20, 25, 32, 41, 26, 29, 34, 41, 50]$$