How to write a recursive definition in a mathematical notation?

3.1k Views Asked by At

I have a programming background and am sorry in advance because I am poor at mathematics and mathematical notation. So please be kind to me.

I have a function

$$f(x,y)=\bigl((x+y)-n,(x-y)+n\bigr)$$

and the output values of this function $(x+y)-n$ and $(x-y)-n$ respectively are the new $x$ and $y$ values for the purpose of recursion. I have two base cases for the recursion to stop.

  1. If $(x+y)-n=0$
  2. If $(x-y)+n=0$

$n$ is a constant. You can assume it to be any number.

How do I write such a recursive function as mathematical notation?

1

There are 1 best solutions below

2
On BEST ANSWER

I suppose your function has 2 input variables and 2 output values, i.e.

$$\vec{f}(\vec{x})=(f_1(x_1,x_2), f_2(x_1,x_2))$$

where $\vec{x}=(x,y)$ is a 2d-vector of input-variables and $\vec{f}$ is a 2-dimensional output vector containing the expressions for both output values.

You can e.g. formulate it as

$$\vec{f}(\vec{x})=\vec{f}(x,y)=\begin{pmatrix}f_1(x,y)\\f_2(x,y)\end{pmatrix}=\begin{pmatrix}x+y-n\\x-y+n\end{pmatrix}.$$

So, in particular you can write it also as a matrix multiplication by

$$\vec{f}(\vec{x})=\begin{pmatrix}1 & 1 \\ 1 &-1\end{pmatrix}\vec{x} + \begin{pmatrix}-n\\n\end{pmatrix}$$

Also, your recursion can be written as

$$\vec{x}_{i+1}=\vec{f}(\vec{x}_i)$$

with some initial value $\vec{x}_0$. I.e. you define $\vec{x}_0=(x_0,y_0)$, from which you calculate $\vec{x}_1$ by plugging in $\vec{x}_0$ into $\vec{f}$.