|
33 | 33 |
|
34 | 34 | """
|
35 | 35 | from sympy import (acos, asin, atan, cos, Derivative, Dummy, diff,
|
36 |
| - E, Eq, exp, I, log, pi, Piecewise, Rational, S, sin, sinh, tan, |
| 36 | + E, Eq, exp, I, LambertW, log, pi, Piecewise, Rational, S, sin, sinh, tan, |
37 | 37 | sqrt, symbols, Ei, erfi)
|
38 | 38 |
|
39 | 39 | from sympy.core import Function, Symbol
|
@@ -318,6 +318,11 @@ def test_nth_algebraic():
|
318 | 318 | _ode_solver_test(_get_examples_ode_sol_nth_algebraic())
|
319 | 319 |
|
320 | 320 |
|
| 321 | +@slow |
| 322 | +def test_slow_examples_1st_exact(): |
| 323 | + _ode_solver_test(_get_examples_ode_sol_1st_exact(), run_slow_test=True) |
| 324 | + |
| 325 | + |
321 | 326 | @slow
|
322 | 327 | def test_slow_examples_nth_order_reducible():
|
323 | 328 | _ode_solver_test(_get_examples_ode_sol_nth_order_reducible(), run_slow_test=True)
|
@@ -1284,6 +1289,48 @@ def _get_examples_ode_sol_separable():
|
1284 | 1289 | }
|
1285 | 1290 |
|
1286 | 1291 |
|
| 1292 | +def _get_examples_ode_sol_1st_exact(): |
| 1293 | + # Type: Exact differential equation, p(x,f) + q(x,f)*f' == 0, |
| 1294 | + # where dp/df == dq/dx |
| 1295 | + return { |
| 1296 | + 'hint': "1st_exact", |
| 1297 | + 'func': f(x), |
| 1298 | + 'examples':{ |
| 1299 | + '1st_exact_01': { |
| 1300 | + 'eq': sin(x)*cos(f(x)) + cos(x)*sin(f(x))*f(x).diff(x), |
| 1301 | + 'sol': [Eq(f(x), -acos(C1/cos(x)) + 2*pi), Eq(f(x), acos(C1/cos(x)))], |
| 1302 | + 'slow': True, |
| 1303 | + }, |
| 1304 | + |
| 1305 | + '1st_exact_02': { |
| 1306 | + 'eq': (2*x*f(x) + 1)/f(x) + (f(x) - x)/f(x)**2*f(x).diff(x), |
| 1307 | + 'sol': [Eq(f(x), exp(C1 - x**2 + LambertW(-x*exp(-C1 + x**2))))], |
| 1308 | + 'slow': True, |
| 1309 | + }, |
| 1310 | + |
| 1311 | + '1st_exact_03': { |
| 1312 | + 'eq': 2*x + f(x)*cos(x) + (2*f(x) + sin(x) - sin(f(x)))*f(x).diff(x), |
| 1313 | + 'sol': [Eq(f(x)*sin(x) + cos(f(x)) + x**2 + f(x)**2, C1)], |
| 1314 | + 'slow': True, |
| 1315 | + }, |
| 1316 | + |
| 1317 | + '1st_exact_04': { |
| 1318 | + 'eq': cos(f(x)) - (x*sin(f(x)) - f(x)**2)*f(x).diff(x), |
| 1319 | + 'sol': [Eq(x*cos(f(x)) + f(x)**3/3, C1)], |
| 1320 | + 'slow': True, |
| 1321 | + }, |
| 1322 | + |
| 1323 | + '1st_exact_05': { |
| 1324 | + 'eq': 2*x*f(x) + (x**2 + f(x)**2)*f(x).diff(x), |
| 1325 | + 'sol': [Eq(x**2*f(x) + f(x)**3/3, C1)], |
| 1326 | + # 'sol':[Eq(f(x), 2**Rational(1, 3)*(x**2/(-3*C1 + sqrt(9*C1**2 + 4*x**6))**Rational(1, 3) - 2**Rational(1, 3)*(-3*C1 + sqrt(9*C1**2 + 4*x**6))**Rational(1, 3)/2)), Eq(f(x), 2**Rational(1, 3)*(2*x**2/((-1 - sqrt(3)*I)*(-3*C1 + sqrt(9*C1**2 + 4*x**6))**Rational(1, 3)) + 2**Rational(1, 3)*(-3*C1 + sqrt(9*C1**2 + 4*x**6))**Rational(1, 3)/4 + 2**Rational(1, 3)*sqrt(3)*I*(-3*C1 + sqrt(9*C1**2 + 4*x**6))**Rational(1, 3)/4)), |
| 1327 | + # Eq(f(x), 2**Rational(1, 3)*(2*x**2/((-1 + sqrt(3)*I)*(-3*C1 + sqrt(9*C1**2 + 4*x**6))**Rational(1, 3)) + 2**Rational(1, 3)*(-3*C1 + sqrt(9*C1**2 + 4*x**6))**Rational(1, 3)/4 - 2**Rational(1, 3)*sqrt(3)*I*(-3*C1 + sqrt(9*C1**2 + 4*x**6))**Rational(1, 3)/4))], |
| 1328 | + 'slow': True, |
| 1329 | + }, |
| 1330 | + } |
| 1331 | + } |
| 1332 | + |
| 1333 | + |
1287 | 1334 | def _get_all_examples():
|
1288 | 1335 | all_solvers = [_get_examples_ode_sol_euler_homogeneous(),
|
1289 | 1336 | _get_examples_ode_sol_euler_undetermined_coeff(),
|
|
0 commit comments