# Solve functional equations which is not exactly recursive

I have the following type of equation :

ff[a, b] == alpha[a, b]*ff[0, b] + beta[a, b]*ff[a, 0]+C[a,b]


Alpha, beta and C are functions of a and b that I assume known.

I want that mathematica find the function ff[a,b] that solves this equation.

I could help him to do it, i.e I write by my own the others equations :

ff[0, b]=alpha[0, b]*ff[0, b] + beta[0, b]*ff[0, 0]+C[0,b]
ff[0, 0]=(alpha[0, 0]+beta[0, b])*ff[0, 0]+C[0,0]
ff[a, 0] == alpha[a, 0]*ff[0, 0] + beta[a, 0]*ff[a, 0]+C[a,0]


Then I would have 4 equations with 4 unknown and find f[a,b]

But I want to know if mathematica can do by its own what I have done here, so I would only say him : ff[a, b] == alpha[a, b]*ff[0, b] + beta[a, b]*ff[a, 0]+C[a,b] and he "automatically" finds f[a,b] without any further help from me.

If I am asking this it is because I have the exact same of problem but for functions of 6 variables and it would be long to find all the equations.

Here's a suggestion. First, write everything in a way that will be easier to generalize for a larger number of arguments:

rec=
ff[x[1], x[2]] == α[x[1], x[2]]ff[0, x[2]] +
β[x[1], x[2]]ff[x[1], 0] +
γ[x[1], x[2]]


Now, you want to have this relation with four options: either setting x[1] to zero or not, and either setting x[2] to zero or not. There are four options because you have $n=2$ variables and that's $2^n$ options in general.

A way to programatically create all these replacement rules is to take all binary vectors of zeros and one, and for each vector have a rule setting x[i] to zero if the i-th entry has one in it:

replacement[vec_] := DeleteCases[
Table[If[vec[[i]]==1, x[i] -> 0], {i, Length@vec}],
Null]


The list of all such vectors is easily obtained by

vectors=Array[Boole[IntegerDigits[#, 2, n]] &, 2^n]


Now you can simply solve for all the possible replacements:

 rules = replacement /@ vectors
ff[x[1],x[2]]/.Solve[rec /. rules, ff[x[1], x[2]] /. rules]

• Thank you for your answer. Just to understand : you think it doesn't exist an in built mathematica function that will simply replace recursively all the occurences of the function on the rhs, and build a system of equation with it ? Jun 8, 2017 at 0:23
• I'd be surprised if such a function existed as is . The problem might be recast in a way that makes it possible to use an existing one, but it's not clear why you'd want to do that. My solution is pretty straightforward and can be made much less verbose (I just broke it down to steps to make it clearer) Jun 8, 2017 at 1:16
• This seems to work only if Boole is removed. +1 Nov 5, 2017 at 3:52