# Finding roots of a non linear expression when multiplied with a linear expression

Here is a simple polynomial equation:

b^2 + 2b + 1 = 0


I could easily solve this as:

import numpy as np
from scipy.optimize import fsolve

eq = lambda b : np.power(b,2) + 2*b + 1
fsolve(eq, np.linspace(0,1,2))


Similarly I could solve any equation, that has finite number of terms. But how do I solve an equation with infinite number of terms which is given as : The above equation could be written as :

(1 - l) * (5.5 + 4.0*l + 4*l^2 + 6*l^3 + 5*l^4 + 5*l^5 + 5*l^6 + 5*l^7 + 5*l^8 + 5*l^9 + 5*l^10   ) = 5


when n goes from 1 to 10. But I want to solve this for sufficiently large value of n such that LHS ~= RHS.

I know the values of LHS and G1 -> Ginf but cannot understand how could I compute the value of lambda here.

I tried looking at numpy polynomial functions but could not find a function that is relevant here.

• Please explain what G_t and G_t:t+n are. – Paul May 26 '19 at 14:31
• @Paul G_t is a constant. In the example equation given above it equals the RHS which is 5. G_t:t+n are also pre-computed constants which in LHS are given as 5.5, 4,4,6,5,,5. Hope that clarifies. – Amanda May 26 '19 at 15:40
• This seems off-topic to me, unless there's a connection to a DS problem you have in mind? Ultimately you're asking how to find zeros of a function given its power series representation, which is probably best for the Math SE (although you're perhaps more interested in computational approaches, and I'm not sure then whether there's a better place). [If, as in your example, the coefficients are eventually periodic, then it's relatively easy to use geometric series to express the equation more compactly.] – Ben Reiniger May 26 '19 at 21:10
• Do you have a formula for G_t:t+n as a function of n and/or λ? – Edmund May 26 '19 at 23:05

## 2 Answers

I don't think this equation can be solved in general. Since it is an infinitely long polynomial, it cannot be evaluated. It can only be done if the constants G_t:t+n followed a very specific pattern, so that the series becomes equivalent to a known function that we can evaluate. For example:

• If $$G_{t:t+n}$$ were equal to [ 1, 1/2!, 1/3!, 1/4!, ...] (where 4! is the factorial of 4), then the sum would be equal to $$e^\lambda$$
• If $$G_{t:t+n}$$ were equal to [1, 0, -1/3!, 0, 1/5!, ...] then the sum would be equal to $$\sin(\lambda)$$

But in general, if G were any random set of constants, the function cannot be evaluated.

You may apply Wolfram Language to your project. There is a free Wolfram Engine for developers and with the Wolfram Client Library for Python you can use these functions.

If you have $$G_{t:t+n}$$ as a function of n and/or λ then the roots can be found if they exist. No amount of memory can store an infinite number of pre-calculated constants so some formula for $$G_{t:t+n}$$ must be provided.

Let

g[n_, λ_] := λ/n


An infinite Sum can be evaluated symbolically in the limit. By Assuming some conditions on λ to insure convergence. Then

Assuming[
0 < λ < 1,
(1 - λ) Sum[λ^(n - 1) g[n, λ], {n, 1, Infinity}]
]

-(1 - λ) Log[1 - λ]


If using Wolfram's notebook interface then there is the option of entering this problem in mathematical notation. Taking a g from @Paul without assumptions.

g[n_,λ_] := 1/n!
res = Sum[λ^(n - 1) g[n, λ], {n, 1, Infinity}]

((-1+E^λ) (1-λ))/λ


Then use Solve (or NSolve) on res for the family of solutions. Reduce is used to make finding inverse solutions easier.

Solve[Reduce[res == 5], λ] The family of solutions is return as a ConditionalExpression with $$c_{1}$$ in the set of integers.

Hope this helps.