Integration error in SymPy 1.0 - python

I'm trying to write my mathcad model in python language, but I get some mistake.
The integration function should look like this:
In python I wrote such code
from __future__ import division
import sympy as sp
import numpy as np
import math
from pylab import *
print(sp.__version__)
s = sp.Symbol('s')
x = sp.symbols('x')
t_start = 11
t_info = 1
t_transf = 2
t_stat_analyze = 3
t_repeat = 3.2
P = 0.1
def M1(s):
return P/(t_info*t_start*t_stat_analyze*t_transf*(1 - (-P + 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/t_transf)))*(s + 1/t_info)*(s + 1/t_start)*(s + 1/t_stat_analyze)*(s + 1/t_transf)**2) + P/( t_info*t_start*t_stat_analyze*t_transf*(1 - (-P + 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/t_transf)))*(s + 1/t_info)*(s + 1/t_start)*(s + 1/t_stat_analyze)**2*(s + 1/t_transf)) + P/(t_info*t_start*t_stat_analyze*t_transf*(1 - (-P + 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/t_transf)))*(s + 1/t_info)*(s + 1/t_start)**2*(s + 1/t_stat_analyze)*(s + 1/t_transf)) + P/(t_info*t_start*t_stat_analyze*t_transf*(1 - (-P + 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/ t_transf)))*(s + 1/t_info)**2*(s + 1/t_start)*(s + 1/t_stat_analyze)*(s + 1/t_transf)) - P*(-(-P + 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/t_transf)**2) - (-P + 1)/(t_repeat*t_transf*(s + 1/t_repeat)**2*(s + 1/t_transf)))/( t_info*t_start*t_stat_analyze*t_transf*(1 - (-P + 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/t_transf)))**2*(s + 1/t_info)*(s + 1/t_start)*(s + 1/t_stat_analyze)*(s + 1/t_transf))
def M2(s):
return 2*P*((s + 1/t_transf)**(-2) + 1/((s + 1/t_stat_analyze)*(s + 1/t_transf)) + (s + 1/t_stat_analyze)**(-2) + 1/((s + 1/t_start)*(s + 1/t_transf)) + 1/((s + 1/t_start)*(s + 1/t_stat_analyze)) + (s + 1/t_start)**(-2) + 1/((s + 1/ t_info)*(s + 1/t_transf)) + 1/((s + 1/t_info)*(s + 1/t_stat_analyze)) + 1/((s + 1/t_info)*(s + 1/t_start)) + (s + 1/t_info)**(-2) - (P - 1)*((s + 1/t_transf)**(-2) + 1/((s + 1/t_repeat)*(s + 1/t_transf)) + (s + 1/t_repeat)**(-2))/( t_repeat*t_transf*(1 + (P - 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/t_transf)))*(s + 1/t_repeat)*(s + 1/t_transf)) - (P - 1)*(1/(s + 1/t_transf) + 1/(s + 1/t_repeat))/(t_repeat*t_transf*(1 + (P - 1)/(t_repeat*t_transf*(s + 1/ t_repeat)*(s + 1/t_transf)))*(s + 1/t_repeat)*(s + 1/t_transf)**2) - (P - 1)*(1/(s + 1/t_transf) + 1/(s + 1/t_repeat))/(t_repeat*t_transf*(1 + (P - 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/t_transf)))*(s + 1/t_repeat)*(s + 1/ t_stat_analyze)*(s + 1/t_transf)) - (P - 1)*(1/(s + 1/t_transf) + 1/(s + 1/t_repeat))/(t_repeat*t_transf*(1 + (P - 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/t_transf)))*(s + 1/t_repeat)*(s + 1/t_start)*(s + 1/t_transf)) - (P - 1)*(1/( s + 1/t_transf) + 1/(s + 1/t_repeat))/(t_repeat*t_transf*(1 + (P - 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/t_transf)))*(s + 1/t_info)*(s + 1/t_repeat)*(s + 1/t_transf)) + (P - 1)**2*(1/(s + 1/t_transf) + 1/(s + 1/t_repeat))**2/( t_repeat**2*t_transf**2*(1 + (P - 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/t_transf)))**2*(s + 1/t_repeat)**2*(s + 1/t_transf)**2))/(t_info*t_start*t_stat_analyze*t_transf*(1 + (P - 1)/(t_repeat*t_transf*(s + 1/t_repeat)*(s + 1/ t_transf)))*(s + 1/t_info)*(s + 1/t_start)*(s + 1/t_stat_analyze)*(s + 1/t_transf))
T_realyze = M1(0)
D = M2(0)-M1(0)**2
alpha = T_realyze**2/D
myu = T_realyze/D
def F(t):
if t<0:
return 0
else:
return sp.integrate((myu**alpha)/(sp.gamma(alpha)*(x**(alpha-1))*sp.exp(myu*x)), (x, 0, t))
t=arange(0, 200, 1)
for i in t:
print(F(i))
i = i+1
So, when I'm trying to execute it, I had such error in
return sp.integrate
function:
$ python2.7 nta.py
1.0
('T_realyze = ', 63.800000000000026)
('D = ', 2696.760000000001)
('alpha = ', 1.5093816283243602)
('myu = ', 0.02365801925273291)
0
('myu*x = ', 0.0236580192527329*x)
('sp.exp(myu*x)', exp(0.0236580192527329*x))
0
1
('myu*x = ', 0.0236580192527329*x)
('sp.exp(myu*x)', exp(0.0236580192527329*x))
Traceback (most recent call last):
File "nta.py", line 48, in <module>
print(F(i))
File "nta.py", line 43, in F
return sp.integrate((myu**alpha)/(sp.gamma(alpha)*(x**(alpha-1))*sp.exp(myu*x)), (x, 0, t))
File "/root/anaconda2/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 1280, in integrate
risch=risch, manual=manual)
File "/root/anaconda2/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 486, in doit
conds=conds)
File "/root/anaconda2/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 887, in _eval_integral
h = heurisch_wrapper(g, x, hints=[])
File "/root/anaconda2/lib/python2.7/site-packages/sympy/integrals/heurisch.py", line 130, in heurisch_wrapper
unnecessary_permutations)
File "/root/anaconda2/lib/python2.7/site-packages/sympy/integrals/heurisch.py", line 657, in heurisch
solution = _integrate('Q')
File "/root/anaconda2/lib/python2.7/site-packages/sympy/integrals/heurisch.py", line 646, in _integrate
numer = ring.from_expr(raw_numer)
File "/root/anaconda2/lib/python2.7/site-packages/sympy/polys/rings.py", line 371, in from_expr
raise ValueError("expected an expression convertible to a polynomial in %s, got %s" % (self, expr))
ValueError: expected an expression convertible to a polynomial in Polynomial ring in _x0, _x1, _x2, _x3 over RR[_A0,_A1,_A2,_A3,_A4,_A5,_A6,_A7,_A8,_A9,_A10,_A11,_A12,_A13,_A14,_A15,_A16,_A17,_A18,_A19,_A20,_A21,_A22,_A23,_A24,_A25,_A26,_A27,_A28,_A29,_A30,_A31,_A32,_A33,_A34] with lex order, got 0.50938162832436*_x3**2.96316463805253*(_A0 + _A10*_x0*_x1 + 2*_A11*_x1*_x3 + _x0**2*_A12 + _A14*_x0*_x2 + _A2*_x0 + 2*_A20*_x0*_x3 + _A24*_x1*_x2 + _x2**2*_A27 + 2*_A28*_x3 + _x1**2*_A30 + 3*_x3**2*_A31 + 2*_A6*_x2*_x3 + _A8*_x2 + _A9*_x1) + 1.50938162832436*_x3**4.92632927610506*(_A10*_x1*_x3 + 2*_A12*_x0*_x3 + _A13*_x1*_x2 + _A14*_x2*_x3 + 2*_A15*_x0 + _A16*_x2 + _x2**2*_A18 + _A2*_x3 + _x3**2*_A20 + _A21 + _x1**2*_A3 + 2*_A33*_x0*_x2 + _A34*_x1 + 3*_x0**2*_A5 + 2*_A7*_x0*_x1) - _A10*_x0*_x3 - _x3**2*_A11 - _A13*_x0*_x2 - _x2**2*_A17 - 2*_A19*_x1*_x2 - _A22 - _A24*_x2*_x3 - 2*_A25*_x1 - 3*_x1**2*_A29 - 2*_A3*_x0*_x1 - 2*_A30*_x1*_x3 - _A34*_x0 - _A4*_x2 - _x0**2*_A7 - _A9*_x3 + _x2*_x3 + 0.0236580192527329*_x2*(_A13*_x0*_x1 + _A14*_x0*_x3 + _A16*_x0 + 2*_A17*_x1*_x2 + 2*_A18*_x0*_x2 + _x1**2*_A19 + 2*_A23*_x2 + _A24*_x1*_x3 + 3*_x2**2*_A26 + 2*_A27*_x2*_x3 + _A32 + _x0**2*_A33 + _A4*_x1 + _x3**2*_A6 + _A8*_x3)

Sympy appears to have difficulties evaluating the integral with floating point coefficients (in this case). However, it can find the integral in closed form when the constants of the integrand expression are symbolic.
a, b, c, t = sp.symbols('a,b,c,t', positive = True)
f = sp.Integral(a * sp.exp(-c*x)/(x**b),(x,0,t)).doit()
print f
Output:
-a*(-b*c**b*gamma(-b + 1)*lowergamma(-b + 1, 0)/(c*gamma(-b + 2)) + c**b*gamma(-b + 1)*lowergamma(-b + 1, 0)/(c*gamma(-b + 2))) + a*(-b*c**b*gamma(-b + 1)*lowergamma(-b + 1, c*t)/(c*gamma(-b + 2)) + c**b*gamma(-b + 1)*lowergamma(-b + 1, c*t)/(c*gamma(-b + 2)))
You can substitute the constants in this expression to get numerical results as follows (here, I use an example value of t=4):
f.subs({a:(myu**alpha)/sp.gamma(alpha), b:(alpha-1), c:myu, t:4}).n()
0.0154626407404632
Another option is to use quad from scipy (again using t=4):
from scipy.integrate import quad
quad(lambda x: (myu**alpha)/(sp.gamma(alpha)*(x**(alpha-1))*sp.exp(myu*x)), 0 ,4)[0]
0.015462640740458165

Related

Unsure about the cause of the DiracDelta error with my code using symfit

I have been carrying out QMSA analysis of PdSn4 and when trying to implement a multicarrier fitting I keep getting an error
NameError: name 'DiracDelta' is not defined
My output includes only one instance where the DiracDelta function is present when looking at the second band fitting (n2, mu2). From what I understand there shouldn't be any DiracDelta functions within the output based on my model design.
import sympy as sp
from sympy.functions.special.delta_functions import DiracDelta
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import math
import symfit
from symfit import DiracDelta
from symfit import Variable, Parameter, parameters, Fit, Model, cosh
from symfit.contrib.interactive_guess import InteractiveGuess
import numpy as np
plt.ion()
data = np.loadtxt('PdSn4_010K_rhoData.txt')
xdata = np.array(data[:, 0])
rhoxx_exp = np.array(data[:, 1])
rhoxy_exp = np.array(data[:, 2])
B = Variable('B')
y1 = Variable('y1')
y2 = Variable('y2')
n_1 = Parameter('n1', value=n1, min=1.5e27, max=1.55e27)
n_2 = Parameter('n2', value=n2, min=-1.52e27, max=-1.51e27)
n_3 = Parameter('n3', value=n3, min=0.91e27, max=0.92e27)
n_4 = Parameter('n4', value=n4, min=-1.05e27, max=-1.045e27)
mu_1 = Parameter('mu1', value=mu1, min=1.4, max=1.42)
mu_2 = Parameter('mu2', value=mu2, min=0.63, max=0.65)
mu_3 = Parameter('mu3', value=mu3, min=0.085, max=0.09)
mu_4 = Parameter('mu4', value=mu4, min=0.088, max=0.092)
a = 1.1513
f = 0.992
q = 1.6e-19
R1 = -1 / (q*n_1)
R2 = -1 / (q*n_2)
R3 = -1 / (q*n_3)
R4 = -1 / (q*n_4)
rho1 = 1 / (abs(n_1) * q * mu_1)
rho2 = 1 / (abs(n_2) * q * mu_2)
rho3 = 1 / (abs(n_3) * q * mu_3)
rho4 = 1 / (abs(n_4) * q * mu_4)
dictionary = {
y1: (rho1 / (rho1**2 + (R1*B)**2) + rho2 / (rho2**2 + (R2*B)**2)
+ rho3 / (rho3**2 + (R3*B)**2) + rho4 / (rho4**2 + (R4*B)**2))
/ ((rho1 / (rho1**2 + (R1*B)**2) + rho2 / (rho2**2 + (R2*B)**2)
+ rho3 / (rho3**2 + (R3*B)**2) + rho4 / (rho4**2 + (R4*B)**2))**2
+ ((-R1*B)/(rho1**2+(R1*B)**2) + (-R2*B)/(rho2**2+(R2*B)**2)
+ (-R3*B)/(rho3**2+(R3*B)**2) + (-R4*B)/(rho4**2+(R4*B)**2))**2)
+ (a/cosh(B/f))*((rho1 / (rho1**2 + (R1*B)**2) + rho2 / (rho2**2 + (R2*B)**2)
+ rho3 / (rho3**2 + (R3*B)**2) + rho4 / (rho4**2 + (R4*B)**2))
/ ((rho1 / (rho1**2 + (R1*B)**2) + rho2 / (rho2**2 + (R2*B)**2)
+ rho3 / (rho3**2 + (R3*B)**2) + rho4 / (rho4**2 + (R4*B)**2))**2
+ ((-R1*B)/(rho1**2+(R1*B)**2) + (-R2*B)/(rho2**2+(R2*B)**2)
+ (-R3*B)/(rho3**2+(R3*B)**2) + (-R4*B)/(rho4**2+(R4*B)**2))**2))
,
y2: - ((-R1*B)/(rho1**2+(R1*B)**2) + (-R2*B)/(rho2**2+(R2*B)**2)
+ (-R3*B)/(rho3**2+(R3*B)**2) + (-R4*B)/(rho4**2+(R4*B)**2)) /
((rho1 / (rho1**2 + (R1*B)**2) + rho2 / (rho2**2 + (R2*B)**2)
+ rho3 / (rho3**2 + (R3*B)**2) + rho4 / (rho4**2 + (R4*B)**2))**2
+ ((-R1*B)/(rho1**2+(R1*B)**2) + (-R2*B)/(rho2**2+(R2*B)**2)
+ (-R3*B)/(rho3**2+(R3*B)**2) + (-R4*B)/(rho4**2+(R4*B)**2))**2)
}
model = Model(dictionary)
#print(model)
model_sim = model(B=xdata, n1=n1, n2=n2, n3=n3, n4=n4, mu1=mu1, mu2=mu2, mu3=mu3, mu4=mu4)
#print(data)
rho_xx_sim = model_sim.y1
rho_xy_sim = model_sim.y2
f = plt.figure(figsize=(15,15))
ax = f.add_subplot(211)
plt.xlabel("Magnetic Field [T]")
plt.ylabel("Rho$_{xx}$")
plt.plot(xdata, rhoxx_exp, 'k.')
plt.plot(xdata, rho_xx_sim, 'r-')
plt.xlim([0,8])
ax2 = f.add_subplot(212)
plt.xlabel("Magnetic Field [T]")
plt.ylabel("Rho$_{xy}$")
plt.plot(xdata, rhoxy_exp, 'k.')
plt.plot(xdata, rho_xy_sim, 'r-')
plt.xlim([0,8])
plt.show()
guess = InteractiveGuess(dictionary, B=xdata, y1=rho_xx_sim, y2=rho_xy_sim, n_points=250)
guess.execute()
print(guess)
fit = Fit(model, B=xdata, y1=rho_xx_sim, y2=rho_xy_sim)
fit_result = fit.execute()
print(fit_result)
Link to the data: Multicarrier Fitting Data
It should be saved as PdSn4_010K_rhoData.txt in the same directory as the file.
If anyone could figure out why there is this DiracDelta function present in my output or how to overcome this error that would be great!
Error traceback goes as follows:
NameError Traceback (most recent call last)
<ipython-input-19-68c235066887> in <module>
197
198 fit = Fit(model, B=xdata, y1=rho_xx_sim, y2=rho_xy_sim)
--> 199 fit_result = fit.execute()
200 print(fit_result)
201 #y1result, y2result = fit.model(B=xdata, **fit_result.params)
~\anaconda5\lib\site-packages\symfit\core\fit.py in execute(self, **minimize_options)
579 """
580 minimizer_ans = self.minimizer.execute(**minimize_options)
--> 581 minimizer_ans.covariance_matrix = self.covariance_matrix(
582 dict(zip(self.model.params, minimizer_ans._popt))
583 )
~\anaconda5\lib\site-packages\symfit\core\fit.py in covariance_matrix(self, best_fit_params)
278 :return: covariance matrix.
279 """
--> 280 cov_matrix = self._covariance_matrix(best_fit_params,
281 objective=self.objective)
282 if cov_matrix is None:
~\anaconda5\lib\site-packages\symfit\core\fit.py in _covariance_matrix(self, best_fit_params, objective)
236 # Helper function for self.covariance_matrix.
237 try:
--> 238 hess = objective.eval_hessian(**key2str(best_fit_params))
239 except AttributeError:
240 # Some models do not have an eval_hessian, in which case we give up
~\anaconda5\lib\site-packages\symfit\core\objectives.py in eval_hessian(self, ordered_parameters, **parameters)
367 ordered_parameters, **parameters
368 )
--> 369 evaluated_hess = super(LeastSquares, self).eval_hessian(
370 ordered_parameters, **parameters
371 )
~\anaconda5\lib\site-packages\symfit\core\objectives.py in eval_hessian(self, ordered_parameters, **parameters)
221 parameters.update(dict(zip(self.model.free_params, ordered_parameters)))
222 parameters.update(self._invariant_kwargs)
--> 223 result = self.model.eval_hessian(**key2str(parameters))._asdict()
224 # Return only the components corresponding to the dependent data.
225 return self._shape_of_dependent_data(
~\anaconda5\lib\site-packages\symfit\core\models.py in eval_hessian(self, *args, **kwargs)
897 # Evaluate the hessian model and use the resulting Ans namedtuple as a
898 # dict. From this, take the relevant components.
--> 899 eval_hess_dict = self.hessian_model(*args, **kwargs)._asdict()
900 hess = [[[np.broadcast_to(eval_hess_dict.get(D(var, p1, p2), 0),
901 eval_hess_dict[var].shape)
~\anaconda5\lib\site-packages\symfit\core\models.py in __call__(self, *args, **kwargs)
665 even for scalar valued functions. This is done for consistency.
666 """
--> 667 return ModelOutput(self.keys(), self.eval_components(*args, **kwargs))
668
669
~\anaconda5\lib\site-packages\symfit\core\models.py in eval_components(self, *args, **kwargs)
613 dependencies_kwargs = {d.name: kwargs[d.name]
614 for d in dependencies}
--> 615 kwargs[symbol.name] = components[symbol](**dependencies_kwargs)
616
617 return [np.atleast_1d(kwargs[var.name]) for var in self]
<lambdifygenerated-1024> in _lambdifygenerated(B, mu1, mu2, mu3, mu4, n1, n2, n3, n4)
1 def _lambdifygenerated(B, mu1, mu2, mu3, mu4, n1, n2, n3, n4):
----> 2 return (6.5536e-76*(-3.90625e+37*(1.31072e-75*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(mu2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2*abs(n2)) - 2*sign(n2)/(mu2*n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))))*(1/(mu4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))*abs(n4)) + 1/(mu3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))*abs(n3)) + 1/(mu2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))*abs(n2)) + 1/(mu1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))*abs(n1))) - 3.90625e+37*(1.31072e-75*B*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(n2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) - 2*B/(n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))))*(B/(n4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))) + B/(n3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))) + B/(n2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) + B/(n1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2)))))*(-2*(1.31072e-75*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(mu2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2*abs(n2)) - 2*sign(n2)/(mu2*n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))))*(1/(mu4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))*abs(n4)) + 1/(mu3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))*abs(n3)) + 1/(mu2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))*abs(n2)) + 1/(mu1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))*abs(n1))) - 2*(1.31072e-75*B*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(n2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) - 2*B/(n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))))*(B/(n4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))) + B/(n3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))) + B/(n2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) + B/(n1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2)))))*(-6.25e+18*B/(n4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))) - 6.25e+18*B/(n3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))) - 6.25e+18*B/(n2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) - 6.25e+18*B/(n1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))))/((1/(mu4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))*abs(n4)) + 1/(mu3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))*abs(n3)) + 1/(mu2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))*abs(n2)) + 1/(mu1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))*abs(n1)))**2 + (B/(n4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))) + B/(n3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))) + B/(n2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) + B/(n1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))))**2)**3 + 1.31072e-75*(-3.90625e+37*(1.31072e-75*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(mu2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2*abs(n2)) - 2*sign(n2)/(mu2*n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))))*(1/(mu4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))*abs(n4)) + 1/(mu3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))*abs(n3)) + 1/(mu2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))*abs(n2)) + 1/(mu1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))*abs(n1))) - 3.90625e+37*(1.31072e-75*B*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(n2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) - 2*B/(n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))))*(B/(n4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))) + B/(n3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))) + B/(n2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) + B/(n1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2)))))*(-4.096e-57*B*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(n2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) + 6.25e+18*B/(n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))))/((1/(mu4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))*abs(n4)) + 1/(mu3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))*abs(n3)) + 1/(mu2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))*abs(n2)) + 1/(mu1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))*abs(n1)))**2 + (B/(n4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))) + B/(n3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))) + B/(n2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) + B/(n1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))))**2)**2 + (-4.096e-57*B*(-2.34375e+38*B**2/n2**4 - 2.34375e+38/(mu2**2*n2**4))/(n2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) - 4.096e-57*B*(4*B**2/n2**3 + 4/(mu2**2*n2**3))*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(n2*(B**2/n2**2 + 1/(mu2**2*n2**2))**3) + 8.192e-57*B*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(n2**2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) - 1.25e+19*B/(n2**3*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))))/(3.90625e+37*(1/(mu4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))*abs(n4)) + 1/(mu3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))*abs(n3)) + 1/(mu2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))*abs(n2)) + 1/(mu1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))*abs(n1)))**2 + 3.90625e+37*(B/(n4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))) + B/(n3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))) + B/(n2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) + B/(n1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))))**2) + 6.5536e-76*((-5.12e-38*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(mu2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2*abs(n2)) + 7.8125e+37*sign(n2)/(mu2*n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))))*(6.5536e-76*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(mu2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2*abs(n2)) - sign(n2)/(mu2*n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2)))) + (-5.12e-38*B*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(n2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) + 7.8125e+37*B/(n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))))*(6.5536e-76*B*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(n2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) - B/(n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2)))) + (1/(mu4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))*abs(n4)) + 1/(mu3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))*abs(n3)) + 1/(mu2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))*abs(n2)) + 1/(mu1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))*abs(n1)))*(-5.12e-38*(-2.34375e+38*B**2/n2**4 - 2.34375e+38/(mu2**2*n2**4))/(mu2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2*abs(n2)) - 5.12e-38*(4*B**2/n2**3 + 4/(mu2**2*n2**3))*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(mu2*(B**2/n2**2 + 1/(mu2**2*n2**2))**3*abs(n2)) + 1.024e-37*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))*sign(n2)/(mu2*n2**2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) + 1.5625e+38*DiracDelta(n2)/(mu2*n2**2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) - 1.5625e+38*sign(n2)/(mu2*n2**3*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2)))) + (B/(n4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))) + B/(n3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))) + B/(n2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) + B/(n1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))))*(-5.12e-38*B*(-2.34375e+38*B**2/n2**4 - 2.34375e+38/(mu2**2*n2**4))/(n2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) - 5.12e-38*B*(4*B**2/n2**3 + 4/(mu2**2*n2**3))*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(n2*(B**2/n2**2 + 1/(mu2**2*n2**2))**3) + 1.024e-37*B*(7.8125e+37*B**2/n2**3 + 7.8125e+37/(mu2**2*n2**3))/(n2**2*(B**2/n2**2 + 1/(mu2**2*n2**2))**2) - 1.5625e+38*B/(n2**3*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2)))))*(-6.25e+18*B/(n4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))) - 6.25e+18*B/(n3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))) - 6.25e+18*B/(n2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) - 6.25e+18*B/(n1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))))/((1/(mu4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))*abs(n4)) + 1/(mu3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))*abs(n3)) + 1/(mu2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))*abs(n2)) + 1/(mu1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))*abs(n1)))**2 + (B/(n4*(3.90625e+37*B**2/n4**2 + 3.90625e+37/(mu4**2*n4**2))) + B/(n3*(3.90625e+37*B**2/n3**2 + 3.90625e+37/(mu3**2*n3**2))) + B/(n2*(3.90625e+37*B**2/n2**2 + 3.90625e+37/(mu2**2*n2**2))) + B/(n1*(3.90625e+37*B**2/n1**2 + 3.90625e+37/(mu1**2*n1**2))))**2)**2)
NameError: name 'DiracDelta' is not defined

Python LDA Gensim model with over 20 topics does not print properly

Using the Gensim package (both LDA and Mallet), I noticed that when I create a model with more than 20 topics, and I use the print_topics function, it will print a maximum of 20 topics (note, not the first 20 topics, rather any 20 topics), and they will be out of order.
And so my question is, how do i get all of the topics to print? I am unsure if this is a bug or an issue on my end. I have looked back at my library of LDA models (over 5000, different data sources), and have noted this happens in all of them where topics are above 20.
Below is sample code with output. In the output, you will see the topics are not ordered (they should be) and topics are missing such as topic 3.
lda_model = gensim.models.ldamodel.LdaModel(corpus=jr_dict_corpus,
id2word=jr_dict,
num_topics=25,
random_state=100,
update_every=1,
chunksize=100,
passes=10,
alpha='auto',
per_word_topics=True)
pprint(lda_model.print_topics())
#note, if the model contained 20 topics, the topics would be listed in order 0-19
[(21,
'0.001*"commitment" + 0.001*"study" + 0.001*"evolve" + 0.001*"outlook" + '
'0.001*"value" + 0.001*"people" + 0.001*"individual" + 0.001*"client" + '
'0.001*"structure" + 0.001*"proposal"'),
(18,
'0.001*"self" + 0.001*"insurance" + 0.001*"need" + 0.001*"trend" + '
'0.001*"statistic" + 0.001*"propose" + 0.001*"analysis" + 0.001*"perform" + '
'0.001*"impact" + 0.001*"awareness"'),
(2,
'0.001*"link" + 0.001*"task" + 0.001*"collegiate" + 0.001*"universitie" + '
'0.001*"banking" + 0.001*"origination" + 0.001*"security" + 0.001*"standard" '
'+ 0.001*"qualifications_bachelor" + 0.001*"greenfield"'),
(11,
'0.024*"collegiate" + 0.016*"interpersonal" + 0.016*"prepare" + '
'0.016*"invite" + 0.016*"aspect" + 0.016*"college" + 0.016*"statistic" + '
'0.016*"continent" + 0.016*"structure" + 0.016*"project"'),
(10,
'0.049*"enjoy" + 0.049*"ambiguity" + 0.017*"accordance" + 0.017*"liberalize" '
'+ 0.017*"developing" + 0.017*"application" + 0.017*"vacancie" + '
'0.017*"service" + 0.017*"initiative" + 0.017*"discontinuing"'),
(20,
'0.028*"negotiation" + 0.028*"desk" + 0.018*"enhance" + 0.018*"engage" + '
'0.018*"discussion" + 0.018*"ability" + 0.018*"depth" + 0.018*"derive" + '
'0.018*"enjoy" + 0.018*"balance"'),
(12,
'0.036*"individual" + 0.024*"validate" + 0.018*"greenfield" + '
'0.018*"capability" + 0.018*"coordinate" + 0.018*"create" + '
'0.018*"programming" + 0.018*"safety" + 0.010*"evaluation" + '
'0.002*"reliability"'),
(1,
'0.028*"negotiation" + 0.021*"responsibility" + 0.014*"master" + '
'0.014*"mind" + 0.014*"experience" + 0.014*"worker" + 0.014*"ability" + '
'0.007*"summary" + 0.007*"proposal" + 0.007*"alert"'),
(23,
'0.043*"banking" + 0.026*"origination" + 0.026*"round" + 0.026*"credibility" '
'+ 0.026*"entity" + 0.018*"standard" + 0.017*"range" + 0.017*"pension" + '
'0.017*"adapt" + 0.017*"information"'),
(13,
'0.034*"priority" + 0.034*"reconciliation" + 0.034*"purchaser" + '
'0.023*"reporting" + 0.023*"offer" + 0.023*"investor" + 0.023*"share" + '
'0.023*"region" + 0.023*"service" + 0.023*"manipulate"'),
(22,
'0.017*"analyst" + 0.017*"modelling" + 0.016*"producer" + 0.016*"return" + '
'0.016*"self" + 0.009*"scope" + 0.008*"mind" + 0.008*"need" + 0.008*"detail" '
'+ 0.008*"statistic"'),
(9,
'0.021*"decision" + 0.014*"invite" + 0.014*"balance" + 0.014*"commercialize" '
'+ 0.014*"transform" + 0.014*"manage" + 0.014*"optionality" + '
'0.014*"problem_solving" + 0.014*"fuel" + 0.014*"stay"'),
(7,
'0.032*"commitment" + 0.032*"study" + 0.016*"impact" + 0.016*"outlook" + '
'0.011*"operation" + 0.011*"expand" + 0.011*"exchange" + 0.011*"management" '
'+ 0.011*"conde" + 0.011*"evolve"'),
(15,
'0.032*"agility" + 0.019*"feasibility" + 0.019*"self" + 0.014*"deploy" + '
'0.014*"define" + 0.013*"investment" + 0.013*"option" + 0.013*"control" + '
'0.013*"action" + 0.013*"incubation"'),
(5,
'0.020*"desk" + 0.018*"agility" + 0.016*"vender" + 0.016*"coordinate" + '
'0.016*"committee" + 0.012*"acquisition" + 0.012*"target" + '
'0.012*"counterparty" + 0.012*"approval" + 0.012*"trend"'),
(17,
'0.022*"option" + 0.017*"working" + 0.017*"niche" + 0.011*"business" + '
'0.011*"constrain" + 0.011*"meeting" + 0.011*"correspond" + 0.011*"exposure" '
'+ 0.011*"element" + 0.011*"face"'),
(0,
'0.025*"expertise" + 0.025*"banking" + 0.021*"universitie" + '
'0.017*"spreadsheet" + 0.013*"negotiation" + 0.013*"shipment" + '
'0.013*"arise" + 0.013*"billing" + 0.013*"assistance" + 0.013*"sector"'),
(4,
'0.024*"provide" + 0.017*"consider" + 0.017*"allow" + 0.015*"outlook" + '
'0.015*"value" + 0.015*"contract" + 0.012*"study" + 0.012*"technology" + '
'0.012*"scenario" + 0.012*"indicator"'),
(6,
'0.058*"impulse" + 0.027*"shall" + 0.027*"shape" + 0.024*"marketer" + '
'0.017*"availability" + 0.014*"determine" + 0.014*"load" + '
'0.014*"constantly_change" + 0.014*"instrument" + 0.014*"interface"'),
(19,
'0.042*"task" + 0.038*"tariff" + 0.038*"recommend" + 0.024*"example" + '
'0.023*"future" + 0.021*"people" + 0.021*"math" + 0.021*"capacity" + '
'0.021*"spirit" + 0.020*"price"')]
Same model as above, but using 20 topics. As you can see, the output is in order by topic # and it contains all the topics.
lda_model = gensim.models.ldamodel.LdaModel(corpus=jr_dict_corpus,
id2word=jr_dict,
num_topics=20,
random_state=100,
update_every=1,
chunksize=100,
passes=10,
alpha='auto',
per_word_topics=True)
pprint(lda_model.print_topics())
[(0,
'0.031*"enjoy" + 0.031*"ambiguity" + 0.028*"accordance" + 0.016*"statistic" '
'+ 0.016*"initiative" + 0.016*"service" + 0.016*"liberalize" + '
'0.016*"application" + 0.011*"community" + 0.011*"identifie"'),
(1,
'0.016*"transformation" + 0.016*"negotiation" + 0.016*"community" + '
'0.016*"clock" + 0.011*"marketer" + 0.011*"desk" + 0.011*"mandate" + '
'0.011*"closing" + 0.011*"initiative" + 0.011*"experience"'),
(2,
'0.026*"priority" + 0.026*"reconciliation" + 0.026*"purchaser" + '
'0.020*"safety" + 0.020*"region" + 0.020*"query" + 0.020*"share" + '
'0.020*"manipulate" + 0.020*"ibex" + 0.020*"investor"'),
(3,
'0.022*"improve" + 0.021*"committee" + 0.021*"affect" + 0.012*"target" + '
'0.012*"acquisition" + 0.011*"basis" + 0.011*"profitability" + '
'0.011*"economic" + 0.011*"natural" + 0.011*"profit"'),
(4,
'0.024*"provide" + 0.019*"value" + 0.017*"consider" + 0.017*"allow" + '
'0.015*"scenario" + 0.015*"outlook" + 0.015*"contract" + 0.014*"forecast" + '
'0.014*"decision" + 0.012*"indicator"'),
(5,
'0.037*"desk" + 0.030*"coordinate" + 0.030*"agility" + 0.030*"vender" + '
'0.023*"counterparty" + 0.023*"immature_emerge" + 0.023*"metric" + '
'0.022*"approval" + 0.015*"maximization" + 0.015*"undergraduate"'),
(6,
'0.053*"impulse" + 0.025*"shall" + 0.025*"shape" + 0.018*"availability" + '
'0.018*"marketer" + 0.012*"determine" + 0.012*"language" + '
'0.012*"monitoring" + 0.012*"integration" + 0.012*"month"'),
(7,
'0.026*"commitment" + 0.026*"study" + 0.013*"impact" + 0.013*"outlook" + '
'0.009*"operation" + 0.009*"management" + 0.009*"expand" + 0.009*"exchange" '
'+ 0.009*"conde" + 0.009*"balance"'),
(8,
'0.057*"insurance" + 0.029*"propose" + 0.028*"rule" + 0.026*"self" + '
'0.023*"product" + 0.023*"asset" + 0.023*"pricing" + 0.023*"amount" + '
'0.023*"result" + 0.020*"liquidity"'),
(9,
'0.012*"universitie" + 0.012*"need" + 0.012*"statistic" + 0.012*"trend" + '
'0.008*"invite" + 0.008*"commercialize" + 0.008*"transform" + 0.008*"manage" '
'+ 0.008*"problem_solving" + 0.008*"optionality"'),
(10,
'0.024*"background" + 0.024*"curve" + 0.020*"allow" + 0.019*"collect" + '
'0.019*"basis" + 0.017*"accordance" + 0.013*"improve" + 0.013*"datum" + '
'0.013*"component" + 0.013*"reliability"'),
(11,
'0.054*"task" + 0.049*"tariff" + 0.049*"recommend" + 0.031*"future" + '
'0.027*"spirit" + 0.027*"capacity" + 0.027*"math" + 0.022*"ensure" + '
'0.022*"profit" + 0.022*"variable_margin"'),
(12,
'0.001*"impulse" + 0.001*"availability" + 0.001*"reliability" + '
'0.001*"shall" + 0.001*"component" + 0.001*"agent" + 0.001*"marketer" + '
'0.001*"shape" + 0.001*"assisting" + 0.001*"supply"'),
(13,
'0.021*"region" + 0.016*"greenfield" + 0.016*"collegiate" + 0.011*"transfer" '
'+ 0.011*"remuneration" + 0.011*"organization" + 0.011*"structure" + '
'0.011*"continent" + 0.011*"project" + 0.011*"prepare"'),
(14,
'0.033*"originator" + 0.025*"vender" + 0.025*"expertise" + 0.025*"banking" + '
'0.019*"evolve" + 0.017*"management" + 0.017*"market" + 0.017*"site" + '
'0.012*"component" + 0.012*"discontinuing"'),
(15,
'0.027*"agility" + 0.022*"mind" + 0.022*"negotiation" + 0.011*"deploy" + '
'0.011*"define" + 0.011*"ecosystem" + 0.011*"control" + 0.011*"lead" + '
'0.011*"industry" + 0.011*"option"'),
(16,
'0.001*"region" + 0.001*"master" + 0.001*"orginiation" + 0.001*"greenfield" '
'+ 0.001*"agent" + 0.001*"identifie" + 0.001*"remuneration" + 0.001*"mark" + '
'0.001*"reviewing" + 0.001*"closing"'),
(17,
'0.030*"banking" + 0.018*"option" + 0.018*"round" + 0.018*"credibility" + '
'0.018*"origination" + 0.018*"entity" + 0.016*"working" + 0.015*"niche" + '
'0.015*"standard" + 0.012*"coordinate"'),
(18,
'0.027*"negotiation" + 0.018*"reporting" + 0.018*"perform" + 0.018*"world" + '
'0.015*"offer" + 0.015*"manipulate" + 0.011*"query" + 0.010*"control" + '
'0.010*"working" + 0.009*"self"'),
(19,
'0.047*"example" + 0.039*"people" + 0.039*"price" + 0.039*"excel" + '
'0.039*"excellent" + 0.038*"base" + 0.031*"office" + 0.031*"optimizing" + '
'0.031*"participate" + 0.031*"package"')]
The default number of topics for print_topics is 20. You must use the num_topics argument to include topics above 20...
print(lda_model.print_topics(num_topics=25, num_words=10))

argument must be a string or a number, not 'LpAffineExpression'

I am trying to use python IRR function with PULP maximisation but i am getting the following error
TypeError: float() argument must be a string or a number, not 'LpAffineExpression'
TypeError Traceback (most recent call last)
in
11 name[6]*rate[6]*ratesList2[2] + name[7]*rate[7]*ratesList2[2] + name[8]*rate[8]*ratesList2[2] + name[9]*rate[9]*ratesList2[2] + name[10]*rate[10]*ratesList2[2] + name[11]*rate[11]*ratesList2[2] +
12 name[12]*rate[12]*ratesList2[2] + name[13]*rate[13]*ratesList2[2] + name[14]*rate[14]*ratesList2[2] + name[15]*rate[15]*ratesList2[2] + name[16]*rate[16]*ratesList2[2] + name[17]*rate[17]*ratesList2[2] +
---> 13 name[18]*rate[18]*ratesList2[2])])
14
15
problem += np.irr([(-19660528.00),
(name[0]*rate[0] + name[1]*rate[1] + name[2]*rate[2] + name[3]*rate[3] + name[4]*rate[4] + name[5]*rate[5] +
name[6]*rate[6] + name[7]*rate[7] + name[8]*rate[8] + name[9]*rate[9] + name[10]*rate[10] + name[11]*rate[11] +
name[12]*rate[12] + name[13]*rate[13] + name[14]*rate[14] + name[15]*rate[15] + name[16]*rate[16] + name[17]*rate[17] +
name[18]*rate[18]),
(name[0]*rate[0]*ratesList1[1] + name[1]*rate[1]*ratesList2[1] + name[2]*rate[2]*ratesList2[1] + name[3]*rate[3]*ratesList2[1] + name[4]*rate[4]*ratesList2[1] + name[5]*rate[5]*ratesList2[1] +
name[6]*rate[6]*ratesList2[1] + name[7]*rate[7]*ratesList2[1] + name[8]*rate[8]*ratesList2[1] + name[9]*rate[9]*ratesList2[1] + name[10]*rate[10]*ratesList2[1] + name[11]*rate[11]*ratesList2[1] +
name[12]*rate[12]*ratesList2[1] + name[13]*rate[13]*ratesList2[1] + name[14]*rate[14]*ratesList2[1] + name[15]*rate[15]*ratesList2[1] + name[16]*rate[16]*ratesList2[1] + name[17]*rate[17]*ratesList2[1] +
name[18]*rate[18]*ratesList2[1]),
(name[0]*rate[0]*ratesList1[2] + name[1]*rate[1]*ratesList2[2] + name[2]*rate[2]*ratesList2[2] + name[3]*rate[3]*ratesList2[2] + name[4]*rate[4]*ratesList2[2] + name[5]*rate[5]*ratesList2[2] +
name[6]*rate[6]*ratesList2[2] + name[7]*rate[7]*ratesList2[2] + name[8]*rate[8]*ratesList2[2] + name[9]*rate[9]*ratesList2[2] + name[10]*rate[10]*ratesList2[2] + name[11]*rate[11]*ratesList2[2] +
name[12]*rate[12]*ratesList2[2] + name[13]*rate[13]*ratesList2[2] + name[14]*rate[14]*ratesList2[2] + name[15]*rate[15]*ratesList2[2] + name[16]*rate[16]*ratesList2[2] + name[17]*rate[17]*ratesList2[2] +
name[18]*rate[18]*ratesList2[2])])
problem += (name[0] + name[1] + name[2] + name[3] + name[4] + name[5] + name[6] + name[7] + name[8] + name[9] + name[10] +
name[11] + name[12] + name[13] + name[14] + name[15] + name[16] + name[17] + name[18]) <= sum(marketMix['GLA']), "1st constraint"
The numpy function irr() takes as argument a list of values. You are instead passing a list of linear expressions containing variables that are subject to optimization. irr() is not prepared to handle that. It assumes that all arguments can be coerced into a float. Instead of using function irr() you will have to state the respective expression explicitly.

Generate a Bode-form transfer function using ratsimp

I have to simplify a transfer function using sympy. I am used to maxima and I am looking for advice to get similar performances in a python environment.
Using the following Maxima code:
A:-Avol0/(1+s/(2*pi*fp));
Zph:Rsh/(1+Rsh*Cj*s);
Zf:Rf/(1+Rf*Cf*s);
alpha:Zf*Zph/(Zf+Zph);
beta:Zph/(Zf+Zph);
BetaA:ratsimp(beta*A,s);
H:ratsimp(alpha*A/(1-BetaA),s);
I get the following:
(H)-> -(2*Avol0*Rf*Rsh*fp*pi)/((Cj+Cf)*Rf*Rsh*s^2+((2*Cj+(2*Avol0+2)*Cf)*Rf*Rsh*fp*pi+Rsh+Rf)*s+((2*Avol0+2)*Rsh+2*Rf)*fp*pi)
The same opertions in sympy do not get to such a nice result:
import numpy as np
import sympy as sy
"""
Formulas
"""
s, Rf, Cf, Rsh, Cj, Cd, Ccm, GBP, Avol0, fp, w = \
sy.symbols("s Rf Cf Rsh Cj Cd Ccm GBP Avol0 fp w")
A = -Avol0/(1+s/(2*np.pi*fp))
Zph = Rsh/(1+Rsh*Cj*s)
Zf = Rf/(1+Rf*Cf*s)
alpha = Zf*Zph/(Zf+Zph)
beta = Zph/(Zf+Zph)
Gloop = sy.ratsimp(beta*A)
H = alpha*A/(1-Gloop)
sy.ratsimp(H)
returns an unreadable result:
-1.0*(1.0*Avol0*Cf**2*Cj*Rf**3*Rsh**3*fp**2*s**3 + 0.159154943091895*Avol0*Cf**2*Cj*Rf**3*Rsh**3*fp*s**4 + 1.0*Avol0*Cf**2*Rf**3*Rsh**2*fp**2*s**2 + 0.159154943091895*Avol0*Cf**2*Rf**3*Rsh**2*fp*s**3 + 1.0*Avol0*Cf*Cj**2*Rf**3*Rsh**3*fp**2*s**3 + 0.159154943091895*Avol0*Cf*Cj**2*Rf**3*Rsh**3*fp*s**4 + 2.0*Avol0*Cf*Cj*Rf**3*Rsh**2*fp**2*s**2 + 0.318309886183791*Avol0*Cf*Cj*Rf**3*Rsh**2*fp*s**3 + 2.0*Avol0*Cf*Cj*Rf**2*Rsh**3*fp**2*s**2 + 0.318309886183791*Avol0*Cf*Cj*Rf**2*Rsh**3*fp*s**3 + 1.0*Avol0*Cf*Rf**3*Rsh*fp**2*s + 0.159154943091895*Avol0*Cf*Rf**3*Rsh*fp*s**2 + 2.0*Avol0*Cf*Rf**2*Rsh**2*fp**2*s + 0.318309886183791*Avol0*Cf*Rf**2*Rsh**2*fp*s**2 + 1.0*Avol0*Cj**2*Rf**2*Rsh**3*fp**2*s**2 + 0.159154943091895*Avol0*Cj**2*Rf**2*Rsh**3*fp*s**3 + 2.0*Avol0*Cj*Rf**2*Rsh**2*fp**2*s + 0.318309886183791*Avol0*Cj*Rf**2*Rsh**2*fp*s**2 + 1.0*Avol0*Cj*Rf*Rsh**3*fp**2*s + 0.159154943091895*Avol0*Cj*Rf*Rsh**3*fp*s**2 + 1.0*Avol0*Rf**2*Rsh*fp**2 + 0.159154943091895*Avol0*Rf**2*Rsh*fp*s + 1.0*Avol0*Rf*Rsh**2*fp**2 + 0.159154943091895*Avol0*Rf*Rsh**2*fp*s)/(1.0*Avol0*Cf**3*Cj*Rf**3*Rsh**3*fp**2*s**4 + 0.159154943091895*Avol0*Cf**3*Cj*Rf**3*Rsh**3*fp*s**5 + 1.0*Avol0*Cf**3*Rf**3*Rsh**2*fp**2*s**3 + 0.159154943091895*Avol0*Cf**3*Rf**3*Rsh**2*fp*s**4 + 1.0*Avol0*Cf**2*Cj**2*Rf**3*Rsh**3*fp**2*s**4 + 0.159154943091895*Avol0*Cf**2*Cj**2*Rf**3*Rsh**3*fp*s**5 + 2.0*Avol0*Cf**2*Cj*Rf**3*Rsh**2*fp**2*s**3 + 0.318309886183791*Avol0*Cf**2*Cj*Rf**3*Rsh**2*fp*s**4 + 3.0*Avol0*Cf**2*Cj*Rf**2*Rsh**3*fp**2*s**3 + 0.477464829275686*Avol0*Cf**2*Cj*Rf**2*Rsh**3*fp*s**4 + 1.0*Avol0*Cf**2*Rf**3*Rsh*fp**2*s**2 + 0.159154943091895*Avol0*Cf**2*Rf**3*Rsh*fp*s**3 + 3.0*Avol0*Cf**2*Rf**2*Rsh**2*fp**2*s**2 + 0.477464829275686*Avol0*Cf**2*Rf**2*Rsh**2*fp*s**3 + 2.0*Avol0*Cf*Cj**2*Rf**2*Rsh**3*fp**2*s**3 + 0.318309886183791*Avol0*Cf*Cj**2*Rf**2*Rsh**3*fp*s**4 + 4.0*Avol0*Cf*Cj*Rf**2*Rsh**2*fp**2*s**2 + 0.636619772367581*Avol0*Cf*Cj*Rf**2*Rsh**2*fp*s**3 + 3.0*Avol0*Cf*Cj*Rf*Rsh**3*fp**2*s**2 + 0.477464829275686*Avol0*Cf*Cj*Rf*Rsh**3*fp*s**3 + 2.0*Avol0*Cf*Rf**2*Rsh*fp**2*s + 0.318309886183791*Avol0*Cf*Rf**2*Rsh*fp*s**2 + 3.0*Avol0*Cf*Rf*Rsh**2*fp**2*s + 0.477464829275686*Avol0*Cf*Rf*Rsh**2*fp*s**2 + 1.0*Avol0*Cj**2*Rf*Rsh**3*fp**2*s**2 + 0.159154943091895*Avol0*Cj**2*Rf*Rsh**3*fp*s**3 + 2.0*Avol0*Cj*Rf*Rsh**2*fp**2*s + 0.318309886183791*Avol0*Cj*Rf*Rsh**2*fp*s**2 + 1.0*Avol0*Cj*Rsh**3*fp**2*s + 0.159154943091895*Avol0*Cj*Rsh**3*fp*s**2 + 1.0*Avol0*Rf*Rsh*fp**2 + 0.159154943091895*Avol0*Rf*Rsh*fp*s + 1.0*Avol0*Rsh**2*fp**2 + 0.159154943091895*Avol0*Rsh**2*fp*s + 1.0*Cf**3*Cj*Rf**3*Rsh**3*fp**2*s**4 + 0.318309886183791*Cf**3*Cj*Rf**3*Rsh**3*fp*s**5 + 0.0253302959105844*Cf**3*Cj*Rf**3*Rsh**3*s**6 + 1.0*Cf**3*Rf**3*Rsh**2*fp**2*s**3 + 0.318309886183791*Cf**3*Rf**3*Rsh**2*fp*s**4 + 0.0253302959105844*Cf**3*Rf**3*Rsh**2*s**5 + 2.0*Cf**2*Cj**2*Rf**3*Rsh**3*fp**2*s**4 + 0.636619772367581*Cf**2*Cj**2*Rf**3*Rsh**3*fp*s**5 + 0.0506605918211689*Cf**2*Cj**2*Rf**3*Rsh**3*s**6 + 4.0*Cf**2*Cj*Rf**3*Rsh**2*fp**2*s**3 + 1.27323954473516*Cf**2*Cj*Rf**3*Rsh**2*fp*s**4 + 0.101321183642338*Cf**2*Cj*Rf**3*Rsh**2*s**5 + 3.0*Cf**2*Cj*Rf**2*Rsh**3*fp**2*s**3 + 0.954929658551372*Cf**2*Cj*Rf**2*Rsh**3*fp*s**4 + 0.0759908877317533*Cf**2*Cj*Rf**2*Rsh**3*s**5 + 2.0*Cf**2*Rf**3*Rsh*fp**2*s**2 + 0.636619772367581*Cf**2*Rf**3*Rsh*fp*s**3 + 0.0506605918211689*Cf**2*Rf**3*Rsh*s**4 + 3.0*Cf**2*Rf**2*Rsh**2*fp**2*s**2 + 0.954929658551372*Cf**2*Rf**2*Rsh**2*fp*s**3 + 0.0759908877317533*Cf**2*Rf**2*Rsh**2*s**4 + 1.0*Cf*Cj**3*Rf**3*Rsh**3*fp**2*s**4 + 0.318309886183791*Cf*Cj**3*Rf**3*Rsh**3*fp*s**5 + 0.0253302959105844*Cf*Cj**3*Rf**3*Rsh**3*s**6 + 3.0*Cf*Cj**2*Rf**3*Rsh**2*fp**2*s**3 + 0.954929658551372*Cf*Cj**2*Rf**3*Rsh**2*fp*s**4 + 0.0759908877317533*Cf*Cj**2*Rf**3*Rsh**2*s**5 + 4.0*Cf*Cj**2*Rf**2*Rsh**3*fp**2*s**3 + 1.27323954473516*Cf*Cj**2*Rf**2*Rsh**3*fp*s**4 + 0.101321183642338*Cf*Cj**2*Rf**2*Rsh**3*s**5 + 3.0*Cf*Cj*Rf**3*Rsh*fp**2*s**2 + 0.954929658551372*Cf*Cj*Rf**3*Rsh*fp*s**3 + 0.0759908877317533*Cf*Cj*Rf**3*Rsh*s**4 + 8.0*Cf*Cj*Rf**2*Rsh**2*fp**2*s**2 + 2.54647908947033*Cf*Cj*Rf**2*Rsh**2*fp*s**3 + 0.202642367284676*Cf*Cj*Rf**2*Rsh**2*s**4 + 3.0*Cf*Cj*Rf*Rsh**3*fp**2*s**2 + 0.954929658551372*Cf*Cj*Rf*Rsh**3*fp*s**3 + 0.0759908877317533*Cf*Cj*Rf*Rsh**3*s**4 + 1.0*Cf*Rf**3*fp**2*s + 0.318309886183791*Cf*Rf**3*fp*s**2 + 0.0253302959105844*Cf*Rf**3*s**3 + 4.0*Cf*Rf**2*Rsh*fp**2*s + 1.27323954473516*Cf*Rf**2*Rsh*fp*s**2 + 0.101321183642338*Cf*Rf**2*Rsh*s**3 + 3.0*Cf*Rf*Rsh**2*fp**2*s + 0.954929658551372*Cf*Rf*Rsh**2*fp*s**2 + 0.0759908877317533*Cf*Rf*Rsh**2*s**3 + 1.0*Cj**3*Rf**2*Rsh**3*fp**2*s**3 + 0.318309886183791*Cj**3*Rf**2*Rsh**3*fp*s**4 + 0.0253302959105844*Cj**3*Rf**2*Rsh**3*s**5 + 3.0*Cj**2*Rf**2*Rsh**2*fp**2*s**2 + 0.954929658551372*Cj**2*Rf**2*Rsh**2*fp*s**3 + 0.0759908877317533*Cj**2*Rf**2*Rsh**2*s**4 + 2.0*Cj**2*Rf*Rsh**3*fp**2*s**2 + 0.636619772367581*Cj**2*Rf*Rsh**3*fp*s**3 + 0.0506605918211689*Cj**2*Rf*Rsh**3*s**4 + 3.0*Cj*Rf**2*Rsh*fp**2*s + 0.954929658551372*Cj*Rf**2*Rsh*fp*s**2 + 0.0759908877317533*Cj*Rf**2*Rsh*s**3 + 4.0*Cj*Rf*Rsh**2*fp**2*s + 1.27323954473516*Cj*Rf*Rsh**2*fp*s**2 + 0.101321183642338*Cj*Rf*Rsh**2*s**3 + 1.0*Cj*Rsh**3*fp**2*s + 0.318309886183791*Cj*Rsh**3*fp*s**2 + 0.0253302959105844*Cj*Rsh**3*s**3 + 1.0*Rf**2*fp**2 + 0.318309886183791*Rf**2*fp*s + 0.0253302959105844*Rf**2*s**2 + 2.0*Rf*Rsh*fp**2 + 0.636619772367581*Rf*Rsh*fp*s + 0.0506605918211689*Rf*Rsh*s**2 + 1.0*Rsh**2*fp**2 + 0.318309886183791*Rsh**2*fp*s + 0.0253302959105844*Rsh**2*s**2)
There is a difference between the maxima code and the python one: const 'pi' is kept symbolic in the first case, and approximated to a floating-point value in the second. Replacing np.pi with pi solves the problem, anyway it is weird how sympy tries to simplify the expression when pi is numeric.

Optimization through Iteration

Hi I am trying to find the minimum value of an objective function which have some constraints, through very basic iterative process. The problem is that due to floating point issue program never terminates. I need accuracy up till 15 decimal digits and I dont want z3 or python to explore any value above that accuracy. Following is the code: the accurate result which I have calculated through Mathematica is: a=1, b=2, c=3, d=4, e=5, f=6 and corresponding minimum value of objective function is: 2.06846*10^-14. Is it possible that I can calculate the same result?
Following is the code: (Please copy paste to run it as expression is very long)
from sympy import*
from z3 import*
#working simple optimization example
# Given formula and set of constraints (cons), find the model that minimize the value of X
# using at-most Max iterations.
def abs(X):
return If(X >= 0,x,-x)
def Opti(cons, X, Max):
#set_option(precision=15)
s = Solver()
s.add(cons)
last_model = None
i = 0
while True:
r = s.check()
if r == unsat:
if last_model != None:
return last_model
else:
return unsat
if r == unknown:
raise Z3Exception("failed")
last_model = s.model()
# if last_model[X]<0:
# last_model[X]=-last_model[X]
s.add(X < last_model[X])
i = i + 1
if (i > Max):
raise Z3Exception("Solution not found, maximum number of iterations was reached")
a = Int('a')
b = Int('b')
c = Int('c')
d = Int('d')
e = Int('e')
f = Int('f')
x = Real('x')
y= Real('y')
X = Real('X')
Y = Real('Y')
cons=[ a>0,b>0,c>0,d>0,e>0,f>0, x== (abs((3608946673948233*d)/4503599627370496 + (274464355232027*e)/2251799813685248 - (274464355232027*e**2)/(4*(562949953421312*e + 562949953421312*f - 5536725273124715)) - 1519633732185043491981133247305/1267650600228229401496703205376) + abs((4636666003778669*b)/9007199254740992 + (1118552746194141*c)/2251799813685248 + (29870012493936382538794142709149*b)/(9007199254740992*(9007199254740992*b + 9007199254740992*c - 6442131581095921)) + (7205863971378845991234609198861*c)/(2251799813685248*(9007199254740992*b + 9007199254740992*c - 6442131581095921)) - (4636666003778669*b*(b + c))/(9007199254740992*b + 9007199254740992*c - 6442131581095921) - (4474210984776564*c*(b + c))/(9007199254740992*b + 9007199254740992*c - 6442131581095921)) + abs((274464355232027*e)/2251799813685248 + (1519633732185043491981133247305*e)/(2251799813685248*(562949953421312*e + 562949953421312*f - 5536725273124715)) - (274464355232027*e*(e + f))/(4*(562949953421312*e + 562949953421312*f - 5536725273124715))) + abs((792979490709637*b)/1125899906842624 - (901702497811663*c)/2251799813685248 + (4891864612675574504296157138923*b)/(1125899906842624*(2251799813685248*b + 2251799813685248*c - 6168967381864879)) - (5562573297146236482969456283777*c)/(2251799813685248*(2251799813685248*b + 2251799813685248*c - 6168967381864879)) - (1585958981419274*b*(b + c))/(2251799813685248*b + 2251799813685248*c - 6168967381864879) + (901702497811663*c*(b + c))/(2251799813685248*b + 2251799813685248*c - 6168967381864879)) + abs((8431533077325893*b)/18014398509481984 - (708586604185451*c)/4503599627370496 + (54368167798740930523060826625213*b)/(18014398509481984*(1125899906842624*b + 1125899906842624*c - 6448194806345241)) - (4569104460954436146783095288691*c)/(4503599627370496*(1125899906842624*b + 1125899906842624*c - 6448194806345241)) - (8431533077325893*b*(b + c))/(16*(1125899906842624*b + 1125899906842624*c - 6448194806345241)) + (708586604185451*c*(b + c))/(4*(1125899906842624*b + 1125899906842624*c - 6448194806345241))) + abs((4474210984776564*c**2)/(9007199254740992*b + 9007199254740992*c - 6442131581095921) - (177126692422487*d)/1125899906842624 - (1118552746194141*c)/2251799813685248 + (4636666003778669*b*c)/(9007199254740992*b + 9007199254740992*c - 6442131581095921) + 7205863971378845991234609198861/20282409603651670423947251286016) + abs((2035957719017013*b**2)/(1024*(140737488355328*b + 140737488355328*c - 2249387656040967)) - (2035957719017013*b)/144115188075855872 - (2035957719017013*a)/144115188075855872 + (2939179565022695*b*c)/(64*(140737488355328*b + 140737488355328*c - 2249387656040967)) + 4579658161378192576066497971571/20282409603651670423947251286016) + abs((5056216978909333*b)/36028797018963968 + (3060017963484179*c)/4503599627370496 + (27994884333529598097197586465095*b)/(36028797018963968*(562949953421312*b + 562949953421312*c - 5536725273124715)) + (16942478794638475145271796383985*c)/(4503599627370496*(562949953421312*b + 562949953421312*c - 5536725273124715)) - (5056216978909333*b*(b + c))/(64*(562949953421312*b + 562949953421312*c - 5536725273124715)) - (3060017963484179*c*(b + c))/(8*(562949953421312*b + 562949953421312*c - 5536725273124715))) + abs((2939179565022695*c**2)/(64*(140737488355328*b + 140737488355328*c - 2249387656040967)) - (2230056655377591*d)/2251799813685248 - (2939179565022695*c)/9007199254740992 + (2035957719017013*b*c)/(1024*(140737488355328*b + 140737488355328*c - 2249387656040967)) + 6611354232449908862093204746065/1267650600228229401496703205376) + abs((3860418273669689*e)/9007199254740992 + (24892729062597149834655331100049*e)/(9007199254740992*(1125899906842624*e + 1125899906842624*f - 6448194806345241)) - (3860418273669689*e*(e + f))/(8*(1125899906842624*e + 1125899906842624*f - 6448194806345241))) + abs((4636666003778669*b**2)/(9007199254740992*b + 9007199254740992*c - 6442131581095921) - (4636666003778669*b)/9007199254740992 - (4636666003778669*a)/9007199254740992 + (4474210984776564*b*c)/(9007199254740992*b + 9007199254740992*c - 6442131581095921) + 29870012493936382538794142709149/81129638414606681695789005144064) + abs((8431533077325893*a)/18014398509481984 + (8431533077325893*b)/18014398509481984 - (8431533077325893*b**2)/(16*(1125899906842624*b + 1125899906842624*c - 6448194806345241)) + (708586604185451*b*c)/(4*(1125899906842624*b + 1125899906842624*c - 6448194806345241)) - 54368167798740930523060826625213/20282409603651670423947251286016) + abs((5981047056487669*e)/9007199254740992 + (13453693419063522919576994335923*e)/(9007199254740992*(140737488355328*e + 140737488355328*f - 2249387656040967)) - (5981047056487669*e*(e + f))/(64*(140737488355328*e + 140737488355328*f - 2249387656040967))) + abs((792979490709637*a)/1125899906842624 + (792979490709637*b)/1125899906842624 - (1585958981419274*b**2)/(2251799813685248*b + 2251799813685248*c - 6168967381864879) + (901702497811663*b*c)/(2251799813685248*b + 2251799813685248*c - 6168967381864879) - 4891864612675574504296157138923/2535301200456458802993406410752) + abs((4461181249195911*e)/9007199254740992 + (27520881610876789415202401309769*e)/(9007199254740992*(2251799813685248*e + 2251799813685248*f - 6168967381864879)) - (4461181249195911*e*(e + f))/(4*(2251799813685248*e + 2251799813685248*f - 6168967381864879))) + abs((708586604185451*c)/4503599627370496 + (5277591482040591*d)/9007199254740992 - (708586604185451*c**2)/(4*(1125899906842624*b + 1125899906842624*c - 6448194806345241)) + (8431533077325893*b*c)/(16*(1125899906842624*b + 1125899906842624*c - 6448194806345241)) - 4569104460954436146783095288691/5070602400912917605986812821504) + abs((2035957719017013*b)/144115188075855872 + (2939179565022695*c)/9007199254740992 + (4579658161378192576066497971571*b)/(144115188075855872*(140737488355328*b + 140737488355328*c - 2249387656040967)) + (6611354232449908862093204746065*c)/(9007199254740992*(140737488355328*b + 140737488355328*c - 2249387656040967)) - (2035957719017013*b*(b + c))/(1024*(140737488355328*b + 140737488355328*c - 2249387656040967)) - (2939179565022695*c*(b + c))/(64*(140737488355328*b + 140737488355328*c - 2249387656040967))) + abs((2230056655377591*d)/2251799813685248 + (5981047056487669*e)/9007199254740992 - (5981047056487669*e**2)/(64*(140737488355328*e + 140737488355328*f - 2249387656040967)) - 13453693419063522919576994335923/1267650600228229401496703205376) + abs((854371257949259*d)/9007199254740992 + (4461181249195911*e)/9007199254740992 - (4461181249195911*e**2)/(4*(2251799813685248*e + 2251799813685248*f - 6168967381864879)) - 27520881610876789415202401309769/20282409603651670423947251286016) + abs((854371257949259*d)/9007199254740992 - (901702497811663*c)/2251799813685248 + (901702497811663*c**2)/(2251799813685248*b + 2251799813685248*c - 6168967381864879) - (1585958981419274*b*c)/(2251799813685248*b + 2251799813685248*c - 6168967381864879) + 5562573297146236482969456283777/5070602400912917605986812821504) + abs((3060017963484179*c**2)/(8*(562949953421312*b + 562949953421312*c - 5536725273124715)) - (3608946673948233*d)/4503599627370496 - (3060017963484179*c)/4503599627370496 + (5056216978909333*b*c)/(64*(562949953421312*b + 562949953421312*c - 5536725273124715)) + 16942478794638475145271796383985/2535301200456458802993406410752) + abs((177126692422487*d)/1125899906842624 - (764299361349167*e)/2251799813685248 + (3057197445396668*e**2)/(9007199254740992*e + 9007199254740992*f - 6442131581095921) + 4923717053158911857783000447807/20282409603651670423947251286016) + abs((5277591482040591*d)/9007199254740992 + (3860418273669689*e)/9007199254740992 - (3860418273669689*e**2)/(8*(1125899906842624*e + 1125899906842624*f - 6448194806345241)) - 24892729062597149834655331100049/10141204801825835211973625643008) + abs((5056216978909333*b**2)/(64*(562949953421312*b + 562949953421312*c - 5536725273124715)) - (5056216978909333*b)/36028797018963968 - (5056216978909333*a)/36028797018963968 + (3060017963484179*b*c)/(8*(562949953421312*b + 562949953421312*c - 5536725273124715)) + 27994884333529598097197586465095/20282409603651670423947251286016) + abs((764299361349167*e)/2251799813685248 + (4923717053158911857783000447807*e)/(2251799813685248*(9007199254740992*e + 9007199254740992*f - 6442131581095921)) - (3057197445396668*e*(e + f))/(9007199254740992*e + 9007199254740992*f - 6442131581095921)))]
SOL= Opti(cons,x , 2)
print SOL

Categories