def test_sqrt(self): from pyaudi import gdual_double as gdual from pyaudi import sqrt x = gdual(2.3, "x",3); y = gdual(1.5, "y",3); p1 = x*x*y - x*y*x*x*x + 3*y*y*y*y*x*y*x; # positive p0 p2 = x*x*y - x*y*x*x*x - 3*y*y*y*y*x*y*x; # negative coefficient self.assertTrue((sqrt(p1)*sqrt(p1) - p1).is_zero(1e-12)) self.assertTrue((sqrt(p2)*sqrt(p2) - p2).is_zero(1e-12))
def test_sqrt(self): from pyaudi import gdual_double as gdual from pyaudi import sqrt x = gdual(2.3, "x", 3) y = gdual(1.5, "y", 3) p1 = x * x * y - x * y * x * x * x + 3 * \ y * y * y * y * x * y * x # positive p0 p2 = x * x * y - x * y * x * x * x - 3 * y * \ y * y * y * x * y * x # negative coefficient self.assertTrue((sqrt(p1) * sqrt(p1) - p1).is_zero(1e-12)) self.assertTrue((sqrt(p2) * sqrt(p2) - p2).is_zero(1e-12))
def some_complex_irrational_f(x, y, z): from pyaudi import exp, log, cos, sin, tan, sqrt, cbrt, cos, sin, tan, acos, asin, atan, cosh, sinh, tanh, acosh, asinh, atanh from pyaudi import abs as gd_abs from pyaudi import sin_and_cos, sinh_and_cosh f = (x + y + z) / 10. retval = exp(f) + log(f) + f**2 + sqrt(f) + cbrt(f) + cos(f) + sin(f) retval += tan(f) + acos(f) + asin(f) + atan(f) + cosh(f) + sinh(f) retval += tanh(f) + acosh(f) + asinh(f) + atanh(f) a = sin_and_cos(f) b = sinh_and_cosh(f) retval += a[0] + a[1] + b[0] + b[1] return retval
def some_complex_irrational_f(x,y,z): from pyaudi import exp, log, cos, sin, tan, sqrt, cbrt, cos, sin, tan, acos, asin, atan, cosh, sinh, tanh, acosh, asinh, atanh from pyaudi import abs as gd_abs from pyaudi import sin_and_cos, sinh_and_cosh f = (x+y+z) / 10. retval = exp(f) + log(f) + f**2 + sqrt(f) + cbrt(f) + cos(f) + sin(f) retval += tan(f) + acos(f) + asin(f) + atan(f) + cosh(f) + sinh(f) retval += tanh(f) + acosh(f) + asinh(f) + atanh(f) a = sin_and_cos(f) b = sinh_and_cosh(f) retval+=a[0]+a[1]+b[0]+b[1] return retval
def do(self, x1, x2): import pyaudi as pd res = x2.sqrt() assert (res == pd.sqrt(x2))