Beispiel #1
0
 def test_get_sos_le_van_barel_1(self):
     polynomial = poly(
         '2*w**2 - 2*z*w + 8*z**2 - 2*y*z + y**2 - 2*y**2*w + y**4 - 4*x*y*z - 4*x**2*z + x**2*y**2 + 2*x**4'
     )
     status, sos = get_sos(polynomial)
     self.assertEqual(status, 'Exact SOS decomposition found.')
     self.assertEqual(expand(sos.as_expr()), expand(polynomial).as_expr())
Beispiel #2
0
 def mildorf_titu_andreescu(self):
     polynomial = poly(
         'a**4*c**2 + b**4*a**2 + c**4*b**2 - a**3*b**2*c - b**3*c**2*a - c**3*a**2*b'
     )
     status, sos = get_sos(polynomial)
     self.assertEqual(status, 'Exact SOS decomposition found.')
     self.assertEqual(expand(sos.as_expr()), expand(polynomial).as_expr())
Beispiel #3
0
 def test_get_sos_1(self):
     polynomial = poly('x**2 + 2*x + 1')
     status, sos = get_sos(polynomial)
     self.assertEqual(status, 'Exact SOS decomposition found.')
     self.assertEqual(expand(sos.as_expr()), expand(polynomial).as_expr())
Beispiel #4
0
 def test_get_sos_odd_2(self):
     polynomial = poly('x**3 + 1')
     status, sos = get_sos(polynomial)
     self.assertEqual(status,
                      'Polynomial has odd degree. Not a sum of squares.')
     self.assertEqual(sos, nan)
Beispiel #5
0
 def test_get_sos_odd_1(self):
     polynomial = poly('abc')
     status, sos = get_sos(polynomial)
     self.assertEqual(status,
                      'Polynomial has odd degree. Not a sum of squares.')
     self.assertEqual(expand(sos.as_poly()), nan)
Beispiel #6
0
 def test_get_sos_choi_lam(self):
     polynomial = poly('1 + y**2*z**2 - 4*x*y*z + x**2*z**2 + x**2*y**2')
     status, sos = get_sos(polynomial)
     self.assertEqual(status, 'Exact SOS decomposition found.')
     self.assertEqual(simplify(sos).as_expr(), expand(polynomial).as_expr())
Beispiel #7
0
 def test_get_sos_choi_lam_2(self):
     polynomial = poly('y**4 + x**2 - 3*x**2*y**2 + x**4*y**2')
     status, sos = get_sos(polynomial)
     self.assertEqual(status, 'Exact SOS decomposition found.')
     self.assertEqual(simplify(sos).as_expr(), polynomial.as_expr())
Beispiel #8
0
 def test_get_sos_motzkin_with_denominator_multiplied_on_left(self):
     polynomial = poly(
         '(1+x**2 + y**2)*(1 + x**2*y**2*(x**2 + y**2) - 3*x**2*y**2)')
     status, sos = get_sos(polynomial)
     self.assertEqual(status, 'Exact SOS decomposition found.')
     self.assertEqual(expand(sos.as_expr()), expand(polynomial).as_expr())
Beispiel #9
0
 def test_get_sos_motzkin(self):
     polynomial = poly('1 + x**2*y**2*(x**2 + y**2) - 3*x**2*y**2')
     status, sos = get_sos(polynomial)
     self.assertEqual(status, 'Exact SOS decomposition found.')
     self.assertEqual(simplify(sos).as_expr(), polynomial.as_expr())
Beispiel #10
0
 def test_get_sos_le_van_barel_0(self):
     polynomial = poly('1 + x**2 + x**4 + x**6')
     status, sos = get_sos(polynomial)
     self.assertEqual(status, 'Exact SOS decomposition found.')
     self.assertEqual(expand(sos.as_expr()), expand(polynomial).as_expr())
Beispiel #11
0
 def test_get_sos_5(self):
     polynomial = poly('(x**2 - 1)**2 * (x**2 + 1) * (x**4 + x**2 + 1)')
     status, sos = get_sos(polynomial)
     self.assertEqual(status, 'Exact SOS decomposition found.')
     self.assertEqual(expand(sos.as_expr()), expand(polynomial).as_expr())
Beispiel #12
0
 def test_get_sos_2(self):
     polynomial = poly('(x**2 + y**2 + z**2)**3 - 3*x**2*y**2*z**2')
     status, sos = get_sos(polynomial)
     self.assertEqual(status, 'Exact SOS decomposition found.')
     self.assertEqual(expand(sos.as_expr()), expand(polynomial).as_expr())