# How to solve for all coefficients in a sum

The statement of the problem:

In the following formula,

$$g(u,v) - \sum_{\Delta,l} c_{\Delta,l} u^{\frac{1}{2}} G^{(l)}\Bigg(\frac{1}{2} (\Delta-l),\frac{1}{2} (\Delta-l),\Delta,u,v \Bigg) = 0$$

what we want to calculate are the values of the constant $c_{\Delta,l}$ when we Taylor expand $g(u,v)$ and we know everything else.

It convenient to change basis from $\Delta,l$ to $m,t$ using the relations $l=2m$ and $\Delta-l=2(t+1)$. The reason for doing so is that $m$ goes from zero to infinity taking all integer values, and $t$ starts from one to infinity taking all integer values.

The code: These are just definitions

    aa = 1/2 (\[CapitalDelta] - l);

l = 2 m;

\[CapitalDelta] = 2 (t + m + 1);

u = x z;

v = (1 - x) (1 - z);

g[u_, v_] := u + u/v


This is the definition of $u^{\frac{1}{2}} G^{(l)}$

ConfBlock[aa_, aa_, \[CapitalDelta]_, x_, z_] := (x z)^(
1/2 (\[CapitalDelta] - l))/(
z - x) ((-(1/2) z)^
l z Hypergeometric2F1[1/2 (\[CapitalDelta] + l),
1/2 (\[CapitalDelta] + l), \[CapitalDelta] + l,
z] Hypergeometric2F1[1/2 (\[CapitalDelta] - l - 2),
1/2 (\[CapitalDelta] - l - 2), (\[CapitalDelta] - l - 2),
x] - (-(1/2) x)^
l x Hypergeometric2F1[1/2 (\[CapitalDelta] + l),
1/2 (\[CapitalDelta] + l), \[CapitalDelta] + l,
x] Hypergeometric2F1[1/2 (\[CapitalDelta] - l - 2),
1/2 (\[CapitalDelta] - l - 2), (\[CapitalDelta] - l - 2), z] )


And this is how I define the original formula that I wrote to get the coefficients.

coefficient =
CoefficientList[
Series[g[u, v], {x, 0, 5}, {z, 0, 5}] -
Sum[c[m, t] (ConfBlock[aa, aa, \[CapitalDelta], x, z]) //
Simplify, {m, 0, 4}, {t, 1, 4}], {x, z}]


This is the result of the above

I only used a limited set of values, and hence I can go by "hand" and calculate the constants; i.e

Solve[1 - c[0, 1] == 0, c[0, 1]]

{{c[0, 1] -> 1}}

Solve[(1 - 9/10 c[0, 1] - 1/4 c[1, 1] == 0) /. c[0, 1] -> 1, c[1, 1]]

{{c[1, 1] -> 2/5}}


and so on and so forth.

What I would like:

I would like to give a command to Mathematica, to solve for all the coefficients, so that I take the results, I create a list of them and try to see if there is a sequence giving these numbers.

My failed attemps at a solution:

1. Using Solve

In[15]:= Solve[coefficient == 0, c[m, t]]

Out[15]= {}

2. Using SolveAlways

In[16]:= SolveAlways[coefficient == 0, c[m, t]]

Out[16]= {}

Thank you in advance.

P.S: This is what I found most useful from the comments.

• The second row of coefficient is {0, 2, 1, 1, 1, 1}, which has nonzero entries. The {} you get, (and which you would get if you replaced 0 in coefficient == 0 with a zero matrix of the appropriate dimensions), indicates there are no values of the c[i, j] that make all the entries 0. – Michael E2 Jan 27 '18 at 13:17
• Note also that c[m, t] in your Solve[...] command is treated as a literal expression and not a pattern to be matched. It should be, I think, Variables[coefficient]. – Michael E2 Jan 27 '18 at 13:20
• Thank you very much for your reply and the clarification. Really helpful. Cheers! – Konstantinos Jan 27 '18 at 13:22
• I got the advice in Solve that not all the variables c[m,y]has solution. Do you expect this? It seems possible for the example you have provided... – José Antonio Díaz Navas Jan 27 '18 at 13:58
• Yes, not all of them has solutions. The ones that do not have though, are kind of excluded from symmetry arguments, and this is why I need to get more terms which ones I need and make sense. In other theories with higher symmetries there is the possibility to find solutions for all c[m,t] Cheers! – Konstantinos Jan 27 '18 at 14:02

## 2 Answers

The return value of {} from Solve indicates there is no solution:

Solve[coefficient == 0, Variables[coefficient]]
(*  {}  *)


If we compare the two sides elementwise, we see that they are decidably not equal:

coefficient == ConstantArray[0, Dimensions@coefficient]
(*  False  *)


This is because some entries of coefficient, like the second row below, are nonzero constants:

coefficient[[2]]
(*  {0, 2, 1, 1, 1, 1}  *)


Assuming that the objective is to make all entries zero, then that is the end of it: It cannot be done.

On the other hand, if the goal is to make the nonconstant entries vanish, we can try the following. First the number of such entries, each of which leads to an equation, is 16, but the number of unknowns is only 10:

nonconstant = DeleteCases[Flatten@coefficient, _Integer];
nonconstant // Length
(*  16  *)

Variables[coefficient] // Length
(*  10  *)


However, the rank of the system of nonconstant coefficients is only 6; so if the system is not inconsistent, it is underdetermined:

ca = CoefficientArrays[nonconstant, Variables[coefficient]];
MatrixRank[ca[[2]]]
(*  6  *)


One way to solve a linear system is LinearSolve. It will return a particular solution. We can use NullSpace to give a general solution in terms of parameters t[j]:

particular = LinearSolve[ca[[2]], -ca[[1]]]
basis = NullSpace[ca[[2]]]
param = Array[t, Length@basis];
sol = Thread[Variables[coefficient] -> particular + param.basis]
(*
{1, -(1/6), 1/60, -(1/1575), 2/5, -(8/315), 0, 0, 0, 0}  (* particular solution *)

{{0, 0, 0, -(1/64), 0, 0, 0, 0, 0, 1},                   (* null space basis *)
{0, 0, 0, -(1/16), 0, 0, 0, 0, 1, 0},
{0, 0, 0, 1/4290, 0, -(1/4), 0, 1, 0, 0},
{0, 0, 0, -(1/4), 0, 0, 1, 0, 0, 0}}

{c[0, 1] -> 1,                                           (* parametrized solution *)
c[0, 2] -> -(1/6),
c[0, 3] -> 1/60,
c[0, 4] -> -(1/1575) - t[1]/64 - t[2]/16 + t[3]/4290 - t[4]/4,
c[1, 1] -> 2/5,
c[1, 2] -> -(8/315) - t[3]/4,
c[1, 3] -> t[4],
c[2, 1] -> t[3],
c[2, 2] -> t[2],
c[3, 1] -> t[1]}
*)


Check that the solution sol satisfies the system:

Thread[nonconstant == 0] /. sol // Simplify
(*
{True, True, True, True, True, True, True, True, True, True, True,
True, True, True, True, True}
*)


Solve will also give a solution, but it is parametrized by some of the variables. I do not think you can know ahead of time which variables it will pick, so I find the LinearSolve/NullSpace solution above is often more convenient.

Solve[Thread[nonconstant == 0], Variables[coefficient]]


Solve::svars: Equations may not give solutions for all "solve" variables.

(*
{{c[0, 1] -> 1,
c[0, 2] -> -(1/6),
c[0, 3] -> 1/60,
c[1, 1] -> 2/5,
c[2, 1] -> -(32/315) - 4 c[1, 2],
c[3, 1] -> -(5696/135135) - 64 c[0, 4] - (128 c[1, 2])/2145 - 16 c[1, 3] - 4 c[2, 2]}}
*)


Maybe this helps:

eqs = DeleteDuplicates@Cases[Flatten@coefficient, Except[_Integer]];
vars = Variables[coefficient];
Solve[eqs == 0, vars]

(* Solve: Equations may not give solutions for all 'solve' variables *)

{{
c[0, 1] -> 1, c[0, 2] -> -(1/6), c[0, 3] -> 1/60, c[1, 1] -> 2/5,
c[2, 1] -> -(32/315) - 4 c[1, 2],
c[3, 1] -> -(5696/135135) - 64 c[0, 4] - (128 c[1, 2])/2145 - 16 c[1, 3] - 4 c[2, 2]
}}

• Thank you for that. It also works if you do what @MichaelE2 suggested Solve[Variables[coefficient] == 0, Variables[coefficient]] – Konstantinos Jan 27 '18 at 14:07
• Sorry for upvote your comment. The code you provided does not work. All the coefficients will be zero. Maybe you forgot something – José Antonio Díaz Navas Jan 27 '18 at 14:11
• I cannot post an image, but the command as given above below the code works. – Konstantinos Jan 27 '18 at 14:14
• I included the picture in the original post. Cheers!!! – Konstantinos Jan 27 '18 at 14:16
• Yes, it works to give zero value (??) as the solution for all the coefficients, unless this is what you want. – José Antonio Díaz Navas Jan 27 '18 at 14:38