def test_pde_1st_linear_constant_coeff_homogeneous(): f, F = map(Function, ['f', 'F']) u = f(x, y) eq = 2 * u + u.diff(x) + u.diff(y) assert classify_pde(eq) == ('1st_linear_constant_coeff_homogeneous', ) sol = pdsolve(eq) assert sol == Eq(u, F(x - y) * exp(-x - y)) assert checkpdesol(eq, sol)[0] eq = 4 + (3 * u.diff(x) / u) + (2 * u.diff(y) / u) assert classify_pde(eq) == ('1st_linear_constant_coeff_homogeneous', ) sol = pdsolve(eq) assert sol == Eq(u, F(2 * x - 3 * y) * exp(-S(12) * x / 13 - S(8) * y / 13)) assert checkpdesol(eq, sol)[0] eq = u + (6 * u.diff(x)) + (7 * u.diff(y)) assert classify_pde(eq) == ('1st_linear_constant_coeff_homogeneous', ) sol = pdsolve(eq) assert sol == Eq(u, F(7 * x - 6 * y) * exp(-6 * x / S(85) - 7 * y / S(85))) assert checkpdesol(eq, sol)[0] eq = a * u + b * u.diff(x) + c * u.diff(y) sol = pdsolve(eq) assert checkpdesol(eq, sol)[0]
def test_pde_1st_linear_constant_coeff(): f, F = map(Function, ["f", "F"]) u = f(x, y) eq = -2 * u.diff(x) + 4 * u.diff(y) + 5 * u - exp(x + 3 * y) sol = pdsolve(eq) assert sol == Eq(f(x, y), (F(4 * x + 2 * y) + exp(x / S(2) + 4 * y) / S(15)) * exp(x / S(2) - y)) assert classify_pde(eq) == ("1st_linear_constant_coeff", "1st_linear_constant_coeff_Integral") assert checkpdesol(eq, sol)[0] eq = (u.diff(x) / u) + (u.diff(y) / u) + 1 - (exp(x + y) / u) sol = pdsolve(eq) assert sol == Eq(f(x, y), F(x - y) * exp(-x / 2 - y / 2) + exp(x + y) / S(3)) assert classify_pde(eq) == ("1st_linear_constant_coeff", "1st_linear_constant_coeff_Integral") assert checkpdesol(eq, sol)[0] eq = 2 * u + -u.diff(x) + 3 * u.diff(y) + sin(x) sol = pdsolve(eq) assert sol == Eq(f(x, y), F(3 * x + y) * exp(x / S(5) - 3 * y / S(5)) - 2 * sin(x) / S(5) - cos(x) / S(5)) assert classify_pde(eq) == ("1st_linear_constant_coeff", "1st_linear_constant_coeff_Integral") assert checkpdesol(eq, sol)[0] eq = u + u.diff(x) + u.diff(y) + x * y sol = pdsolve(eq) assert sol == Eq(f(x, y), -x * y + x + y + F(x - y) * exp(-x / S(2) - y / S(2)) - 2) assert classify_pde(eq) == ("1st_linear_constant_coeff", "1st_linear_constant_coeff_Integral") assert checkpdesol(eq, sol)[0] eq = u + u.diff(x) + u.diff(y) + log(x) assert classify_pde(eq) == ("1st_linear_constant_coeff", "1st_linear_constant_coeff_Integral")
def test_pde_1st_linear_constant_coeff(): f, F = map(Function, ["f", "F"]) u = f(x, y) eq = -2 * u.diff(x) + 4 * u.diff(y) + 5 * u - exp(x + 3 * y) sol = pdsolve(eq) assert sol == Eq(f(x, y), (F(4 * x + 2 * y) + exp(x / S(2) + 4 * y) / S(15)) * exp(x / S(2) - y)) assert classify_pde(eq) == ( "1st_linear_constant_coeff", "1st_linear_constant_coeff_Integral", ) assert checkpdesol(eq, sol)[0] eq = (u.diff(x) / u) + (u.diff(y) / u) + 1 - (exp(x + y) / u) sol = pdsolve(eq) assert sol == Eq(f(x, y), F(x - y) * exp(-x / 2 - y / 2) + exp(x + y) / S(3)) assert classify_pde(eq) == ( "1st_linear_constant_coeff", "1st_linear_constant_coeff_Integral", ) assert checkpdesol(eq, sol)[0] eq = 2 * u + -u.diff(x) + 3 * u.diff(y) + sin(x) sol = pdsolve(eq) assert sol == Eq( f(x, y), F(3 * x + y) * exp(x / S(5) - 3 * y / S(5)) - 2 * sin(x) / S(5) - cos(x) / S(5), ) assert classify_pde(eq) == ( "1st_linear_constant_coeff", "1st_linear_constant_coeff_Integral", ) assert checkpdesol(eq, sol)[0] eq = u + u.diff(x) + u.diff(y) + x * y sol = pdsolve(eq) assert sol == Eq(f(x, y), -x * y + x + y + F(x - y) * exp(-x / S(2) - y / S(2)) - 2) assert classify_pde(eq) == ( "1st_linear_constant_coeff", "1st_linear_constant_coeff_Integral", ) assert checkpdesol(eq, sol)[0] eq = u + u.diff(x) + u.diff(y) + log(x) assert classify_pde(eq) == ( "1st_linear_constant_coeff", "1st_linear_constant_coeff_Integral", )
def test_pde_classify(): # When more number of hints are added, add tests for classifying here. f = Function('f') eq1 = a * f(x, y) + b * f(x, y).diff(x) + c * f(x, y).diff(y) eq2 = 3 * f(x, y) + 2 * f(x, y).diff(x) + f(x, y).diff(y) eq3 = a * f(x, y) + b * f(x, y).diff(x) + 2 * f(x, y).diff(y) eq4 = x * f(x, y) + f(x, y).diff(x) + 3 * f(x, y).diff(y) eq5 = x**2 * f(x, y) + x * f(x, y).diff(x) + x * y * f(x, y).diff(y) eq6 = y * x**2 * f(x, y) + y * f(x, y).diff(x) + f(x, y).diff(y) for eq in [eq1, eq2, eq3]: assert classify_pde(eq) == ('1st_linear_constant_coeff_homogeneous', ) for eq in [eq4, eq5, eq6]: assert classify_pde(eq) == ()
def test_pde_classify(): # When more number of hints are added, add tests for classifying here. f = Function("f") eq1 = a * f(x, y) + b * f(x, y).diff(x) + c * f(x, y).diff(y) eq2 = 3 * f(x, y) + 2 * f(x, y).diff(x) + f(x, y).diff(y) eq3 = a * f(x, y) + b * f(x, y).diff(x) + 2 * f(x, y).diff(y) eq4 = x * f(x, y) + f(x, y).diff(x) + 3 * f(x, y).diff(y) eq5 = x ** 2 * f(x, y) + x * f(x, y).diff(x) + x * y * f(x, y).diff(y) eq6 = y * x ** 2 * f(x, y) + y * f(x, y).diff(x) + f(x, y).diff(y) for eq in [eq1, eq2, eq3]: assert classify_pde(eq) == ("1st_linear_constant_coeff_homogeneous",) for eq in [eq4, eq5, eq6]: assert classify_pde(eq) == ()
def test_pde_1st_linear_constant_coeff(): f, F = map(Function, ['f', 'F']) u = f(x, y) eq = -2 * u.diff(x) + 4 * u.diff(y) + 5 * u - exp(x + 3 * y) sol = pdsolve(eq) assert sol == Eq(f( x, y), (F(4 * x + 2 * y) * exp(x / 2) + exp(x + 4 * y) / 15) * exp(-y)) assert classify_pde(eq) == ('1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral') assert checkpdesol(eq, sol)[0] eq = (u.diff(x) / u) + (u.diff(y) / u) + 1 - (exp(x + y) / u) sol = pdsolve(eq) assert sol == Eq(f(x, y), F(x - y) * exp(-x / 2 - y / 2) + exp(x + y) / 3) assert classify_pde(eq) == ('1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral') assert checkpdesol(eq, sol)[0] eq = 2 * u + -u.diff(x) + 3 * u.diff(y) + sin(x) sol = pdsolve(eq) assert sol == Eq( f(x, y), F(3 * x + y) * exp(x / 5 - 3 * y / 5) - 2 * sin(x) / 5 - cos(x) / 5) assert classify_pde(eq) == ('1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral') assert checkpdesol(eq, sol)[0] eq = u + u.diff(x) + u.diff(y) + x * y sol = pdsolve(eq) assert sol.expand() == Eq( f(x, y), x + y + (x - y)**2 / 4 - (x + y)**2 / 4 + F(x - y) * exp(-x / 2 - y / 2) - 2).expand() assert classify_pde(eq) == ('1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral') assert checkpdesol(eq, sol)[0] eq = u + u.diff(x) + u.diff(y) + log(x) assert classify_pde(eq) == ('1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral')
def test_pde_1st_linear_constant_coeff_homogeneous(): f, F = map(Function, ["f", "F"]) u = f(x, y) eq = 2 * u + u.diff(x) + u.diff(y) assert classify_pde(eq) == ("1st_linear_constant_coeff_homogeneous",) sol = pdsolve(eq) assert sol == Eq(u, F(x - y) * exp(-x - y)) assert checkpdesol(eq, sol)[0] eq = 4 + (3 * u.diff(x) / u) + (2 * u.diff(y) / u) assert classify_pde(eq) == ("1st_linear_constant_coeff_homogeneous",) sol = pdsolve(eq) assert sol == Eq(u, F(2 * x - 3 * y) * exp(-S(12) * x / 13 - S(8) * y / 13)) assert checkpdesol(eq, sol)[0] eq = u + (6 * u.diff(x)) + (7 * u.diff(y)) assert classify_pde(eq) == ("1st_linear_constant_coeff_homogeneous",) sol = pdsolve(eq) assert sol == Eq(u, F(7 * x - 6 * y) * exp(-6 * x / S(85) - 7 * y / S(85))) assert checkpdesol(eq, sol)[0] eq = a * u + b * u.diff(x) + c * u.diff(y) sol = pdsolve(eq) assert checkpdesol(eq, sol)[0]