python - Possible bug in Sympy library working with imaginary numbers when there are not any -


I tried to do the regula falsi method in Python using the Simpi library, though I There are some functions found that an issue is telling me that I am working with fictitious numbers.

This is my code:

  DIF reagla falsa (Fx, P, P1, millennium, Iteracy Maxima): Fx = S (Fx) I = 2 q0 = Fx (X, p0) q1 = fx.subs (x, p1) while i & lt; = IteracionesMaximas: p = p1 - q1 * (p1-p0) / (q1-q0) if full (p-p1) & lt; Tolerance: Return p q = fx.subs (x, p) if (q ** q1) & lt; 0: p0 = p q0 = q other: p1 = p q1 = qi + = 1 return p  

I called it with the following arguments:

Fx = 3 * x + sin (x) -2.71828182846 ** x, pO = 0.0, p1 = 2.0, millennium = .0001, iTreasinemaximus = 15

and

< P> fx = 2 * x ** 2 + x-1, po = 0.0, p1 = 1.0, tolerancia = .0001, iteracionesMaximas = 15

Sin ( X) As argument, I get NaN on some variables

I am using the following traceback:

  Traceback (Most recent call final): File "../Prakcticas/python/ReglaFalsa.py", type Finance 16, & lt; Module & gt; Print json.dumps (reglafalsa (y, a, b, tolerancia, iteraciones maximas), indent = 1) file "/home/diegoaguilar/Copy/buap/Métodos/Prakcticas/python/reglafalsa.py", line 45, in Regal Falsa if (Q ** q1) & lt; 0: file "/usr/local/lib/python2.7/dist-packages/sympy/core/decorators.py", in line 77, __sympifyit_wrapper return func (A, B) file "/ usr / local / lib / python2 Type__rty__ (Comparative comparison of "complex% s"% dif) TypeError: Compared 0.0114119631147945 - 0.179219618952309 * Invalid comparison compared to .7 / dist-packages / sympy / core / expr.py ", line 248, / change exponentiation (leading to complex results)  
  q  
  

to multiply

  q * q1 & lt; 0:  

Or find another way to compare signals, for example, is the signbite function.


Comments

Popular posts from this blog

Removing From ArrayList, In Loop Based On It's Size, But Breaking After Remove Still Gives OutOfBounds -

c# - Reactive Extensions ControlScheduler -

java - Add color code support to a Bukkit plugin -