Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is it possible to get an answer to the following question in Mathematica?

Let $M$ be a $n$ by $n$ matrix, is there a function $m:\mathbb{N}\times \mathbb{N}\rightarrow \mathbb{Z}$ such that $m_{ij}=m_{ji}$ and $m_{ij}=m_{i+2,j+2}$ for all $i$ and $j$.

I am new to Mathematica and interested whether such existential, abstract expressions can be solved in Mathematica.

share|improve this question
    
If the dimension n is specified one can use FindInstance to solve for the m_i,j. –  Daniel Lichtblau Feb 26 '13 at 20:41
    
Sorry maybe it was not clear. I will enter the matrix M, so yes it'll be specified. –  Nonlinear Feb 26 '13 at 20:46
    
Now I'm confused. I was assuming the m_i,j are entries of your M. Is that not the case? (In particular, is your M a numeric matrix?) If so then I'm not clear as to what is the question. –  Daniel Lichtblau Feb 26 '13 at 20:49
    
Wait... you changed your question. I thought the $m_{ij}$ were entries in your matrix. Is that not the case? What relation does $M$ have with $f$? –  rm -rf Feb 26 '13 at 20:56
2  
So now it's no longer $i+2,j+2$, but all possible $i,j,k,l$? You should formulate your problem correctly before posting instead of changing it every 5 minutes... else it is a waste of everyone's time. –  rm -rf Feb 26 '13 at 21:28
show 7 more comments

1 Answer

up vote 6 down vote accepted

The good thing about programming with Mathematica is that you can move from conceptual problems like the one described to getting a solution pretty easily. Since you're new to Mathematica, let's walk this through step by step:

1. Let $M$ be an $n\times n$ matrix

This one's easy:

ℳ[n_Integer] := Array[m, {n, n}]
ℳ[5] // MatrixForm

2. A function $m:\ \mathbb{N}\times\mathbb{N}\to \mathbb{Z}$ such that $m_{ij}=m_{ji}$

In other words, we don't care about the order $i,j$ or $j,i$ — we can achieve this simply by making m have the attribute Orderless.

SetAttributes[m, Orderless]
ℳ[5] // MatrixForm

Compare this output with the one above.

3. A function $m:\ \mathbb{N}\times\mathbb{N}\to \mathbb{Z}$ such that $m_{ij}=m_{i+2,j+2}$

Here, we can use RSolve to solve for the relation m[i,j] == m[i+2,j+2]:

RSolve[m[i, j] == m[2 + i, 2 + j], m[i, j], {i, j}]
(* {{m[i, j] -> C[1][-2 i + 2 j] + (-1)^i C[2][-2 i + 2 j]}} *)

What this solution says is that $m$ can be a function of the form

$$m: (i,j)\mapsto C_1(i,j) +(-1)^iC_2(i,j)$$

where the $C_i$ are constant functions (C denotes a constant in Mathematica).

Now putting all of these together, we can do:

Block[{m, p, q},
    SetAttributes[m, Orderless];
    m[i_, j_] := p + (-1)^i q;
    ℳ[5]
] // MatrixForm

where p and q are constants you can choose.

share|improve this answer
    
Why do you define m as p + (-1)^i q instead of p[j - i] + (-1)^i q[j - i]? –  ssch Feb 26 '13 at 21:00
    
@ssch It's a constant function –  rm -rf Feb 26 '13 at 21:00
    
ah right, never seen C[i][x] in a result before. Nice solution! –  ssch Feb 26 '13 at 21:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.