Skip to content

Commit cab6171

Browse files
committed
matrices: set the default value for dotprodsimp to None
Simplify excessively complicated ODE system test. This test has a solution that is too complicated to write out explicitly in the code. It also takes too long for checkodesol to verify the solution. Instead we check that the solution holds for t=1.
1 parent 262134e commit cab6171

File tree

1 file changed

+13
-50
lines changed

1 file changed

+13
-50
lines changed

sympy/solvers/ode/tests/test_systems.py

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
_eqs2dict, _dict2graph)
1414
from sympy.functions import airyai, airybi
1515
from sympy.integrals.integrals import Integral
16+
from sympy.simplify.ratsimp import ratsimp
1617
from sympy.testing.pytest import ON_TRAVIS, raises, slow, skip, XFAIL
1718

1819

@@ -2173,60 +2174,22 @@ def test_dsolve():
21732174
dsolve(eqs)
21742175

21752176

2176-
def _higher_order_slow1():
2177+
@slow
2178+
def test_higher_order1_slow1():
21772179
x, y = symbols("x y", cls=Function)
21782180
t = symbols("t")
21792181

2180-
eq = (Eq(diff(x(t),t,t), (log(t)+t**2)*diff(x(t),t)+(log(t)+t**2)*3*diff(y(t),t)), Eq(diff(y(t),t,t), \
2181-
(log(t)+t**2)*2*diff(x(t),t)+(log(t)+t**2)*9*diff(y(t),t)))
2182-
_x1 = log(t)**2
2183-
_x2 = sqrt(22)
2184-
_x3 = sqrt(9*_x1 + t**4 + 6*t**2*log(t) - 6*t**2 - 18*log(t) + 9)
2185-
_x4 = 1/(-_x2*_x3*t/3 - 4*t**3/3 - 4*t*log(t) + 4*t)
2186-
_x5 = 1/(_x2*_x3*t/3 - 4*t**3/3 - 4*t*log(t) + 4*t)
2187-
_x6 = 1/(-_x4*t**3 - 3*_x4*t*log(t) + 3*_x4*t + _x5*t**3 + 3*_x5*t*log(t) - 3*_x5*t)
2188-
_x7 = exp(-_x2*_x3*t/3 + 5*t**3/3 + 5*t*log(t) - 5*t)
2189-
_x8 = exp(_x2*_x3*t/3 + 5*t**3/3 + 5*t*log(t) - 5*t)
2190-
_x9 = 1/(18*_x1*_x4*t**5 - 54*_x1*_x4*t**3 - 18*_x1*_x5*t**5 + 54*_x1*_x5*t**3 + 2*_x4*t**9/3 + 6*_x4*t**7*log(t) -
2191-
6*_x4*t**7 - 36*_x4*t**5*log(t) + 18*_x4*t**5 + 18*_x4*t**3*log(t)**3 + 54*_x4*t**3*log(t) - 18*_x4*t**3 -
2192-
2*_x5*t**9/3 - 6*_x5*t**7*log(t) + 6*_x5*t**7 + 36*_x5*t**5*log(t) - 18*_x5*t**5 - 18*_x5*t**3*log(t)**3 -
2193-
54*_x5*t**3*log(t) + 18*_x5*t**3)
2194-
_x10 = -12*_x1*_x5*t**2
2195-
_x11 = 24*_x5*t**2*log(t)
2196-
_x12 = 8*_x4*t**4*log(t)
2197-
_x13 = -24*_x4*t**2*log(t)
2198-
_x14 = -8*_x5*t**4*log(t)
2199-
_x15 = 1/(12*_x1*_x4*t**2 + _x10 + _x11 + _x12 + _x13 + _x14 + _x2*_x3*_x4*t**4/3 + _x2*_x3*_x4*t**2*log(t) -
2200-
_x2*_x3*_x4*t**2 - _x2*_x3*_x5*t**4/3 - _x2*_x3*_x5*t**2*log(t) + _x2*_x3*_x5*t**2 + 4*_x4*t**6/3 -
2201-
8*_x4*t**4 + 12*_x4*t**2 - 4*_x5*t**6/3 + 8*_x5*t**4 - 12*_x5*t**2)
2202-
_x16 = 1/(12*_x1*_x4*t**2 + _x10 + _x11 + _x12 + _x13 + _x14 - _x2*_x3*_x4*t**4/3 - _x2*_x3*_x4*t**2*log(t) +
2203-
_x2*_x3*_x4*t**2 + _x2*_x3*_x5*t**4/3 + _x2*_x3*_x5*t**2*log(t) - _x2*_x3*_x5*t**2 + 4*_x4*t**6/3 -
2204-
8*_x4*t**4 + 12*_x4*t**2 - 4*_x5*t**6/3 + 8*_x5*t**4 - 12*_x5*t**2)
2205-
_x17 = (t**3 + 3*t*log(t) - 3*t)**2
2206-
sol = [
2207-
Eq(x(t), C1 + Integral(-C2*_x15*_x8*t**3 - 3*C2*_x15*_x8*t*log(t) + 3*C2*_x15*_x8*t + C2*_x16*_x7*t**3 +
2208-
3*C2*_x16*_x7*t*log(t) - 3*C2*_x16*_x7*t + C3*_x17*_x7*_x9 - C3*_x17*_x8*_x9, t)),
2209-
Eq(y(t), C4 + Integral(-C2*_x6*_x7 + C2*_x6*_x8 - C3*_x15*_x7*t**3 - 3*C3*_x15*_x7*t*log(t) + 3*C3*_x15*_x7*t +
2210-
C3*_x16*_x8*t**3 + 3*C3*_x16*_x8*t*log(t) - 3*C3*_x16*_x8*t, t)),
2182+
eq = [
2183+
Eq(diff(x(t),t,t), (log(t)+t**2)*diff(x(t),t)+(log(t)+t**2)*3*diff(y(t),t)),
2184+
Eq(diff(y(t),t,t), (log(t)+t**2)*2*diff(x(t),t)+(log(t)+t**2)*9*diff(y(t),t))
22112185
]
2212-
2213-
return eq, sol
2214-
2215-
2216-
@slow
2217-
def test_higher_order_slow1():
2218-
eq, sol = _higher_order_slow1()
2219-
2220-
assert dsolve_system(eq, simplify=False, doit=False) == [sol]
2221-
2222-
2223-
@slow
2224-
def test_higher_order1_slow1_check():
2225-
if ON_TRAVIS:
2226-
skip("Too slow for travis.")
2227-
2228-
eq, sol = _higher_order_slow1()
2229-
assert checksysodesol(eq, sol) == (True, [0, 0])
2186+
sol, = dsolve_system(eq, simplify=False, doit=False)
2187+
# The solution is too long to write out explicitly and checkodesol is too
2188+
# slow so we test for particular values of t:
2189+
for e in eq:
2190+
res = (e.lhs - e.rhs).subs({sol[0].lhs:sol[0].rhs, sol[1].lhs:sol[1].rhs})
2191+
res = res.subs({d: d.doit(deep=False) for d in res.atoms(Derivative)})
2192+
assert ratsimp(res.subs(t, 1)) == 0
22302193

22312194

22322195
@slow

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy