Utilities for solving

General utility functions for solvers.

diofant.solvers.utils.checksol(f, sol, **flags)[source]

Checks whether sol is a solution of equations f.

Examples

>>> checksol(x**4 - 1, {x: 1})
True
>>> checksol(x**4 - 1, {x: 0})
False
>>> checksol(x**2 + y**2 - 5**2, {x: 3, y: 4})
True
Returns:

bool or None – Return True, if solution satisfy all equations in f. Return False, if a solution doesn’t satisfy any equation. Else (i.e. one or more checks are inconclusive), return None.

Parameters:
  • f (Expr or iterable of Expr’s) – Equations to substitute solutions in.

  • sol (dict of Expr’s) – Mapping of symbols to values.

  • **flags (dict) – A dictionary of following parameters:

    minimalbool, optional

    Do a very fast, minimal testing. Default is False.

    warnbool, optional

    Show a warning if it could not conclude. Default is False.

    simplifybool, optional

    Simplify solution before substituting into function and simplify the function before trying specific simplifications. Default is True.

    forcebool, optional

    Make positive all symbols without assumptions regarding sign. Default is False.

Utility functions for classifying and solving ordinary and partial differential equations.

Contains

_preprocess ode_order _desolve

diofant.solvers.deutils.ode_order(expr, func)[source]

Returns the order of a given differential equation with respect to func.

This function is implemented recursively.

Examples

>>> ode_order(f(x).diff((x, 2)) + f(x).diff(x)**2 +
...           f(x).diff(x), f(x))
2
>>> ode_order(f(x).diff((x, 2)) + g(x).diff((x, 3)), f(x))
2
>>> ode_order(f(x).diff((x, 2)) + g(x).diff((x, 3)), g(x))
3