32
32
ODEs which raises exception.
33
33
34
34
"""
35
- from sympy import (acos , asin , atan , cos , Derivative , Dummy , diff ,
35
+ from sympy import (acos , asin , asinh , atan , cos , Derivative , Dummy , diff ,
36
36
E , Eq , exp , I , Integral , integrate , LambertW , log , pi , Piecewise , Rational , S , sin , sinh , tan ,
37
37
sqrt , symbols , Ei , erfi )
38
38
46
46
47
47
from sympy .solvers .ode .subscheck import checkodesol
48
48
49
- from sympy .testing .pytest import raises , slow
49
+ from sympy .testing .pytest import raises , slow , ON_TRAVIS
50
50
import traceback
51
51
52
52
@@ -151,7 +151,9 @@ def _ode_solver_test(ode_examples, run_slow_test=False):
151
151
'example_name' : example ,
152
152
'slow' : ode_examples ['examples' ][example ].get ('slow' , False ),
153
153
'simplify_flag' :ode_examples ['examples' ][example ].get ('simplify_flag' ,True ),
154
- 'checkodesol_XFAIL' : ode_examples ['examples' ][example ].get ('checkodesol_XFAIL' , False )
154
+ 'checkodesol_XFAIL' : ode_examples ['examples' ][example ].get ('checkodesol_XFAIL' , False ),
155
+ 'dsolve_too_slow' :ode_examples ['examples' ][example ].get ('dsolve_too_slow' ,False ),
156
+ 'checkodesol_too_slow' :ode_examples ['examples' ][example ].get ('checkodesol_too_slow' ,False ),
155
157
}
156
158
if (not run_slow_test ) and temp ['slow' ]:
157
159
continue
@@ -194,6 +196,8 @@ def _test_particular_example(our_hint, ode_example, solver_flag=False):
194
196
result = {'msg' : '' , 'xpass_msg' : '' }
195
197
simplify_flag = ode_example ['simplify_flag' ]
196
198
checkodesol_XFAIL = ode_example ['checkodesol_XFAIL' ]
199
+ dsolve_too_slow = ode_example ['dsolve_too_slow' ]
200
+ checkodesol_too_slow = ode_example ['checkodesol_too_slow' ]
197
201
xpass = True
198
202
if solver_flag :
199
203
if our_hint not in classify_ode (eq , func ):
@@ -203,7 +207,10 @@ def _test_particular_example(our_hint, ode_example, solver_flag=False):
203
207
if our_hint in classify_ode (eq , func ):
204
208
result ['match_list' ] = example
205
209
try :
206
- dsolve_sol = dsolve (eq , func , simplify = simplify_flag ,hint = our_hint )
210
+ if not (dsolve_too_slow and ON_TRAVIS ):
211
+ dsolve_sol = dsolve (eq , func , simplify = simplify_flag ,hint = our_hint )
212
+ else :
213
+ dsolve_sol = expected_sol
207
214
208
215
except Exception as e :
209
216
dsolve_sol = []
@@ -237,16 +244,17 @@ def _test_particular_example(our_hint, ode_example, solver_flag=False):
237
244
if len (expected_sol ) == 1 :
238
245
expected_checkodesol = (True , 0 )
239
246
240
- if not checkodesol_XFAIL :
241
- if checkodesol (eq , dsolve_sol , solve_for_func = False ) != expected_checkodesol :
242
- result ['unsolve_list' ] = example
243
- xpass = False
244
- message = dsol_incorrect_msg .format (hint = our_hint , eq = eq , sol = expected_sol ,dsolve_sol = dsolve_sol )
245
- if solver_flag :
246
- message = checkodesol_msg .format (example = example , eq = eq )
247
- raise AssertionError (message )
248
- else :
249
- result ['msg' ] = 'AssertionError: ' + message
247
+ if not (checkodesol_too_slow and ON_TRAVIS ):
248
+ if not checkodesol_XFAIL :
249
+ if checkodesol (eq , dsolve_sol , solve_for_func = False ) != expected_checkodesol :
250
+ result ['unsolve_list' ] = example
251
+ xpass = False
252
+ message = dsol_incorrect_msg .format (hint = our_hint , eq = eq , sol = expected_sol ,dsolve_sol = dsolve_sol )
253
+ if solver_flag :
254
+ message = checkodesol_msg .format (example = example , eq = eq )
255
+ raise AssertionError (message )
256
+ else :
257
+ result ['msg' ] = 'AssertionError: ' + message
250
258
251
259
if xpass and xfail :
252
260
result ['xpass_msg' ] = example + "is now passing for the hint" + our_hint
@@ -1312,6 +1320,15 @@ def _get_examples_ode_sol_separable():
1312
1320
def _get_examples_ode_sol_1st_exact ():
1313
1321
# Type: Exact differential equation, p(x,f) + q(x,f)*f' == 0,
1314
1322
# where dp/df == dq/dx
1323
+ '''
1324
+ Example 7 is an exact equation that fails under the exact engine. It is caught
1325
+ by first order homogeneous albeit with a much contorted solution. The
1326
+ exact engine fails because of a poorly simplified integral of q(0,y)dy,
1327
+ where q is the function multiplying f'. The solutions should be
1328
+ Eq(sqrt(x**2+f(x)**2)**3+y**3, C1). The equation below is
1329
+ equivalent, but it is so complex that checkodesol fails, and takes a long
1330
+ time to do so.
1331
+ '''
1315
1332
return {
1316
1333
'hint' : "1st_exact" ,
1317
1334
'func' : f (x ),
@@ -1356,6 +1373,20 @@ def _get_examples_ode_sol_1st_exact():
1356
1373
'sol' : [Eq (x * cos (f (x )) + f (x )** 3 / 3 , C1 )],
1357
1374
'simplify_flag' :False
1358
1375
},
1376
+
1377
+ '1st_exact_07' : {
1378
+ 'eq' : x * sqrt (x ** 2 + f (x )** 2 ) - (x ** 2 * f (x )/ (f (x ) - sqrt (x ** 2 + f (x )** 2 )))* f (x ).diff (x ),
1379
+ 'sol' : [Eq (log (x ),
1380
+ C1 - 9 * sqrt (1 + f (x )** 2 / x ** 2 )* asinh (f (x )/ x )/ (- 27 * f (x )/ x +
1381
+ 27 * sqrt (1 + f (x )** 2 / x ** 2 )) - 9 * sqrt (1 + f (x )** 2 / x ** 2 )*
1382
+ log (1 - sqrt (1 + f (x )** 2 / x ** 2 )* f (x )/ x + 2 * f (x )** 2 / x ** 2 )/
1383
+ (- 27 * f (x )/ x + 27 * sqrt (1 + f (x )** 2 / x ** 2 )) +
1384
+ 9 * asinh (f (x )/ x )* f (x )/ (x * (- 27 * f (x )/ x + 27 * sqrt (1 + f (x )** 2 / x ** 2 ))) +
1385
+ 9 * f (x )* log (1 - sqrt (1 + f (x )** 2 / x ** 2 )* f (x )/ x + 2 * f (x )** 2 / x ** 2 )/
1386
+ (x * (- 27 * f (x )/ x + 27 * sqrt (1 + f (x )** 2 / x ** 2 ))))],
1387
+ 'slow' : True ,
1388
+ 'dsolve_too_slow' :True
1389
+ },
1359
1390
}
1360
1391
}
1361
1392
0 commit comments