-1

I need to solve a transcendental equation (my code is below where "L" is the desirable variable) in function of some parameters, but, the Sympy returns

NotImplementedError: multiple generators [L, exp(L*tau)]
No algorithms are implemented to solve equation L**2 - L*epsilon + L*sigma*exp(-L*tau) - epsilon*mu - 2*epsilon*sigma*exp(-L*tau) - mu**2 - mu*sigma*exp(-L*tau)

I searched by this message and saw that them is returned if Sympy does not find the solutions. Is this correct? Is there something that I can make to improve the code for the Sympy let be able to solve my problem?

This is my code.

# -*- coding: utf-8 -*-
"""
Created on Sun Aug 13 08:19:24 2023

@author: Luciano Aparecido
"""

# Modulos
import sympy

# Real Parameters : Positive Values
beta = sympy.Symbol('beta', positive = True, real = True)
epsilon = sympy.Symbol('epsilon', positive = True, real = True)
delta = sympy.Symbol('delta', positive = True, real = True)
sigma = sympy.Symbol('sigma', positive = True, real = True)
gamma = sympy.Symbol('gamma', positive = True, real = True)
mu = sympy.Symbol('mu', positive = True, real = True)
psi = sympy.Symbol('psi', positive = True, real = True)
N = sympy.Symbol('N', positive = True, real = True)
B = sympy.Symbol('B', positive = True, real = True)
L = sympy.Symbol('L', positive = True, real = True)
tau = sympy.Symbol('tau', positive = True, real = True)


# Variables : Are Non Negatives
S = sympy.Symbol('S', negative = False, real = True)
V = sympy.Symbol('V', negative = False, real = True)
I = sympy.Symbol('I', negative = False, real = True)
R = sympy.Symbol('R', negative = False, real = True)


# Equilibria Points
# Dictionary :: Order to Output: I, R, S, V
eq1 = B + epsilon*V + delta*R - (psi + mu + beta*I/N)*S
eq2 = psi*S - (epsilon + mu + sigma*beta*I/N)*V
eq3 = (S + sigma*V)*beta*I/N - (mu + gamma)*I
eq4 = gamma*I - (mu + delta)*R
sol1, sol2, sol3 = sympy.solve([eq1, eq2, eq3, eq4], S, V, I, R, dict=True)


# Trivial Equilibria Points (sol1)::
sol_trivial = list(sol1.values())
It, Rt, St, Vt = sol_trivial

# Linear Part
k = beta*St/N + sigma*beta*Vt/N - (mu + gamma)
A = sympy.Matrix([[mu, -epsilon, -beta*St/N, -delta], [0, -epsilon-mu, sigma*beta*Vt/N, 0], [0, 0, -k, 0], [0, 0, -gamma, mu+delta]])
B = sympy.Matrix([[sigma, 0, 0, 0], [-sigma, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Id = sympy.Matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])
Delta = (A + L*Id + B*sympy.exp(-L*tau))
det_Delta = Delta.det()

# Eigenvalues (L values in det_Delta equation)
auto1, auto2, auto3, auto4 = sympy.solve(det_Delta, L)

When I run this code, as commented above, Python returns

NotImplementedError: multiple generators [L, exp(L*tau)]
No algorithms are implemented to solve equation L**2 - L*epsilon + L*sigma*exp(-L*tau) - epsilon*mu - 2*epsilon*sigma*exp(-L*tau) - mu**2 - mu*sigma*exp(-L*tau)

How to improve this code (if this is possible) for that Sympy to solve my equation?

jared
  • 4,165
  • 1
  • 8
  • 31
  • 1
    Most transcendental equations do not have explicit symbolic solutions. The question here is if a substitution could bring the equation to a Lambert form but I don't know if such a substitution exists: they are not generally guaranteed to exist and it looks like `solve` cannot find one. – Oscar Benjamin Aug 16 '23 at 11:00

0 Answers0