K i7*dZddlmZmZmZmZmZddlmZddl m Z m Z ddl m Z mZmZmZmZmZmZddlmZddlmZmZmZddlmZmZdd lmZmZdd l m!Z!m"Z"m#Z#m$Z$dd l%m&Z&dd l'm(Z(dd l)m*Z*m+Z+m,Z,ddl-m.Z.m/Z/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9ddl:m;Z;ddlm?Z?ddl@mAZAmBZBmCZCmDZDmEZEmFZFddlGmHZHddlImJZJmKZKddlLmMZMddlNmOZOmPZPmQZQddlRmSZSmTZTmUZUdZVdLdZWdMdZX dNd!ZYdOd"ZZd#Z[dPd dddd$d%Z\dQd&Z]d'Z^d(Z_d)Z`d*Zad+Zbedd,ZcdRd-Zdd.Zed/Zfd0Zgedd1ZhdSd2Zid3Zjd4Zkd5Zld6ZmdQd7Znd8Zod9Zpd:ZqdSd;Zrd<Zsd=Ztd>Zud?Zvd@ZwdAZxdBZydCZzdDZ{dEZ|dFZ}dGZ~dHZdIZdJZddKlmZmZmZy)Ta4 This module contains :py:meth:`~sympy.solvers.ode.dsolve` and different helper functions that it uses. :py:meth:`~sympy.solvers.ode.dsolve` solves ordinary differential equations. See the docstring on the various functions for their uses. Note that partial differential equations support is in ``pde.py``. Note that hint functions have docstrings describing their various methods, but they are intended for internal use. Use ``dsolve(ode, func, hint=hint)`` to solve an ODE using a specific hint. See also the docstring on :py:meth:`~sympy.solvers.ode.dsolve`. **Functions in this module** These are the user functions in this module: - :py:meth:`~sympy.solvers.ode.dsolve` - Solves ODEs. - :py:meth:`~sympy.solvers.ode.classify_ode` - Classifies ODEs into possible hints for :py:meth:`~sympy.solvers.ode.dsolve`. - :py:meth:`~sympy.solvers.ode.checkodesol` - Checks if an equation is the solution to an ODE. - :py:meth:`~sympy.solvers.ode.homogeneous_order` - Returns the homogeneous order of an expression. - :py:meth:`~sympy.solvers.ode.infinitesimals` - Returns the infinitesimals of the Lie group of point transformations of an ODE, such that it is invariant. - :py:meth:`~sympy.solvers.ode.checkinfsol` - Checks if the given infinitesimals are the actual infinitesimals of a first order ODE. These are the non-solver helper functions that are for internal use. The user should use the various options to :py:meth:`~sympy.solvers.ode.dsolve` to obtain the functionality provided by these functions: - :py:meth:`~sympy.solvers.ode.ode.odesimp` - Does all forms of ODE simplification. - :py:meth:`~sympy.solvers.ode.ode.ode_sol_simplicity` - A key function for comparing solutions by simplicity. - :py:meth:`~sympy.solvers.ode.constantsimp` - Simplifies arbitrary constants. - :py:meth:`~sympy.solvers.ode.ode.constant_renumber` - Renumber arbitrary constants. - :py:meth:`~sympy.solvers.ode.ode._handle_Integral` - Evaluate unevaluated Integrals. See also the docstrings of these functions. **Currently implemented solver methods** The following methods are implemented for solving ordinary differential equations. See the docstrings of the various hint functions for more information on each (run ``help(ode)``): - 1st order separable differential equations. - 1st order differential equations whose coefficients or `dx` and `dy` are functions homogeneous of the same order. - 1st order exact differential equations. - 1st order linear differential equations. - 1st order Bernoulli differential equations. - Power series solutions for first order differential equations. - Lie Group method of solving first order differential equations. - 2nd order Liouville differential equations. - Power series solutions for second order differential equations at ordinary and regular singular points. - `n`\th order differential equation that can be solved with algebraic rearrangement and integration. - `n`\th order linear homogeneous differential equation with constant coefficients. - `n`\th order linear inhomogeneous differential equation with constant coefficients using the method of undetermined coefficients. - `n`\th order linear inhomogeneous differential equation with constant coefficients using the method of variation of parameters. **Philosophy behind this module** This module is designed to make it easy to add new ODE solving methods without having to mess with the solving code for other methods. The idea is that there is a :py:meth:`~sympy.solvers.ode.classify_ode` function, which takes in an ODE and tells you what hints, if any, will solve the ODE. It does this without attempting to solve the ODE, so it is fast. Each solving method is a hint, and it has its own function, named ``ode_``. That function takes in the ODE and any match expression gathered by :py:meth:`~sympy.solvers.ode.classify_ode` and returns a solved result. If this result has any integrals in it, the hint function will return an unevaluated :py:class:`~sympy.integrals.integrals.Integral` class. :py:meth:`~sympy.solvers.ode.dsolve`, which is the user wrapper function around all of this, will then call :py:meth:`~sympy.solvers.ode.ode.odesimp` on the result, which, among other things, will attempt to solve the equation for the dependent variable (the function we are solving for), simplify the arbitrary constants in the expression, and evaluate any integrals, if the hint allows it. **How to add new solution methods** If you have an ODE that you want :py:meth:`~sympy.solvers.ode.dsolve` to be able to solve, try to avoid adding special case code here. Instead, try finding a general method that will solve your ODE, as well as others. This way, the :py:mod:`~sympy.solvers.ode` module will become more robust, and unhindered by special case hacks. WolphramAlpha and Maple's DETools[odeadvisor] function are two resources you can use to classify a specific ODE. It is also better for a method to work with an `n`\th order ODE instead of only with specific orders, if possible. To add a new method, there are a few things that you need to do. First, you need a hint name for your method. Try to name your hint so that it is unambiguous with all other methods, including ones that may not be implemented yet. If your method uses integrals, also include a ``hint_Integral`` hint. If there is more than one way to solve ODEs with your method, include a hint for each one, as well as a ``_best`` hint. Your ``ode__best()`` function should choose the best using min with ``ode_sol_simplicity`` as the key argument. See :obj:`~sympy.solvers.ode.single.HomogeneousCoeffBest`, for example. The function that uses your method will be called ``ode_()``, so the hint must only use characters that are allowed in a Python function name (alphanumeric characters and the underscore '``_``' character). Include a function for every hint, except for ``_Integral`` hints (:py:meth:`~sympy.solvers.ode.dsolve` takes care of those automatically). Hint names should be all lowercase, unless a word is commonly capitalized (such as Integral or Bernoulli). If you have a hint that you do not want to run with ``all_Integral`` that does not have an ``_Integral`` counterpart (such as a best hint that would defeat the purpose of ``all_Integral``), you will need to remove it manually in the :py:meth:`~sympy.solvers.ode.dsolve` code. See also the :py:meth:`~sympy.solvers.ode.classify_ode` docstring for guidelines on writing a hint name. Determine *in general* how the solutions returned by your method compare with other methods that can potentially solve the same ODEs. Then, put your hints in the :py:data:`~sympy.solvers.ode.allhints` tuple in the order that they should be called. The ordering of this tuple determines which hints are default. Note that exceptions are ok, because it is easy for the user to choose individual hints with :py:meth:`~sympy.solvers.ode.dsolve`. In general, ``_Integral`` variants should go at the end of the list, and ``_best`` variants should go before the various hints they apply to. For example, the ``undetermined_coefficients`` hint comes before the ``variation_of_parameters`` hint because, even though variation of parameters is more general than undetermined coefficients, undetermined coefficients generally returns cleaner results for the ODEs that it can solve than variation of parameters does, and it does not require integration, so it is much faster. Next, you need to have a match expression or a function that matches the type of the ODE, which you should put in :py:meth:`~sympy.solvers.ode.classify_ode` (if the match function is more than just a few lines. It should match the ODE without solving for it as much as possible, so that :py:meth:`~sympy.solvers.ode.classify_ode` remains fast and is not hindered by bugs in solving code. Be sure to consider corner cases. For example, if your solution method involves dividing by something, make sure you exclude the case where that division will be 0. In most cases, the matching of the ODE will also give you the various parts that you need to solve it. You should put that in a dictionary (``.match()`` will do this for you), and add that as ``matching_hints['hint'] = matchdict`` in the relevant part of :py:meth:`~sympy.solvers.ode.classify_ode`. :py:meth:`~sympy.solvers.ode.classify_ode` will then send this to :py:meth:`~sympy.solvers.ode.dsolve`, which will send it to your function as the ``match`` argument. Your function should be named ``ode_(eq, func, order, match)`. If you need to send more information, put it in the ``match`` dictionary. For example, if you had to substitute in a dummy variable in :py:meth:`~sympy.solvers.ode.classify_ode` to match the ODE, you will need to pass it to your function using the `match` dict to access it. You can access the independent variable using ``func.args[0]``, and the dependent variable (the function you are trying to solve for) as ``func.func``. If, while trying to solve the ODE, you find that you cannot, raise ``NotImplementedError``. :py:meth:`~sympy.solvers.ode.dsolve` will catch this error with the ``all`` meta-hint, rather than causing the whole routine to fail. Add a docstring to your function that describes the method employed. Like with anything else in SymPy, you will need to add a doctest to the docstring, in addition to real tests in ``test_ode.py``. Try to maintain consistency with the other hint functions' docstrings. Add your method to the list at the top of this docstring. Also, add your method to ``ode.rst`` in the ``docs/src`` directory, so that the Sphinx docs will pull its docstring into the main SymPy documentation. Be sure to make the Sphinx documentation by running ``make html`` from within the doc directory to verify that the docstring formats correctly. If your solution method involves integrating, use :py:obj:`~.Integral` instead of :py:meth:`~sympy.core.expr.Expr.integrate`. This allows the user to bypass hard/slow integration by using the ``_Integral`` variant of your hint. In most cases, calling :py:meth:`sympy.core.basic.Basic.doit` will integrate your solution. If this is not the case, you will need to write special code in :py:meth:`~sympy.solvers.ode.ode._handle_Integral`. Arbitrary constants should be symbols named ``C1``, ``C2``, and so on. All solution methods should return an equality instance. If you need an arbitrary number of arbitrary constants, you can use ``constants = numbered_symbols(prefix='C', cls=Symbol, start=1)``. If it is possible to solve for the dependent function in a general way, do so. Otherwise, do as best as you can, but do not call solve in your ``ode_()`` function. :py:meth:`~sympy.solvers.ode.ode.odesimp` will attempt to solve the solution for you, so you do not need to do that. Lastly, if your ODE has a common simplification that can be applied to your solutions, you can add a special case in :py:meth:`~sympy.solvers.ode.ode.odesimp` for it. For example, solutions returned from the ``1st_homogeneous_coeff`` hints often have many :obj:`~sympy.functions.elementary.exponential.log` terms, so :py:meth:`~sympy.solvers.ode.ode.odesimp` calls :py:meth:`~sympy.simplify.simplify.logcombine` on them (it also helps to write the arbitrary constant as ``log(C1)`` instead of ``C1`` in this case). Also consider common ways that you can rearrange your solution to have :py:meth:`~sympy.solvers.ode.constantsimp` take better advantage of it. It is better to put simplification in :py:meth:`~sympy.solvers.ode.ode.odesimp` than in your method, because it can then be turned off with the simplify flag in :py:meth:`~sympy.solvers.ode.dsolve`. If you have any extraneous simplification in your function, be sure to only run it using ``if match.get('simplify', True):``, especially if it can be slow or if it can reduce the domain of the solution. Finally, as with every contribution to SymPy, your method will need to be tested. Add a test for each method in ``test_ode.py``. Follow the conventions there, i.e., test the solver using ``dsolve(eq, f(x), hint=your_hint)``, and also test the solution using :py:meth:`~sympy.solvers.ode.checkodesol` (you can put these in a separate tests and skip/XFAIL if it runs too slow/does not work). Be sure to call your hint specifically in :py:meth:`~sympy.solvers.ode.dsolve`, that way the test will not be broken simply by the introduction of another matching hint. If your method works for higher order (>1) ODEs, you will need to run ``sol = constant_renumber(sol, 'C', 1, order)`` for each solution, where ``order`` is the order of the ODE. This is because ``constant_renumber`` renumbers the arbitrary constants by printing order, which is platform dependent. Try to test every corner case of your solver, including a range of orders if it is a `n`\th order solver, but if your solver is slow, such as if it involves hard integration, try to keep the test run time down. Feel free to refactor existing hints to avoid duplicating code or creating inconsistencies. If you can show that your method exactly duplicates an existing method, including in the simplicity and speed of obtaining the solutions, then you can remove the old, less general method. The existing code is tested extensively in ``test_ode.py``, so if anything is broken, one of those tests will surely fail. )AddSMulPowoo)Tuple) AtomicExprExpr)Function Derivative AppliedUndefdiffexpand expand_mulSubs) vectorize)nanzooNumber)EqualityEq)default_sort_keyordered)SymbolWildDummysymbols)sympify)preorder_traversal) BooleanAtom BooleanTrue BooleanFalse)explogsqrt) factorial)Integral)Poly terms_gcdPolynomialErrorlcm)cancel)Order)series)collect logcombinepowsimp separatevarssimplifycse) collect_const)checksolsolve)numbered_symbols)uniqsiftiterable) _preprocess ode_order_desolve)- factorable nth_algebraic separable 1st_exact 1st_linear Bernoulli1st_rational_riccatiRiccati_special_minus21st_homogeneous_coeff_best(1st_homogeneous_coeff_subs_indep_div_dep(1st_homogeneous_coeff_subs_dep_div_indep almost_linearlinear_coefficientsseparable_reduced1st_power_series lie_group%nth_linear_constant_coeff_homogeneousnth_linear_euler_eq_homogeneous3nth_linear_constant_coeff_undetermined_coefficients Solve ordinary differential equation ``eq`` for function ``f(x)``, using method ``hint``. **Details** ``eq`` can be any supported ordinary differential equation (see the :py:mod:`~sympy.solvers.ode` docstring for supported methods). This can either be an :py:class:`~sympy.core.relational.Equality`, or an expression, which is assumed to be equal to ``0``. ``f(x)`` is a function of one variable whose derivatives in that variable make up the ordinary differential equation ``eq``. In many cases it is not necessary to provide this; it will be autodetected (and an error raised if it could not be detected). ``hint`` is the solving method that you want dsolve to use. Use ``classify_ode(eq, f(x))`` to get all of the possible hints for an ODE. The default hint, ``default``, will use whatever hint is returned first by :py:meth:`~sympy.solvers.ode.classify_ode`. See Hints below for more options that you can use for hint. ``simplify`` enables simplification by :py:meth:`~sympy.solvers.ode.ode.odesimp`. See its docstring for more information. Turn this off, for example, to disable solving of solutions for ``func`` or simplification of arbitrary constants. It will still integrate with this hint. Note that the solution may contain more arbitrary constants than the order of the ODE with this option enabled. ``xi`` and ``eta`` are the infinitesimal functions of an ordinary differential equation. They are the infinitesimals of the Lie group of point transformations for which the differential equation is invariant. The user can specify values for the infinitesimals. If nothing is specified, ``xi`` and ``eta`` are calculated using :py:meth:`~sympy.solvers.ode.infinitesimals` with the help of various heuristics. ``ics`` is the set of initial/boundary conditions for the differential equation. It should be given in the form of ``{f(x0): x1, f(x).diff(x).subs(x, x2): x3}`` and so on. For power series solutions, if no initial conditions are specified ``f(0)`` is assumed to be ``C0`` and the power series solution is calculated about 0. ``x0`` is the point about which the power series solution of a differential equation is to be evaluated. ``n`` gives the exponent of the dependent variable up to which the power series solution of a differential equation is to be evaluated. **Hints** Aside from the various solving methods, there are also some meta-hints that you can pass to :py:meth:`~sympy.solvers.ode.dsolve`: ``default``: This uses whatever hint is returned first by :py:meth:`~sympy.solvers.ode.classify_ode`. This is the default argument to :py:meth:`~sympy.solvers.ode.dsolve`. ``all``: To make :py:meth:`~sympy.solvers.ode.dsolve` apply all relevant classification hints, use ``dsolve(ODE, func, hint="all")``. This will return a dictionary of ``hint:solution`` terms. If a hint causes dsolve to raise the ``NotImplementedError``, value of that hint's key will be the exception object raised. The dictionary will also include some special keys: - ``order``: The order of the ODE. See also :py:meth:`~sympy.solvers.deutils.ode_order` in ``deutils.py``. - ``best``: The simplest hint; what would be returned by ``best`` below. - ``best_hint``: The hint that would produce the solution given by ``best``. If more than one hint produces the best solution, the first one in the tuple returned by :py:meth:`~sympy.solvers.ode.classify_ode` is chosen. - ``default``: The solution that would be returned by default. This is the one produced by the hint that appears first in the tuple returned by :py:meth:`~sympy.solvers.ode.classify_ode`. ``all_Integral``: This is the same as ``all``, except if a hint also has a corresponding ``_Integral`` hint, it only returns the ``_Integral`` hint. This is useful if ``all`` causes :py:meth:`~sympy.solvers.ode.dsolve` to hang because of a difficult or impossible integral. This meta-hint will also be much faster than ``all``, because :py:meth:`~sympy.core.expr.Expr.integrate` is an expensive routine. ``best``: To have :py:meth:`~sympy.solvers.ode.dsolve` try all methods and return the simplest one. This takes into account whether the solution is solvable in the function, whether it contains any Integral classes (i.e. unevaluatable integrals), and which one is the shortest in size. See also the :py:meth:`~sympy.solvers.ode.classify_ode` docstring for more info on hints, and the :py:mod:`~sympy.solvers.ode` docstring for a list of all supported hints. **Tips** - You can declare the derivative of an unknown function this way: >>> from sympy import Function, Derivative >>> from sympy.abc import x # x is the independent variable >>> f = Function("f")(x) # f is a function of x >>> # f_ will be the derivative of f with respect to x >>> f_ = Derivative(f, x) - See ``test_ode.py`` for many tests, which serves also as a set of examples for how to use :py:meth:`~sympy.solvers.ode.dsolve`. - :py:meth:`~sympy.solvers.ode.dsolve` always returns an :py:class:`~sympy.core.relational.Equality` class (except for the case when the hint is ``all`` or ``all_Integral``). If possible, it solves the solution explicitly for the function being solved for. Otherwise, it returns an implicit solution. - Arbitrary constants are symbols named ``C1``, ``C2``, and so on. - Because all solutions should be mathematically equivalent, some hints may return the exact same result for an ODE. Often, though, two different hints will return the same solution formatted differently. The two should be equivalent. Also note that sometimes the values of the arbitrary constants in two different solutions may not be the same, because one constant may have "absorbed" other constants into it. - Do ``help(ode.ode_)`` to get help more information on a specific hint, where ```` is the name of a hint without ``_Integral``. For system of ordinary differential equations ============================================= **Usage** ``dsolve(eq, func)`` -> Solve a system of ordinary differential equations ``eq`` for ``func`` being list of functions including `x(t)`, `y(t)`, `z(t)` where number of functions in the list depends upon the number of equations provided in ``eq``. **Details** ``eq`` can be any supported system of ordinary differential equations This can either be an :py:class:`~sympy.core.relational.Equality`, or an expression, which is assumed to be equal to ``0``. ``func`` holds ``x(t)`` and ``y(t)`` being functions of one variable which together with some of their derivatives make up the system of ordinary differential equation ``eq``. It is not necessary to provide this; it will be autodetected (and an error raised if it could not be detected). **Hints** The hints are formed by parameters returned by classify_sysode, combining them give hints name used later for forming method name. Examples ======== >>> from sympy import Function, dsolve, Eq, Derivative, sin, cos, symbols >>> from sympy.abc import x >>> f = Function('f') >>> dsolve(Derivative(f(x), x, x) + 9*f(x), f(x)) Eq(f(x), C1*sin(3*x) + C2*cos(3*x)) >>> eq = sin(x)*cos(f(x)) + cos(x)*sin(f(x))*f(x).diff(x) >>> dsolve(eq, hint='1st_exact') [Eq(f(x), -acos(C1/cos(x)) + 2*pi), Eq(f(x), acos(C1/cos(x)))] >>> dsolve(eq, hint='almost_linear') [Eq(f(x), -acos(C1/cos(x)) + 2*pi), Eq(f(x), acos(C1/cos(x)))] >>> t = symbols('t') >>> x, y = symbols('x, y', cls=Function) >>> eq = (Eq(Derivative(x(t),t), 12*t*x(t) + 8*y(t)), Eq(Derivative(y(t),t), 21*x(t) + 7*t*y(t))) >>> dsolve(eq) [Eq(x(t), C1*x0(t) + C2*x0(t)*Integral(8*exp(Integral(7*t, t))*exp(Integral(12*t, t))/x0(t)**2, t)), Eq(y(t), C1*y0(t) + C2*(y0(t)*Integral(8*exp(Integral(7*t, t))*exp(Integral(12*t, t))/x0(t)**2, t) + exp(Integral(7*t, t))*exp(Integral(12*t, t))/x0(t)))] >>> eq = (Eq(Derivative(x(t),t),x(t)*y(t)*sin(t)), Eq(Derivative(y(t),t),y(t)**2*sin(t))) >>> dsolve(eq) {Eq(x(t), -exp(C1)/(C2*exp(C1) - cos(t))), Eq(y(t), -1/(C1 - cos(t)))} r) dsolve_systemT)funcsicsdoitrlrrorderrz@It solves only those systems of equations whose orders are equalc,tfd|DS)Nc3RK|]}t|tr|nd yw)rlN)r~list).0item recur_lens ry z,dsolve..recur_len..Hs#U4*T$*?yQFUs$')sum)lrs ryrzdsolve..recur_lenGsUSTUU Uz_dsolve() and classify_sysode() work with number of functions being equal to number of equationstype_of_equationN is_linearz1sysode_linear_%(no_of_equation)seq_order%(order)sz4sysode_nonlinear_%(no_of_equation)seq_order%(order)sode) rhintr3xietatyperx0nallF)dictr ordered_hintsc"t| S)N trysolving)ode_sol_simplicity)xrr3s ryzdsolve..ps"1d8|Drkeybest best_hintdefaultr)r)r;sympy.solvers.ode.systemsrlenNotImplementedErrorclassify_sysoderrr rror~coeffrr= is_negativervaluesrglobalsrr solve_icssubsr>pop classify_ode_helper_simplifymingetupdate)rrrrr3rrrrrkwargsrsolmatchrtrwfunc_ solvefuncsols constantssolved_constants given_hinthintsall_retdict failed_hintsgethints orderedhintsrvdetailrs ` ` @rydsolverdsD|; $CdCC X]3q6 3 3T "$5cQ" "YYtR yy& GL#BT>H#O4L '')"dE$KJB%'GDM  ';v&D!$w~~'7"8?EFGFOV#v&! 6?gkk!T&::+,GK( "*)!4GI '0GG  NN< (N=D#BeX3G G_#    D) 4[gV} bekk*-.q177? @ Cs2w 'A 'eT*!u{{4Q)BqE472K#LMYY!#A1  ' 'd s5<<>" #Q &_` `elln-a0g V T?c"g %EF F # $ ,% %[!T)#I&Y\a&ab #I&\_d&de U#D!4L55r 8O8OO #,T4C#H >BCs!12CCCK$+0)/L&0s4EEL8 EEL18 MM  Mc |}|d}|d}||}t|tr|} ntd|jdz} |jfd} |rt| tr| j } n | ||||} t | rFg} | D]>} t|| ||}t |r| j|.| j|@nzt|| ||} nkt| tr| j d}nd|d<| ||||}t|tr|Dcgc]}t|||} }n t|||} t| trItd | DsJ| |rt|| ||jd } t| d k(r| d } |rd |vrt| t t"fr,t%| g|dg| | |}| j'|} | Sg}| D]<} t%| g|dg| | |}|j| j'|>t|d k(r|d S|} | Scc}w#t($rYfwxYw) a Helper function of dsolve that calls the respective :py:mod:`~sympy.solvers.ode` functions to solve for the ordinary differential equations. This minimizes the computation in calling :py:meth:`~sympy.solvers.deutils._desolve` multiple times. rrode_ _Integralc:|jjSN)r difference)sfrees ryrz"_helper_simplify..sQ^^..t4rF)r3r3c3<K|]}t|tywr)r~rrrws ryrz#_helper_simplify..s1:a$1rrl power_series)r~SingleODESolverr removesuffixrget_general_solutionr;odesimpextendappendr_handle_Integralr_remove_redundant_solutionsargsrr rrrr)rrrrr3rrrrrrconsrrrsimpexprsexprrrv1rs @ryrrsz A V9D gJE dGE%) Ift'8'8'EEF ??D 4D i 1113DRue4D D>B $r1dD1D>IIdOIIdO  $T4.B i 122E2BE %E* b$u5E eT "AFG"4t4GBG!%t4B"d1b115251 ,RUDIIaLIB r7a<AB ~T) b4* %("& {DHcJ )*B IC 5'0!qyk47C'P$ 166"234  5 3x1}1v B I3H&"s+I 8I IIc |djd}g}g}t}|jD]5\}} t|tr@|jd} |D cgc]} | j |j k(s|  c} d} |} n\t|t tfr:t|t r|j}t|t r4|j}|jd} |jj}|} nLt|tr<|}|jd} |ft|jz}|j| |} |D]q}|jjj s)|jt!|j"j$|j&j$|s|j)|} n t+d| D]~}|j s|}|j| }|j|| }t|t,r|rN|Dcgc]}t|t,r|}}|j|8 t/||d}|s t1d|dk(r t1dt|dkDr t+d|dScc} wcc}w#t*$rg}YRwxYw) a Solve for the constants given initial conditions ``sols`` is a list of solutions. ``funcs`` is a list of functions. ``constants`` is a list of constants. ``ics`` is the set of initial/boundary conditions for the differential equation. It should be given in the form of ``{f(x0): x1, f(x).diff(x).subs(x, x2): x3}`` and so on. Returns a dictionary mapping constants to values. ``solution.subs(constants)`` will replace the constants in ``solution``. Example ======= >>> # From dsolve(f(x).diff(x) - f(x), f(x)) >>> from sympy import symbols, Eq, exp, Function >>> from sympy.solvers.ode.ode import solve_ics >>> f = Function('f') >>> x, C1 = symbols('x C1') >>> sols = [Eq(f(x), C1*exp(x))] >>> funcs = [f(x)] >>> constants = [C1] >>> ics = {f(0): 2} >>> solved_constants = solve_ics(sols, funcs, constants, ics) >>> solved_constants {C1: 2} >>> sols[0].subs(solved_constants) Eq(f(x), 2*exp(x)) rzUnrecognized initial conditionTrz%Couldn't solve for initial conditionsz\Initial conditions did not produce any solutions for constants. Perhaps they are degenerate.rlz> K  K )preprrrc \78t|}|r&t|jdk7rtd|zt |t r|j |jz }|} |s|t||\}} || }|jd} |j} td} |dn|}t|| | }d|i}| | j| }td| | g }td || | j| d g }td |g }td | | | |g }td| g }td| | || | j| d g }td| | || | j| d g }td| | || | j| d g }i}td}||D] }t |tt frSt |tr+|j"7|j$d}|j&d}n#t |t r|7| }|j$d}t 7t rt 7jdt(r7jdj| k(rt7jdjdk(r|| k(rwj+| sft-7fd7j$DrH| ||j.vr7t7| }dt1|z}|j3|||dz||ictdt |t(r|j| k(rmt|jdk(rU|jdj+| s7| ||j.vr&|j3|jd||dtdtdt5| || |||} |j7dd}!|!dk(}"|!j9d}!t:}#|!dvr|!t:vr |!t:|!i}#|#D]H}$|#|$| }%|%j=s|%||$<|#|$j>r|%||$dz<|s>|"sA|$|d<|cStA|}d}&|jBr|jE| | j| |}'|'dvrU|'jG|| | |zz88r68|r1| | 8|z}(tI|jD)cgc]})|)|(z  c})}&|&s|}&|dk(rtK||d !jG|||zz88r|8d <|8d <| 8d<8|jM| | | 8|<8|jM| | | 8|<|j7d"d}*|j7d#|}+tO8|8|z },|,jM| |*| |+i}-|-j+tPsf|-j+tRsP|-j+tTs:|-j+tP s#|-j| jM| |*| |+i}.|.j+tPs|.j+tRs|.j+tTs|.j+tP s8jW}/|/j3||*|+d$|/|d%<nz|d k(rt|| | j| d z||zz|| | zz}0tK|&| | j| d | | j| | | gjG|08d&}18rt-8fd'8Dsm|&jY\}}tA|}&tK|&| | j| d | | j| | | gjG|088rp8|dk7rgtO8|8|z }2tO8|8|z }3|j7d(d}*|2jM| |*},|,j+tPtTtRtP sU|3jM| |*},|,j+tPtTtRtP sd }18j3||||*|d)8|d*<|1stO| |*z |2z}2|2jM| |*},|,j+tPtTtRtP sWtO| |*z d z|3z}3|3jM| |*},|,j+tPtTtRtP s |2|3|*|d+}4|4|d,<tZD5cgc] }5|5|vs|5 }6}5|r|6r|6dnd|d<t]|6|d-<|St]|6Scc})wcc}5w).a: Returns a tuple of possible :py:meth:`~sympy.solvers.ode.dsolve` classifications for an ODE. The tuple is ordered so that first item is the classification that :py:meth:`~sympy.solvers.ode.dsolve` uses to solve the ODE by default. In general, classifications at the near the beginning of the list will produce better solutions faster than those near the end, thought there are always exceptions. To make :py:meth:`~sympy.solvers.ode.dsolve` use a different classification, use ``dsolve(ODE, func, hint=)``. See also the :py:meth:`~sympy.solvers.ode.dsolve` docstring for different meta-hints you can use. If ``dict`` is true, :py:meth:`~sympy.solvers.ode.classify_ode` will return a dictionary of ``hint:match`` expression terms. This is intended for internal use by :py:meth:`~sympy.solvers.ode.dsolve`. Note that because dictionaries are ordered arbitrarily, this will most likely not be in the same order as the tuple. You can get help on different hints by executing ``help(ode.ode_hintname)``, where ``hintname`` is the name of the hint without ``_Integral``. See :py:data:`~sympy.solvers.ode.allhints` or the :py:mod:`~sympy.solvers.ode` docstring for a list of all supported hints that can be returned from :py:meth:`~sympy.solvers.ode.classify_ode`. Notes ===== These are remarks on hint names. ``_Integral`` If a classification has ``_Integral`` at the end, it will return the expression with an unevaluated :py:class:`~.Integral` class in it. Note that a hint may do this anyway if :py:meth:`~sympy.core.expr.Expr.integrate` cannot do the integral, though just using an ``_Integral`` will do so much faster. Indeed, an ``_Integral`` hint will always be faster than its corresponding hint without ``_Integral`` because :py:meth:`~sympy.core.expr.Expr.integrate` is an expensive routine. If :py:meth:`~sympy.solvers.ode.dsolve` hangs, it is probably because :py:meth:`~sympy.core.expr.Expr.integrate` is hanging on a tough or impossible integral. Try using an ``_Integral`` hint or ``all_Integral`` to get it return something. Note that some hints do not have ``_Integral`` counterparts. This is because :py:func:`~sympy.integrals.integrals.integrate` is not used in solving the ODE for those method. For example, `n`\th order linear homogeneous ODEs with constant coefficients do not require integration to solve, so there is no ``nth_linear_homogeneous_constant_coeff_Integrate`` hint. You can easily evaluate any unevaluated :py:class:`~sympy.integrals.integrals.Integral`\s in an expression by doing ``expr.doit()``. Ordinals Some hints contain an ordinal such as ``1st_linear``. This is to help differentiate them from other hints, as well as from other methods that may not be implemented yet. If a hint has ``nth`` in it, such as the ``nth_linear`` hints, this means that the method used to applies to ODEs of any order. ``indep`` and ``dep`` Some hints contain the words ``indep`` or ``dep``. These reference the independent variable and the dependent function, respectively. For example, if an ODE is in terms of `f(x)`, then ``indep`` will refer to `x` and ``dep`` will refer to `f`. ``subs`` If a hints has the word ``subs`` in it, it means that the ODE is solved by substituting the expression given after the word ``subs`` for a single dummy variable. This is usually in terms of ``indep`` and ``dep`` as above. The substituted expression will be written only in characters allowed for names of Python objects, meaning operators will be spelled out. For example, ``indep``/``dep`` will be written as ``indep_div_dep``. ``coeff`` The word ``coeff`` in a hint refers to the coefficients of something in the ODE, usually of the derivative terms. See the docstring for the individual methods for more info (``help(ode)``). This is contrast to ``coefficients``, as in ``undetermined_coefficients``, which refers to the common name of a method. ``_best`` Methods that have more than one fundamental way to solve will have a hint for each sub-method and a ``_best`` meta-classification. This will evaluate all hints and return the best, using the same considerations as the normal ``best`` meta-hint. Examples ======== >>> from sympy import Function, classify_ode, Eq >>> from sympy.abc import x >>> f = Function('f') >>> classify_ode(Eq(f(x).diff(x), 0), f(x)) ('nth_algebraic', 'separable', '1st_exact', '1st_linear', 'Bernoulli', '1st_homogeneous_coeff_best', '1st_homogeneous_coeff_subs_indep_div_dep', '1st_homogeneous_coeff_subs_dep_div_indep', '1st_power_series', 'lie_group', 'nth_linear_constant_coeff_homogeneous', 'nth_linear_euler_eq_homogeneous', 'nth_algebraic_Integral', 'separable_Integral', '1st_exact_Integral', '1st_linear_Integral', 'Bernoulli_Integral', '1st_homogeneous_coeff_subs_indep_div_dep_Integral', '1st_homogeneous_coeff_subs_dep_div_indep_Integral') >>> classify_ode(f(x).diff(x, 2) + 3*f(x).diff(x) + 2*f(x) - 4) ('factorable', 'nth_linear_constant_coeff_undetermined_coefficients', 'nth_linear_constant_coeff_variation_of_parameters', 'nth_linear_constant_coeff_variation_of_parameters_Integral') rlzLdsolve() and classify_ode() only work with functions of one variable, not %sNryrar}derc1a3b3c3C1c3BK|]}|jdk(ywrN)r)rrwrs ryrzclassify_ode..s#'%1qEOOA,>'>'%srvalz+Invalid boundary conditions for Derivatives)f0f0valz(Invalid boundary conditions for FunctionzfEnter boundary conditions of the form ics={f(point): value, f(x).diff(x, order).subs(x, point): value})rrrrrr)rr all_Integralr)rlrT)exactrr)termsrrrMFc3DK|]}|jywr) is_polynomial)rrrs ryrzclassify_ode..Ks;#qv++-;s r)r r r rrr[)pqrrr\r)/rrrrr~rrrr<rrr=rrrrr rrrr rrrrrSingleODEProblemrr solver_mapmatches has_integralris_Addrrrr/rr,rrrcopyas_numer_denomallhintsrq)9rrrrrrrrrreq_origrrrrrrmatching_hintsdfrrrrr r r boundaryr roldnewdordertempr user_hint early_exituser_maprsolver reduced_eq deriv_coefdenargrrcheckcheck1check2rseriesdeqordinaryrr coeff_dictrwretlistrrs9 @@ryrr3s~ #,C DII!#68<=> >"h VVbff_G t|D) E <D ! A A c AAE b!A$ Eu%N 11B S1Q4&!A S2qtyyA/0A S2$A S1adB-(A dQC B dQqT2qtyyA7 8B dQqT2qtyyA7 8B dQqT2qtyyA7 8BH B % KG'D*#56gt,#LLE!++A.C!--*C4#EC!++A.Cuj1jA 7"&+jjm&8&8A&= 1 **+q0SAXGGAJ3'%OO'%$%)*#g,2K2K)K&ua0FV,DOOT3u c'l$KL$%RSSG\2LLA%#gll*;q*@ Q++A.1CL> #)N4 ~**5;tk12 ,0y)%%& BJ yyXXadii512 V #  1Q48,AQrUdAbEk bgg">s3s7">?   z B$ ' - -a!b&j 9 AcFAcFAcFQ499QqT1%AaDQ499QqT1%AaDLLq)ELL"-E1Q4!9%EZZE1e 45F::b>&**S/JJsOFJJsO ++a...5!U/CDzz"~fjjo 3 B3ffhGNNU%%#PQ9@N#56 ! !A$))Aq/"RU*R!W4 J qTYYq!_adiilAaD 1 3385:  ;;;!0021#AY JqTYYq!_adiilAaD9;;@5: 2!quQrU{#AquQrU{#AJJtQ'EFF1e$E99RcB3/q%(yyS#s3#HHHBb%RWXYBCN#>? AIq=)q%(yyS#s3UQ12AFF1e,E 99RcB37+,1EE%R EO'AB#:Qa>&9q:G: 3:GAJty!*/.'W~g#?V;s f$+ f)5f)c 2dfd|fD\}t|D]2\}}t|ts|j|jz ||<4t t |dj tdj tdddzi}||d<|dk(r tdidgk(r t|t ttt|k7rtd zi}D]Y}j|d rd}t|D]\}} t| |} || ks| }|}  |vr || |g|| <n||| <||<[tt|Dcgc]}|| c}|d <D]i}t|t r.|D](} t| j dk7std |zA|sDt|j dk7s]td |z|d <fd} id}t|D]:\}}D]0}t|t r|D] } | ||| |}&| ||||}2<|d<||d<ttj#dk(rt |d j#d}|ddk(r!|ddk(r|dk(rt%|}nGd}nDd}nA|ddk(r|dk(rt'|}n&d}n#|ddk(r|dk(rt)|}nd}nd}nd}||d<|Scc}w)a Returns a dictionary of parameter names and values that define the system of ordinary differential equations in ``eq``. The parameters are further used in :py:meth:`~sympy.solvers.ode.dsolve` for solving that system. Some parameter names and values are: 'is_linear' (boolean), which tells whether the given system is linear. Note that "linear" here refers to the operator: terms such as ``x*diff(x,t)`` are nonlinear, whereas terms like ``sin(t)*diff(x,t)`` are still linear operators. 'func' (list) contains the :py:class:`~sympy.core.function.Function`s that appear with a derivative in the ODE, i.e. those that we are trying to solve the ODE for. 'order' (dict) with the maximum derivative for each element of the 'func' parameter. 'func_coeff' (dict or Matrix) with the coefficient for each triple ``(equation number, function, order)```. The coefficients are those subexpressions that do not appear in 'func', and hence can be considered constant for purposes of ODE solving. The value of this parameter can also be a Matrix if the system of ODEs are linear first order of the form X' = AX where X is the vector of dependent variables. Here, this function returns the coefficient matrix A. 'eq' (list) with the equations from ``eq``, sympified and transformed into expressions (we are solving for these expressions to be zero). 'no_of_equations' (int) is the number of equations (same as ``len(eq)``). 'type_of_equation' (string) is an internal classification of the type of ODE. 'is_constant' (boolean), which tells if the system of ODEs is constant coefficient or not. This key is temporary addition for now and is in the match dict only when the system of ODEs is linear first order constant coefficient homogeneous. So, this key's value is True for now if it is available else it does not exist. 'is_homogeneous' (boolean), which tells if the system of ODEs is homogeneous. Like the key 'is_constant', this key is a temporary addition and it is True since this key value is available only when the system is linear first order constant coefficient homogeneous. References ========== -https://eqworld.ipmnet.ru/en/solutions/sysode/sode-toc1.htm -A. D. Polyanin and A. V. Manzhirov, Handbook of Mathematics for Engineers and Scientists Examples ======== >>> from sympy import Function, Eq, symbols, diff >>> from sympy.solvers.ode.ode import classify_sysode >>> from sympy.abc import t >>> f, x, y = symbols('f, x, y', cls=Function) >>> k, l, m, n = symbols('k, l, m, n', Integer=True) >>> x1 = diff(x(t), t) ; y1 = diff(y(t), t) >>> x2 = diff(x(t), t, t) ; y2 = diff(y(t), t, t) >>> eq = (Eq(x1, 12*x(t) - 6*y(t)), Eq(y1, 11*x(t) + 3*y(t))) >>> classify_sysode(eq) {'eq': [-12*x(t) + 6*y(t) + Derivative(x(t), t), -11*x(t) - 3*y(t) + Derivative(y(t), t)], 'func': [x(t), y(t)], 'func_coeff': {(0, x(t), 0): -12, (0, x(t), 1): 1, (0, y(t), 0): 6, (0, y(t), 1): 0, (1, x(t), 0): -11, (1, x(t), 1): 0, (1, y(t), 0): -3, (1, y(t), 1): 1}, 'is_linear': True, 'no_of_equation': 2, 'order': {x(t): 1, y(t): 1}, 'type_of_equation': None} >>> eq = (Eq(diff(x(t),t), 5*t*x(t) + t**2*y(t) + 2), Eq(diff(y(t),t), -t**2*x(t) + 5*t*y(t))) >>> classify_sysode(eq) {'eq': [-t**2*y(t) - 5*t*x(t) + Derivative(x(t), t) - 2, t**2*x(t) - 5*t*y(t) + Derivative(y(t), t)], 'func': [x(t), y(t)], 'func_coeff': {(0, x(t), 0): -5*t, (0, x(t), 1): 1, (0, y(t), 0): -t**2, (0, y(t), 1): 0, (1, x(t), 0): t**2, (1, x(t), 1): 0, (1, y(t), 0): -5*t, (1, y(t), 1): 1}, 'is_linear': True, 'no_of_equation': 2, 'order': {x(t): 1, y(t): 1}, 'type_of_equation': None} c`tttt|r |S|gSr)rmaprr;)rrs ry_sympifyz!classify_sysode.._sympifys'Cx|>??">??rc3.K|] }|ywr)rwr<s ryrz"classify_sysode..s2!2srno_of_equationrlrrzYclassify_sysode() works for systems of ODEs. For scalar ODEs, classify_ode should be usedNzDNumber of functions given is not equal to the number of equations %sFrzOdsolve() and classify_sysode() work with functions of one variable only, not %src t |dzD]L}t|jt| |gj t| | |||f<|dk(sP |||fdk(r|dk(ra|j |dd}tdt ||dzD]&}||j t| |ddz}(|dk7sd}|j t| |ddsd} D]b}t|tr,|D]&} |||fj |dd} | dk7s%d}(? |||fj |dd} | dk7sad}dO|S)NrlTras_AddF) ror/rrras_independentr=r~r)eqsjr is_linear_kcoefxrr elem_func_dep func_coefrrrs rylinearity_checkz(classify_sysode..linearity_checksuT{Q' 3A$+CJJL4a;K:L$M$S$STXY]_`bcTd$eIaqj !T!QaZ(A-Av"11$t1DQG"'9S+>+B"CZB C$6$6tD!R7HQU$6$VWX$YYDZ19).J--d4A.>t-LQO).J!& 3%eT2.37 &/4 &;&J&J:^b&J&cde&f#&!816J7 #,AtQJ"7"F"FuUY"F"Z[\"]C"ax-2  3 30rT func_coeffrrr) enumerater~rrrrrr rr_extract_funcsrrrr=rorrcheck_linear_2eq_order1check_nonlinear_2eq_order1check_nonlinear_3eq_order1)rrrrrwfir" func_dictr max_ordereqs_order_eq_no func_elemrNrrFrEorder_eqrr<rMrrs ` @@@@ryrrvsT@3r5k2IB2$2 b( #FFRVVOBqE$ T"Q%++j) *1 - 3 3F ;d} A| sD| dk(sJd|z dz dd|z z z |k(skd } nd dk7sd dk7ryt!fd d j#Dsyddz d<ddz d<ddz d<ddz d<| ryy)Nrrla1a2b1b2rc2rd1d2c3FK|]}|jywrr)rrHrrs ryrz*check_linear_2eq_order1..wsD11Q488A;Ds!za1 a2 b1 b2 c1 c2type6type7)rrrr rrZeroror make_argsrr,rrQrr5anysplit)rrrrMrrfcforcingrwrFrrp1p2rrrs @@ryrSrSJs Q A Q A B T"Q%++j) *1 - 3 3F ;?AEAq!ttWQY4(1T7QtWQY+>?AEA   wzQtWaZD(;(A(A(CDDgagoAdG!D'!D'/$gagoAdG!D'!D'/$rc  ttdjtdjtdt dt dt dt \fd}|D]N}t|ts|ddj}|ddj}|||}|s |||}|cS|dj}|dj}|}t d||g } t d g } t d g } t d g } t d g } tdD]7}d}tj|D]}||||||dfz z }||<9djt||| zzz }|rt|dz |z |rj|shj|jsA|j|j|jsydjt|t!| |zzz }|rt|dz |z |rj|shj|jsA|j|j|jsyt ddjt|z }djt|z }|r|r|j|j|jsA|j|j|jsydjt|z }djt|z }|j|j||j|j|z j#\}}|j| | z}|j| | z}|r|ryy)Nrrgu, vclscdjt|z|z z}djt|z|z z}|r|sldjt||z z z z}djt||z z z z}|r|shd jt|z|z z}d jt|z|z z}|r|snd jt||z z z z}d jt||z z z z}|r|r|jt|jt| jsU|jt|jt| jsyy)Nrrltype5)rrrr) rrr1r2rrrrsruvs ry check_typez.check_nonlinear_2eq_order1..check_types! U[[4!Q<!A$.2 3 U[[4!Q<!A$.2 3rAT!A$q\AaDF2QqS89BAT!A$q\AaDF2QqS89Bra5&$qtA,1 5 9:Ba5&$qtA,1 5 9:Bra5&QqT! qtAv 5! ; >q Arrlrrf1f2g1g2rtype1type2type3type4)rrr rrrrr~rrorrkrrrrr#r)rrrrMr}rrreq_typernrr~rrrrwrErrryrzrsr/R1R2rrsrr{r|s` @@@@@ryrTrTs T"Q%++j) *1 - 3 3F ;+; C 2b5 B 2b5 B b rcyrr>rrrrMs rycheck_nonlinear_2eq_order2r rc|dj}|dj}|dj}|}tt|djtdjtd}t dt \}} } td|||||||g} td|||||||g} td |||||||g} td }td }td }td }tdD]7}d}tj||D]}||||||dfz z }|||<9|djt|||| ||z||zz }|djt|||| ||z||zz }|djt|||| ||z||zz }|r||rz|rx|| j\}}|| j\}}|| j\}}t||z|| | z zz || z|| |z zz || z||| z zz g|| gry|djt|||||||z|zz }|rt||j| |z}t||||dz ||z j| ||z||z}t||||dz ||z j| ||z||z}|r||rz|rx|| j\}}|| j\}}|| j\}}t||z|| | z zz || z|| |z zz || z||| z zz g|| gry|djt|||||z z }|rt||j| |z}|j!t||j| |z|r|dj#||r;|dj#||s$||||c||<||<||  ||  c|| <|| <|djt|||| ||zz || |zz}|r0|dt||||| ||zz || ||zzk(}|r|r|ry|djt||||||zz |||zz}|r6t||j| |z}|j!t||j| |z|r|dj#||r;|dj#||s$||||c||<||<||  ||  c|| <|| <t||||dz j| ||z||z|| ||z|zz }|rBt||||dz || ||z||z|| ||z||zz k(}|r|r|ryt||||dz j||||z z}|r$t||j| |z}|j!t||j| |z|r|dj#||r;|dj#||s$||||c||<||<||  ||  c|| <|| <t||||dz j||| ||z|| |zz z}|r9t||||dz |||| ||z|| ||zz zk(}|r|r|ryy)Nrrlru, v, wrurrbcrF1F2F3rPrrrrrx)rrrr rrrrrorrkrrrr7r5rr)rrrrMrrzrnrr{r|r?rrrrrrrrwrErryrzr3num1den1num2den2num3den3rs ryrUrUs  Q A Q A Q A B T"Q%++j) *1 - 3 3F ;AaD|be#RU* 1 1!AaD&1+ > bRU))+ dU))+ dU))+ d $q&qs#T!VD!A#J%6QtQqSz8IJAq6 R 1 D1aLBrE*+A 1R5 ! ' '" - -"&,,QrT23 !uyyB A2b6):!#BB22 "1v1v 1r!uAT!A$q\AbfH4r!uRx?@B Q%4!Q<"Q%2,6Ar"vEEB " 1 D1aL1Q47*QqT"W45A 1R5 ! ' '" - -"&,,QrT23 !uyyB A2b6):!#BB22 "1v1v 1r!uqtA,A&--a!fRVmbeAaDjm.KLB qtA,A&"Q%!*RV*;beAaDjB>O*OOB " ad11 $$QqT27^4A 1R5 ! ' '" - -"&,,QrT23 !uyyB A2b6):!#BB22 "1v1v 1r!uqtA,A&--adAbfHr!uRx4G.HIB qtA,A&!A$1bf r!uRV|0K*LLB " rcyrr>rs rycheck_nonlinear_3eq_order2rrrc |jd}|j}t|d}|j|jz }t |||}|j dr t |}t|ts td|j|Dcic]}|tdc}x} j| Dcic]}| || c}}t||}|j|k(r<|jj|s!t!|j|jg}|j|k(r|jj|s|g}n t#d|j%t&D} t)||d| rd nd } | st* d } | D cgc]} t!||| | }} |j d rtt/|D]f\}}t1|d}t|jt2r5|jdk(r&t!|jjd|z |}|||<ht/|D]0\}}t||||<t5|||j||<2t7|dk(r|d}|Scc}wcc}wcc} w#t*t,f$r|g}YwxYw)a Simplifies solutions of ODEs, including trying to solve for ``func`` and running :py:meth:`~sympy.solvers.ode.constantsimp`. It may use knowledge of the type of solution that the hint returns to apply additional simplifications. It also attempts to integrate any :py:class:`~sympy.integrals.integrals.Integral`\s in the expression, if the hint is not an ``_Integral`` hint. This function should have no effect on expressions returned by :py:meth:`~sympy.solvers.ode.dsolve`, as :py:meth:`~sympy.solvers.ode.dsolve` already calls :py:meth:`~sympy.solvers.ode.ode.odesimp`, but the individual hint functions do not call :py:meth:`~sympy.solvers.ode.ode.odesimp` (because the :py:meth:`~sympy.solvers.ode.dsolve` wrapper does). Therefore, this function is designed for mainly internal use. Examples ======== >>> from sympy import sin, symbols, dsolve, pprint, Function >>> from sympy.solvers.ode.ode import odesimp >>> x, u2, C1= symbols('x,u2,C1') >>> f = Function('f') >>> eq = dsolve(x*f(x).diff(x) - f(x) - x*sin(f(x)/x), f(x), ... hint='1st_homogeneous_coeff_subs_indep_div_dep_Integral', ... simplify=False) >>> pprint(eq, wrap_line=False) x ---- f(x) / | | / 1 \ | -|u1 + -------| | | /1 \| | | sin|--|| | \ \u1// log(f(x)) = log(C1) + | ---------------- d(u1) | 2 | u1 | / >>> pprint(odesimp(eq, f(x), 1, {C1}, ... hint='1st_homogeneous_coeff_subs_indep_div_dep' ... )) #doctest: +SKIP x --------- = C1 /f(x)\ tan|----| \2*x / rrlrs"nth_linear_euler_eq_nonhomogeneousz$eq should be an instance of EqualityT)nonzeroc34K|]}|jywr)is_Floatrs ryrzodesimp..s>>FN)forcerationalc||j\}}|jr|St|jddS)Nr#T)combinedeep)rrr1r)rnumerdenoms ry_expandzodesimp.._expands5#224 u<<K"4;;=%dKKr1st_homogeneous_coeff)r)rrrzrr startswithr3r~r TypeErrorxreplacer constantsimprrrrrlrrr7rr*rQr0r$constant_renumberr)rrrrrrrr rrw_floatseqsolrrrFeqinewis ryrr!st ! A A  *B#"2"22I "dD )B ;< b\ b( #>?? )DQ!U400DDa F O ObcPd]^QRSTQUWXQXPd eB b) $B vv~bffjj. ! vv~bffjj.T 7>RXXf-=>>F"d$&dSE))  L1661"QqT71:&6B6 ??2 3#B- 3!#T2dhh,QdhhmmA.r126D1  B-;3S),1!"Q%)9)9:1;  2w!| U ICEPdX7$_5 B s%J? JAJ)!J$)J>=J>ct|r8|D]}t|||tk(stcStt |S|j t rtS|j|k(r|jj |r*|j|k(r|jj |sy|r t||}|st ytt |S#t$rYwxYw)a@ Returns an extended integer representing how simple a solution to an ODE is. The following things are considered, in order from most simple to least: - ``sol`` is solved for ``func``. - ``sol`` is not solved for ``func``, but can be if passed to solve (e.g., a solution returned by ``dsolve(ode, func, simplify=False``). - If ``sol`` is not solved for ``func``, then base the result on the length of ``sol``, as computed by ``len(str(sol))``. - If ``sol`` has any unevaluated :py:class:`~sympy.integrals.integrals.Integral`\s, this will automatically be considered less simple than any of the above. This function returns an integer such that if solution A is simpler than solution B by above metric, then ``ode_sol_simplicity(sola, func) < ode_sol_simplicity(solb, func)``. Currently, the following are the numbers returned, but if the heuristic is ever improved, this may change. Only the ordering is guaranteed. +----------------------------------------------+-------------------+ | Simplicity | Return | +==============================================+===================+ | ``sol`` solved for ``func`` | ``-2`` | +----------------------------------------------+-------------------+ | ``sol`` not solved for ``func`` but can be | ``-1`` | +----------------------------------------------+-------------------+ | ``sol`` is not solved nor solvable for | ``len(str(sol))`` | | ``func`` | | +----------------------------------------------+-------------------+ | ``sol`` contains an | ``oo`` | | :obj:`~sympy.integrals.integrals.Integral` | | +----------------------------------------------+-------------------+ ``oo`` here means the SymPy infinity, which should compare greater than any integer. If you already know :py:meth:`~sympy.solvers.solvers.solve` cannot solve ``sol``, you can use ``trysolving=False`` to skip that step, which is the only potentially slow step. For example, :py:meth:`~sympy.solvers.ode.dsolve` with the ``simplify=False`` flag should do this. If ``sol`` is a list of solutions, if the worst solution in the list returns ``oo`` it returns that, otherwise it returns ``len(str(sol))``, that is, the length of the string representation of the whole list. Examples ======== This function is designed to be passed to ``min`` as the key argument, such as ``min(listofsolutions, key=lambda i: ode_sol_simplicity(i, f(x)))``. >>> from sympy import symbols, Function, Eq, tan, Integral >>> from sympy.solvers.ode.ode import ode_sol_simplicity >>> x, C1, C2 = symbols('x, C1, C2') >>> f = Function('f') >>> ode_sol_simplicity(Eq(f(x), C1*x**2), f(x)) -2 >>> ode_sol_simplicity(Eq(x**2 + f(x), C1), f(x)) -1 >>> ode_sol_simplicity(Eq(f(x), C1*Integral(2*x, x)), f(x)) oo >>> eq1 = Eq(f(x)/tan(f(x)/(2*x)), C1) >>> eq2 = Eq(f(x)/tan(f(x)/(2*x) + f(x)), C2) >>> [ode_sol_simplicity(eq, f(x)) for eq in [eq1, eq2]] [28, 35] >>> min([eq1, eq2], key=lambda i: ode_sol_simplicity(i, f(x))) Eq(f(x)/tan(f(x)/(2*x)), C1) r) r;rrrrrr'rrr7r)rrrrwrs ryrrsb} A!!TjARG  3s8} wwx  ww$sww{{40 GGtOCGGKK$5 d#D))  s3x=#   s7C!! C-,C-c g}|D]m}t|Dcgc]}t|ts|}}g}|D]#}|t|j t z }%|D]}|j |ott|}|Scc}wr)rr~r rrr rr9)rErrrnodederivsrrrs ryrRrR(s E #5b#9Z4Zj=Y$ZZ 0A D./ /D 0 E LL    e E L[s B B cDtgfd|S)Ncx|j}|r#|jrj|y|jtk(r|j d}|jt tfvrZt|jfd}t|ddkDr|j|d}|jsjj|nXt|trH|jjr-td|jDrj||jD] }| y)NT)mulc:|jjSr)rissubsetrwrxs ryrzG_get_constant_subexpressions.._recursive_walk..Asq~~/F/Fr/Jrrlc38K|]}t|dk(yw)rPN)r)rrs ryrzH_get_constant_subexpressions.._recursive_walk..HsAA! As)rrrrr#rrrr:rr is_numberr~r'rlimits)r expr_symsrrrwCesrx_recursive_walks ryrz5_get_constant_subexpressions.._recursive_walk9s%% ++B/ JJt  yyC{{t{,yyS#J&$JKqw._linearTs dC *4::a=$q'#91a(*B*A IIaLA:AaD! A    /qt9q=aDII#I&qT!"X/#yyA/ /  *s CCct|jdk7r-|j|jDcgc] }| c}}|}|Scc}wNr)rrr)rrwrrs ryrz5__remove_linear_redundancies.._recursive_walkesK tyy>Q 499499Eaq1EFDt} FsAc0t|txs|vSr)r~rrs ryrz.__remove_linear_redundancies..msjF+6qBwr)TFFTrl) rr~rrrrrr:r rr) rrxrwrrrdlhsdrhshsrrrs ` @@@ry__remove_linear_redundanciesrPs&( )Atzz!}  )D '47Q;! 'B" $!04 :1OA&:S 6 c6 "sbyCC 88V} $c6])BC!<#((ANDC!<#((AND" $,$B{!"1$ $ tE{#c4;&77CtDz"S$t*%55C XX#v &388V}+DC!<#((ANDt|$#$#DK4;'#tDz**#s|t$$e * '4;sG; HH)Hc |}}t|}|D][ t j}|st fd|Ds1|j t j |d] t\}}|j|d}|D] t djt t dk(rO d|vrH d|jtvr.t fd|Ds|j d d}|j }|t|d}||k7r t|SS#t$rY5wxYw)a Simplifies an expression with arbitrary constants in it. This function is written specifically to work with :py:meth:`~sympy.solvers.ode.dsolve`, and is not intended for general use. Simplification is done by "absorbing" the arbitrary constants into other arbitrary constants, numbers, and symbols that they are not independent of. The symbols must all have the same name with numbers after it, for example, ``C1``, ``C2``, ``C3``. The ``symbolname`` here would be '``C``', the ``startnumber`` would be 1, and the ``endnumber`` would be 3. If the arbitrary constants are independent of the variable ``x``, then the independent symbol would be ``x``. There is no need to specify the dependent function, such as ``f(x)``, because it already has the independent symbol, ``x``, in it. Because terms are "absorbed" into arbitrary constants and because constants are renumbered after simplifying, the arbitrary constants in expr are not necessarily equal to the ones of the same name in the returned result. If two or more arbitrary constants are added, multiplied, or raised to the power of each other, they are first absorbed together into a single arbitrary constant. Then the new constant is combined into other terms if necessary. Absorption of constants is done with limited assistance: 1. terms of :py:class:`~sympy.core.add.Add`\s are collected to try join constants so `e^x (C_1 \cos(x) + C_2 \cos(x))` will simplify to `e^x C_1 \cos(x)`; 2. powers with exponents that are :py:class:`~sympy.core.add.Add`\s are expanded so `e^{C_1 + x}` will be simplified to `C_1 e^x`. Use :py:meth:`~sympy.solvers.ode.ode.constant_renumber` to renumber constants after simplification or else arbitrary numbers on constants may appear, e.g. `C_1 + C_3 x`. In rare cases, a single constant can be "simplified" into two constants. Every differential equation solution should have as many arbitrary constants as the order of the differential equation. The result here will be technically correct, but it may, for example, have `C_1` and `C_2` in an expression, when `C_1` is actually equal to `C_2`. Use your discretion in such situations, and also take advantage of the ability to use hints in :py:meth:`~sympy.solvers.ode.dsolve`. Examples ======== >>> from sympy import symbols >>> from sympy.solvers.ode.ode import constantsimp >>> C1, C2, C3, x, y = symbols('C1, C2, C3, x, y') >>> constantsimp(2*C1*x, {C1, C2, C3}) C1*x >>> constantsimp(C1 + 2 + x, {C1, C2, C3}) C1 + x >>> constantsimp(C1*C2 + 2 + C2 + C3*x, {C1, C2, C3}) C1 + C3*x c3dK|]'}j|j|k()ywr)r)rrrxes ryrzconstantsimp..s&9tzz!} +9s-0rrrlc38K|]}|k7s d|vywrr>)rexcsrs ryrzconstantsimp..sAq1 As  ct|ddd}|jrZd}d}|jD]G}t|trd}n(|j rt d|jD}|sA|sD|}|S|S)NFT)clearrrc3pK|].}tj|D]}t|t0ywr)rrkr~r#)rrrVs ryrzDconstantsimp.._conditional_term_factoring..s: 4"%--"2 4!+2s 3 4 3 4s46)r)is_Mulrr~r#rrl)rnew_exprinfacasfacms ry_conditional_term_factoringz1constantsimp.._conditional_term_factoringsTT%H ??EE]] a% EXX 4QVV 44EU#H r)rrrrrrrr4reverserrrrl IndexErrorrr) rrrx orig_exprconstant_subexprsxescommonsrexprrrrrs ` @@@ryrrspN BI4T2>)2??#  9S9 9 HHH 99RQ(D ) Ta 'Aadjj()B2w!|1 1U[[00AgAA 1Q4A/" A ' (b 1D$ 't ,DDD"%% K7    s6B9E E%$E%c t|tttfr#t |t t ||S&t|j}t|z  n:td}|jDcgc]}||js|c} |tdd}n fd|D}g Dcgc]}|tjfc} fd fd  |} Dcgc] }|vs| c} tt |} |j| d }|Scc}wcc}wcc}w) a Renumber arbitrary constants in ``expr`` to use the symbol names as given in ``newconstants``. In the process, this reorders expression terms in a standard way. If ``newconstants`` is not provided then the new constant names will be ``C1``, ``C2`` etc. Otherwise ``newconstants`` should be an iterable giving the new symbols to use for the constants in order. The ``variables`` argument is a list of non-constant symbols. All other free symbols found in ``expr`` are assumed to be constants and will be renumbered. If ``variables`` is not given then any numbered symbol beginning with ``C`` (e.g. ``C1``) is assumed to be a constant. Symbols are renumbered based on ``.sort_key()``, so they should be numbered roughly in the order that they appear in the final, printed expression. Note that this ordering is based in part on hashes, so it can produce different results on different machines. The structure of this function is very similar to that of :py:meth:`~sympy.solvers.ode.constantsimp`. Examples ======== >>> from sympy import symbols >>> from sympy.solvers.ode.ode import constant_renumber >>> x, C1, C2, C3 = symbols('x,C1:4') >>> expr = C3 + C2*x + C1*x**2 >>> expr C1*x**2 + C2*x + C3 >>> constant_renumber(expr) C1 + C2*x + C3*x**2 The ``variables`` argument specifies which are constants so that the other symbols will not be renumbered: >>> constant_renumber(expr, [C1, x]) C1*x**2 + C2 + C3*x The ``newconstants`` argument is used to specify what symbols to use when replacing the constants: >>> constant_renumber(expr, [x], newconstants=symbols('E1:4')) E1 + E2*x + E3*x**2 )r newconstantscN|jdxr|ddjS)NCrl)risdigit)rs ryrz#constant_renumber..Cs q||C0DQqrU]]_rrlrr|c3,K|] }|vs| ywrr>)rsymrs ryrz$constant_renumber..JsN#I9M#Ns c8t|jSr)rr)r0C_1s ryrz#constant_renumber..Rs)#((3-8rct|tr|Dcgc] }| }}t|St|tr,t|j|j St |tttfvr|js|js|S|jr|S|vr|vrj||S|js |jr-|j|j Dcgc] }| c}St#|j }|j%|j|Dcgc] }| c}Scc}wcc}wcc}w)z@ We need to have an internal recursive function r)r~rrrrrrrrr is_Functionr is_Piecewiseris_Powrrrr) rr renumberedr sortedargs_constant_renumberconstants_foundconstantsymbolssort_keys ryrz-constant_renumber.._constant_renumberTsM dE "9=>A,Q/>J>*% % dH %"488,"488,. . :c3_ ,T5E5EDHHo.K   K _ $?*&&t,K   49915;A$Q';= =diiJ OOO )499jI1!4IJ J3?*<JsE?E! E&T) simultaneous)r~rrrqrrrrnamer8rOnerzipr)rrrr isconstantriter_constantscir subs_dictrrrrrs ` @@@@@ryrrsGd$dE*+tDz+E4L"+,HI I N (( |i78E D *.*;*;T3z#((?S3T)#yQNNO "1 12B; 1C 8H KB d #D#2HQQi5GqHOS.9:I 99YT9 2D KuU 2NIsD9 D9 D>> EEcb|dk(r|}|S|jds|j}|S|}|S)z Converts a solution with Integrals in it into an actual solution. For most hints, this simply runs ``expr.doit()``. rOr)endswithr)rrrrs ryrrsE 66 J ]]; 'iik J Jrc :|s tdt|}t|}|jtt ry|j s|js |jrtjStdt}t}|Dcgc]}t|ds|c}D]i}t|j}|j|ryt!|}|j#||}|j%||j'|k|j)||j*|zsyt-|t.r7t1|jdgt3|dk7rdStjStdd } t5|j#|Dcgc] }|| |zf c}| gd | } | tj6urtjS| j9| d \}} | j;\} } | | k(r| Sycc}wcc}w) a Returns the order `n` if `g` is homogeneous and ``None`` if it is not homogeneous. Determines if a function is homogeneous and if so of what order. A function `f(x, y, \cdots)` is homogeneous of order `n` if `f(t x, t y, \cdots) = t^n f(x, y, \cdots)`. If the function is of two variables, `F(x, y)`, then `f` being homogeneous of any order is equivalent to being able to rewrite `F(x, y)` as `G(x/y)` or `H(y/x)`. This fact is used to solve 1st order ordinary differential equations whose coefficients are homogeneous of the same order (see the docstrings of :obj:`~sympy.solvers.ode.single.HomogeneousCoeffSubsDepDivIndep` and :obj:`~sympy.solvers.ode.single.HomogeneousCoeffSubsIndepDivDep`). Symbols can be functions, but every argument of the function must be a symbol, and the arguments of the function that appear in the expression must match those given in the list of symbols. If a declared function appears with different arguments than given in the list of symbols, ``None`` is returned. Examples ======== >>> from sympy import Function, homogeneous_order, sqrt >>> from sympy.abc import x, y >>> f = Function('f') >>> homogeneous_order(f(x), f(x)) is None True >>> homogeneous_order(f(x,y), f(y, x), x, y) is None True >>> homogeneous_order(f(x), f(x), x) 1 >>> homogeneous_order(x**2*f(x)/sqrt(x**2+f(x)**2), x, f(x)) 2 >>> homogeneous_order(x**2+f(x), x, f(x)) is None True z)homogeneous_order: no symbols were given.Nr)rurvrrrT)positiverFrB)rrrrr-r is_Numberis_NumberSymbolrrrjr8rgetattrrrrprremoverrrr~r homogeneous_orderrqr2rrD as_base_exp)rrrsymsetdumnewsymsrFrwiargsdummyvarrrErrrs ryrrsT DEE \F B vveZ    vv  #5 1CeG =A71m#* :sH$H H c |jd}|j}t|d\}}tdd}t d} t d|g } |d } |d } ||d } ||d }||d}i}t d}|||f|||z|f||dz z||z| fg}t |D]%\}}|ds tt|d|| z ||z zzj||| z}|jr |j}n|g}|D]}|j| || zz}|d|| z}|| js*|j|||| j|dz }|| j||}|r;tt|D]#}|j||s|||<|dz||<t j"||<(t j"}|j%}|j'}t)|}t+|rCt-|} |D]3}||}!|!| k7st|!| D]}||j||!z }5i}"|rk|j/t0}#t3|#dk(rd|"|#j5<n4t-|#d}$t7||$}%t9|%t:r|%d}%|%|"|$<|j/t0}#t-|#d}$t=|#d}&|&jdjrd}'n"|&jdj|d }'|$}(t7||$})t9|)t:r|)d})t3|"j%D*cgc]}*|*s|* c}*}+t|+| dz D]A},|)j||'}-|(j||'}.|-j|"}/|/|"|.<|'dz }'C|||| z zz}0|"D]I}|"|s |jd}1|0|"|j|d|f|d|fg|| z |1zzz }0Kt?tA|0||gtC|| zz}0tE|||0Scc}*w)a Gives a power series solution to a second order homogeneous differential equation with polynomial coefficients at an ordinary point. A homogeneous differential equation is of the form .. math :: P(x)\frac{d^2y}{dx^2} + Q(x)\frac{dy}{dx} + R(x) y(x) = 0 For simplicity it is assumed that `P(x)`, `Q(x)` and `R(x)` are polynomials, it is sufficient that `\frac{Q(x)}{P(x)}` and `\frac{R(x)}{P(x)}` exists at `x_{0}`. A recurrence relation is obtained by substituting `y` as `\sum_{n=0}^\infty a_{n}x^{n}`, in the differential equation, and equating the nth term. Using this relation various terms can be generated. Examples ======== >>> from sympy import dsolve, Function, pprint >>> from sympy.abc import x >>> f = Function("f") >>> eq = f(x).diff(x, 2) + f(x) >>> pprint(dsolve(eq, hint='2nd_power_series_ordinary')) / 4 2 \ / 2\ |x x | | x | / 6\ f(x) = C2*|-- - -- + 1| + C1*x*|1 - --| + O\x / \24 2 / \ 6 / References ========== - https://tutorial.math.lamar.edu/Classes/DE/SeriesSolutions.aspx - George E. Simmons, "Differential Equations with Applications and Historical Notes", p.p 176 - 184 rrrrT)integerrrHrrrr r r rrlc |jdSrrrs ryrz/ode_2nd_power_series_ordinary..X saffQirrc |jdSrrrs ryrz/ode_2nd_power_series_ordinary..` affQirc |jdSrrrs ryrz/ode_2nd_power_series_ordinary..a rrrP)#rrrzrrr rQr1rrrr is_SymbolrDreversedrorrjrkeysrrlmaxrr rrr7r~rrr/rr-r)2rrrrrrrC0r rrrHrrrrr seriesdictrecurr coefflistindexrraddargsr0powmtermstartindrwteqsuminitrkeysreqmaxvalr finaldictfargsmaxfrminf startiterrrrtcounterrr1nlhsnrhsr.facts2 ryode_2nd_power_series_ordinaryr<sH ! A A #BA .FB c4 A S A S1#A tB 'NE eDkA eDkA eDkAJ c]F)Q!F1I+q!1Aq1uIfQi4G3KLI!),. u 8q1r6QY*?!? E EaR PQRByy''$ .yy1a4(QxQ'Aw((99QDG,B,B1,Ea,H(HID7<<51%eHo6"#yyA/0Jt,/01uJt,! "()vvJt$# ..6 &&C!G OO E u+C 7|W -DT"Cf}sF+-A499Q,,C- - I  ,' u:?%&Ieiik "u$78DT"C#t$!f!IdO IIl #E u/ 0D u/ 0D yy| YYq\003A66 C d C#t!fy//17!QA78H 8UQY 'I&xx9%zz)$ $Q "a"f+ F T?99Q>> from sympy import dsolve, Function, pprint >>> from sympy.abc import x >>> f = Function("f") >>> eq = x*(f(x).diff(x, 2)) + 2*(f(x).diff(x)) + x*f(x) >>> pprint(dsolve(eq, hint='2nd_power_series_regular')) / 6 4 2 \ | x x x | / 4 2 \ C1*|- --- + -- - -- + 1| |x x | \ 720 24 2 / / 6\ f(x) = C2*|--- - -- + 1| + ------------------------ + O\x / \120 6 / x References ========== - George E. Simmons, "Differential Equations with Applications and Historical Notes", p.p 176 - 184 rrrrrrrrrl)rrrc34K|]}|jywr)is_real)rrs ryrz/ode_2nd_power_series_regular.. s5( 5(r)r1N)rrrzrrrr.r~r-rrjr7rrrrr _frobenius is_integerintrr/)rrrrrrrr%r rrrrrindicialr,r0p0q0sollistserdict1serdict2m1m2 finalseries1rpower finalseries2s ryode_2nd_power_series_regularrN sBl ! A A #BA .FB c A tB 'NE c A c AHA xx{ OOD !$!qR0D$&'99C771: , FBAq1uI"$r)1-G:gt,5(&5(2( w<1 kkm #BRxzQ!A$e --!%(1*b"b!QArJHBBBwRB"%(1*b"b!QArJHG''%eBhqj"b"aB2N&eBhqj"b"aB2UWX L >CHHQRL) q2vo ==  >FR< 4L66L#BC -E HSM1r6E/$AALB" !B|L8 adGL<$?R!!U(O,- - 52(,wrc ,t|}| } td} tdd} t|dzD cgc] } t | } } g}||fD]}|j |rOt ||j|kr2|r|j|||z}t ||j}nJt|||dz}t tt|jdd|j}t|dzD]} | f|vs tj|| f<|j!||d}|d}| | dz z| |zz|z}i}td|dzD]} |||| fz|| fzz}td| D];}t#dt%|z}|||||z|| |z fz|| |z fzzz }=| #| | |z k(r|ry tj|| | <| |j| || zz || | <|Scc} w) z\ Returns a dict with keys as coefficients and values as their values in terms of C0 rrr)rtrl)rrNrF)rBrr8rorprr(degreeras_dictr.rrrrrjrrr)rrrDrErrrrrr1rJrnumsymsrwserlistserdict_tseriespseriesqseriesrCfrobdictrsrFrs ryr@r@ sQ AA B c As!,G&+AEl3tG}3G3G1v   Q DaL$7$7$9Q$>hhq!b&)aL((*ESB!A#.Gggll34Tr:A>FFHEq1u %At5 ffqd  % u"ajGajG!a%y1R4"$HH 1a!e_@7A4=7A4=01q! QAs1v&C 8C=1q5'1q5(*;";gq1uh>O"OP PC Q >a26k'(vv$$'4q!A#)>#?HWQZ @" OQ4sHcfd}g}|D]N}|jD](}|||r!|||s|j|*|j|P|S)ax Remove redundant solutions from the set of solutions. This function is needed because otherwise dsolve can return redundant solutions. As an example consider: eq = Eq((f(x).diff(x, 2))*f(x).diff(x), 0) There are two ways to find solutions to eq. The first is to solve f(x).diff(x, 2) = 0 leading to solution f(x)=C1 + C2*x. The second is to solve the equation f(x).diff(x) = 0 leading to the solution f(x) = C1. In this particular case we then see that the second solution is a special case of the first and we do not want to return it. This does not always happen. If we have eq = Eq((f(x)**2-4)*(f(x).diff(x)-4), 0) then we get the algebraic solution f(x) = [-2, 2] and the integral solution f(x) = x + C1 and in this case the two solutions are not equivalent wrt initial conditions so both should be returned. c"t||Sr)_is_special_case_of)soln1soln2rrrvars ryis_special_case_ofz7_remove_redundant_solutions..is_special_case_ofF s"5%UC@@r)rrr)rrsolnsrr_r` unique_solnsr]r^s` `` ryrr/ st.AL'!&&( 'E!%/#E51##E*  '    &' rc0|j|jz }|j|jz }|jtrX|jtrC|j |j k(r!|j }|j }n,y|jts|jtry|j j|j }|j j|j }tt||t|}t|dk(r|h}t||D]\}} |j|| }|} |} t| | g} td|D]A} | j} | j} t| | }| j!|Ct#d| Dry| Dcgc]}t%|t&r|} } t)| |}t%|t,r|g}|D]3}| D],}|j|jz }t/||dus+y5|D]&}t#fd|j1Dr&yycc}w#t*$rYywxYw)z True if soln1 is found to be a special case of soln2 wrt some value of the constants that appear in soln2. False otherwise. Frlc3<K|]}t|tywr)r~r")rrrs ryrz&_is_special_case_of.. s 7B:b, ' 7rTc3@K|]}|jywrrg)rrr_s ryrz&_is_special_case_of.. s>!155:>s)rrrr-getOremoveOrrrzrrrrrrorrrlr~r!r7rrr6r)r]r^rrrr_ constants1 constants2constants1_newc_oldc_newrreqnsrconstant_solns constant_solns ` ryr\r\U sQ& II !E II !E yyEIIe, ::<5::< 'MMOEMMOE 5 UYYu-##..r?J##..r?J+E%,?ZQN :!()J7) u 5%() C C sCL>D 1e_hhsmhhsm S\ B  7$ 77 A2ZK%@B AD AtZ0 .$'()(  Bvvbff}BM*$6 ( >}';';'=>> 1 B s$J:J J JJc|jd}|d}|j}||d ||dz }|d}|d} |d} |} |st||| S| } | dkDrw|j|||| i} | j t s*| j t s| j trt||t S| r | | ||z zz } td | D]}| j|| j||zz}|j|||| i}|j t s@|j t s+|j t s|j trt||t cS| |||z |zzt|z z } |} | t|| zz } t||| S) aH The power series solution is a method which gives the Taylor series expansion to the solution of a differential equation. For a first order differential equation `\frac{dy}{dx} = h(x, y)`, a power series solution exists at a point `x = x_{0}` if `h(x, y)` is analytic at `x_{0}`. The solution is given by .. math:: y(x) = y(x_{0}) + \sum_{n = 1}^{\infty} \frac{F_{n}(x_{0},b)(x - x_{0})^n}{n!}, where `y(x_{0}) = b` is the value of y at the initial value of `x_{0}`. To compute the values of the `F_{n}(x_{0},b)` the following algorithm is followed, until the required number of terms are generated. 1. `F_1 = h(x_{0}, b)` 2. `F_{n+1} = \frac{\partial F_{n}}{\partial x} + \frac{\partial F_{n}}{\partial y}F_{1}` Examples ======== >>> from sympy import Function, pprint, exp, dsolve >>> from sympy.abc import x >>> f = Function('f') >>> eq = exp(x)*(f(x).diff(x)) - f(x) >>> pprint(dsolve(eq, hint='1st_power_series')) 3 4 5 C1*x C1*x C1*x / 6\ f(x) = C1 + C1*x - ----- + ----- + ----- + O\x / 6 24 60 References ========== - Travis W. Walker, Analytic power series technique for solving first-order differential equations, p.p 17, 18 rrrrrrrrlr) rrrrrrrrrorr&r-)rrrrrrrrhrrrFr.hc factcountFnewFnewcs ryode_1st_power_seriesrw sN ! A c A A uSz 5s,,A $KE 'NE 'NE A !A$F qy VVQq%( ) 66":s adB<   b!e)n $F1e_ vvay166!9Q;& 1eQ./ 99R=EIIcNeiin #adB< %!e)i/091EEE  eAuHoF adF rcDt|tr|j|jz }|st |\}}|j }t |dk7r td|d}|s t||}|dk7r td|j|}td|g}td|g}tt||j||z|z} | rt| || |z  } n t!||} | d} t#d } | j%|| } t'd || } t'd || }t'd ||}t'd ||}|j||j| | j|z | zz| j| | d zzz | | j|zz || j| zz }g}|D]} | t)| |j%|| |t)| |j%|| i}t|j%|j+} | r$|j-d | j%| |f|j-d|S#t$r tdwxYw)a= This function is used to check if the given infinitesimals are the actual infinitesimals of the given first order differential equation. This method is specific to the Lie Group Solver of ODEs. As of now, it simply checks, by substituting the infinitesimals in the partial differential equation. .. math:: \frac{\partial \eta}{\partial x} + \left(\frac{\partial \eta}{\partial y} - \frac{\partial \xi}{\partial x}\right)*h - \frac{\partial \xi}{\partial y}*h^{2} - \xi\frac{\partial h}{\partial x} - \eta\frac{\partial h}{\partial y} = 0 where `\eta`, and `\xi` are the infinitesimals and `h(x,y) = \frac{dy}{dx}` The infinitesimals should be given in the form of a list of dicts ``[{xi(x, y): inf, eta(x, y): inf}]``, corresponding to the output of the function infinitesimals. It returns a list of values of the form ``[(True/False, sol)]`` where ``sol`` is the value obtained after substituting the infinitesimals in the PDE. If it is ``True``, then ``sol`` would be 0. rlz(ODE's have only one independent variablerzRLie groups solver has been implemented only for first order differential equationsrrrz9Infinitesimals for the first order ODE could not be foundrrrrF)Tr)r~rrrr<rrrr=rrrr/rrr3r7rrr rrr)rrinfinitesimalsrrrrr#rrrrqrrrrdxidetapdesoltuptsols ry checkinfsolr s4"h VVbff_ r?D I 9~CDD aLb$'E A:%':; ;1BSRD)ASRD)AF2J+11!B$(;EeAhuQx/00B-C AAc AtQA$1%B!(5/!Q'C (4.D)C"8E?1d+D88A;#((1+ ":A!==QT!"$&q N358!&&)_ECF% -Ac#hK,,T153t9**435sxx~2245MM5#((1d*;"<=MM), -M/+>-/=>>>s 2 J Jc t|ddj}|ddj}|d}|d}|d}i}tt|djtdjtd}t dD]=}t t j||D cgc]} | ||||dfz c} ||<?|d||df |d||dfz |d<|d||df |d||dfz |d<|d||df |d||dfz |d <|d||df |d||dfz |d <tjtjg} t dD]K}t j||D].} | j||||r"| |xx| z cc<0M| dj|s%| dj|s| d|d <| d|d <n td |ddk(rt|||||} |ddk(rt|||||}  Scc} w)NrrrlrOrrrrrrrk1k2zDOnly homogeneous problems are supported (and constant inhomogeneity)rrhri)rrrr rrorrkrrjrr_linear_2eq_order1_type6_linear_2eq_order1_type7) match_rrrrnrrrrrwrrorFrs rysysode_linear_2eq_order1r= s|vqAvqA &>D  B B A T"Q%++j) *1 - 3 3F ;d;ddS!!$ck 1266v3r(1S6AcF1H+Z[\_Z`K` `B 3#qv #qvqy 0 04#q>!C&3H H1S6RVWXY\W]^_R`K` `B 3#3# &afQ 7B 3#3# &afQ 7B QwafT!A$q^+bad1o=>BBd1Q4lQsVD[01S6!A$;>?CC qafT!A$q^+bad1o=>BBd1Q4lQsVAaD[01S6$;>?CC3i__Q AcF(:d1Q4!n1S6 4!Q<'??2af9aPQdBRRSWWd1Q4lQsVD[01S6!A$;>?CC3i__Q AcF(:d1Q4!n1S6 4!Q<'??2af9aPQdBRRSWWd1Q4lQsVAaD[01S6$;>?CC Xd^A  Xd^A  3" # 3" #"ur"uXafQhqjQ&6:::"ur1Q3r6Bx#q 2q50@!'D$DDEE qtTNBqtTN ++rcZ|d}|d}|d}tt|djtdjtd}|ddk(rt |||}|S|dj }|dj }t dD]7}d} tj||D]} | | ||||dfz z } | ||<9|dd k(rt||||}|S|dd k(rt||||}|S|dd k(rt||||}|S|dd k(rt||||}S) NrrrrOrrrxrlrrrrr) rrr r_nonlinear_2eq_order1_type5rrorrk_nonlinear_2eq_order1_type1_nonlinear_2eq_order1_type2_nonlinear_2eq_order1_type3_nonlinear_2eq_order1_type4) rrrrrnrrrrrwrErs rysysode_nonlinear_2eq_order1r s~ &>D B  B T"Q%++j) *1 - 3 3F ;"# Jrc t|d\}}td||||g}td}td\}} |djt |||t |||z|zz } t ||||dz | |z j ||| } | |j |||j ||| } | |}|r%d |z t||td| z | zz z} n|td| z | z} | j} ttd| | j || zz | j|z |z | }g}|D]T}|jt||| j | ||jt|||V|S) a Equations: .. math:: x' = e^{\lambda x} F(x,y) .. math:: y' = g(y) F(x,y) Solution: .. math:: x = \varphi(y), \int \frac{1}{g(y) F(\varphi(y),y)} \,dy = t + C_2 where if `\lambda \neq 0` .. math:: \varphi = -\frac{1}{\lambda} log(C_1 - \lambda \int \frac{1}{g(y)} \,dy) if `\lambda = 0` .. math:: \varphi = C_1 + \int \frac{1}{g(y)} \,dy where `C_1` and `C_2` are arbitrary constants. rrrrrrtrrlr) rzrrrrr#rr$r'rr7rrrs ryrr s2$BA .FB S1Q4!+&A S A 6?DAq 1 D1aL3q1v;q=01A qtA,A ! $**1Q42A ! !A$qqtA&A !Ad3rAhqsA...//8AaC## ((*C !Qqvva}_-q16681"# Jrc t|d\}}}}td}td} td} td} |dj t |||| z } |dj t |||| z } | | j ||| j |||| }| | j ||| j |||| }ttt || | ||z }t|tr|g}|D]O}ttd|j || |jz | j|z |z | }Qg}D]^}|jt||||jt||jj | |`|S) a Autonomous system of general form .. math:: x' = F(x,y) .. math:: y' = G(x,y) Assuming `y = y(x, C_1)` where `C_1` is an arbitrary constant is the general solution of the first-order equation .. math:: F(x,y) y'_x = G(x,y) Then the general solution of the original system of equations has the form .. math:: \int \frac{1}{F(x,y(x,C_1))} \,dx = t + C_1 rrr|r{rrsrrl)rzr rrrrrrrr~rr7r'rrr)rrrrrr rrrr|r{rrsryrzrrGsol2rsol2srrrs ryrrG s$,BA6NBB As A S A S A AT!A$q\A% &B AT!A$q\A% &B 1 1Q4  1qt,A 1 1Q4  1qt,A 2d1Q4mQqS) *E%"PXaqtUYY 77;@@BQFKQOP C8 2adD>" 2adUYY,,Q5678 Jrct|d\}}td\}}tdt\}} td} td} td||g } td ||g } td ||g }td ||g }|d j t |||| z }|dj t |||| z }|| j |||j ||||| j |||j |||z j\}}|j | |z}|j | |z}|| j |||j ||||z }|| }|| }||}||}tt||z |jt||z |jz |z |}tt||z |jt||z |jz |z |}g}|D]}|jt||tt | |||j ||j || ||j || |z|j ||j || |zz j|D]}|jt||tt ||||j ||||j ||j |||z|j ||j |||zz jt|S)a Equation: .. math:: x' = f_1(x) g_1(y) \phi(x,y,t) .. math:: y' = f_2(x) g_2(y) \phi(x,y,t) First integral: .. math:: \int \frac{f_2(x)}{f_1(x)} \,dx - \int \frac{g_1(y)}{g_2(y)} \,dy = C where `C` is an arbitrary constant. On solving the first integral for `x` (resp., `y` ) and on substituting the resulting expression into either equation of the original solution, one arrives at a first-order equation for determining `y` (resp., `x` ). rrrtzU, Vrurrsr~rrrrrrl)rzrr rrrrrr7r'rrrrrr)rrrrrr rr{r|UVrrsr~rrrryrzrsr/rrrrrG1G2sol1rrrrs ryrrm s}&$BA .FB 6?DAq 6x (DAq S A S A dQqE "B dQqE "B dQqE "B dQqE "B AT!A$q\A% &B AT!A$q\A% &B AAaD  1a ( AAaD  1a ( *+9>+; C 2b5 B 2b5 B a5::ad1  " "1Q4 *C /C BBbf BBbf (2b5!$))+hr"uQ.?.D.D.FFKQ OE (2b5!$))+hr"uQ.?.D.D.FFKQ OE CD 2adF4!Q<"''!D/2F2Fq12NrwwWXYZ[\Y]2^_b_g_ghijn_o_t_tuvwxyzw{_|2|#|}BBC DDD 2adF4!Q<"''!AaD/"''!D/BVBVWXYZ[\Y]B^2^_b_g_ghijn_o_t_tuvwxyzw{_|2|#|}BBC DD s8Orc T td\}}td td fd}|D]X}t|ts|ddj}|ddj}|||\} } | r| rI|||\} } ||}}Zt } t } t ||z j| |j| |zt ||z j| |j| |zhS)a Clairaut system of ODEs .. math:: x = t x' + F(x',y') .. math:: y = t y' + G(x',y') The following are solutions of the system `(i)` straight lines: .. math:: x = C_1 t + F(C_1, C_2), y = C_2 t + G(C_1, C_2) where `C_1` and `C_2` are arbitrary constants; `(ii)` envelopes of the above lines; `(iii)` continuously differentiable lines made up from segments of the lines `(i)` and `(ii)`. rrrrsctdjt|z|z z}djt|z|z z}|r|sldjt||z z z z}djt||z z z z}|r|shd jt|z|z z}d jt|z|z z}|r|snd jt||z z z z}d jt||z z z z}||gS)Nrrl)rr)rrryrzrrrrsrs ryr}z/_nonlinear_2eq_order1_type5..check_type s U[[4!Q<!A$.2 3 U[[4!Q<!A$.2 3rAT!A$q\AaDF2QqS89BAT!A$q\AaDF2QqS89Bra5&$qtA,1 5 9:Ba5&$qtA,1 5 9:Bra5&QqT! qtAv 5! ;HHtAaD|be#QqT) 0 01Q4! => qT "FB qT "FB qT "FB Abd2a4Abd2a4"Qr!tBqDA1Q% HC FCF D DG " " $Q 'a)?)?)A!)DEA Q QA Q QA 2bAqsGAaD!GO+a1g6 7C 2bAqsGAaD!GO+a1g6 7C 2bAqsGAaD!GO+a1g6 7C 2bAqsGAaD!GO+a1g6 7C 2bAqsGAaD!GO+a1g6 7C 2bAqsGAaD!GO+a1g6 7C !D1aL.AaC9S=1#55 6D !D1aL.AaC9S=1#55 6D !D1aL.AaC9S=1#55 6D $ rc  t|d}td\}}}tdt\} } } td|||||||g} td|||||||g} td|||||||g}td t\}}}t ||||d z j ||z }t ||j ||z}|jt ||j | |z|dj||r;|dj||s$||||c||<||<||  || c||<|| <|jt ||||dz j | ||z|||zz || }|| }||}||j|||j|||j|||}||j|||j|||j|||}||j|||j|||j|||}|||zz ||zz |z }|||zz ||zz |z }|||zz ||zz |z }tt | ||||z||zz ||z||zz z j||j|| |z j}tt | ||||z||zz ||z||zz z j||j|| |z j}tt | ||||z||zz ||z||zz z j||j|| |z j}tt | ||||z||zz ||z||zz z j||j|| |z j}tt | ||||z||zz ||z||zz z j||j|| |z j}tt | ||||z||zz ||z||zz z j||j|| |z j}tt | ||||z||zz j||j||j|| |z j} tt | ||||z||zz j||j||j|| |z j}!tt | ||||z||zz j||j||j|| |z j}"| |!|"gS) a Equations: .. math:: x' = c F_2 - b F_3, \enspace y' = a F_3 - c F_1, \enspace z' = b F_1 - a F_2 where `F_n = F_n(x, y, z, t)`. 1. First Integral: .. math:: a x + b y + c z = C_1, where C is an arbitrary constant. 2. If we assume function `F_n` to be independent of `t`,i.e, `F_n` = `F_n (x, y, z)` Then, on eliminating `t` and `z` from the first two equation of the system, one arrives at the first-order equation .. math:: \frac{dy}{dx} = \frac{a F_3 (x, y, z) - c F_1 (x, y, z)}{c F_2 (x, y, z) - b F_3 (x, y, z)} where `z = \frac{1}{c} (C_1 - a x - b y)` References ========== -https://eqworld.ipmnet.ru/en/solutions/sysode/sode0404.pdf rlrrrurrrr F1, F2, F3r) rzrr rrrr5rrrrr)#rrrrrrr r{r|r?fufvfwrrrrrrryrrrrz_xyy_zxx_yzrrrrrrrrrs# ryrrH s8  *Bi GAq!1JBB S1Q41qtQ/0A S1Q41qtQ/0A S1Q41qtQ/0A40JBB qtQ-"Q%  & &r"u -Bbf##AbD)AHH]2b6 " ( (2 ./ !uyy21 !B% 0uae "qudUQqTE !adHHd1Q4mbe# * *1QrU7QqT"W+< => !A!A$aAaD 2AaD!  ! !!A$q ) . .qtQ 7B 2AaD!  ! !!A$q ) . .qtQ 7B 2AaD!  ! !!A$q ) . .qtQ 7B qsF1Q3J>D qsF1Q3J>D qsF1Q3J>D beA1R4"9qtAbDy"9!?!?$!G!L!LQrRSu!UU V Z ZC beA1R4"9qtAbDy"9!?!?$!G!L!LQrRSu!UU V Z ZC beA1R4"9qtAbDy"9!?!?$!G!L!LQrRSu!UU V Z ZC beA1R4"9qtAbDy"9!?!?$!G!L!LQrRSu!UU V Z ZC beA1R4"9qtAbDy"9!?!?$!G!L!LQrRSu!UU V Z ZC beA1R4"9qtAbDy"9!?!?$!G!L!LQrRSu!UU V Z ZC $r!uQ-1R4!B$;"4"4Qs";"@"@3"G"L"LQrRSu"UU V Z ZD $r!uQ-1R4!B$;"4"4Qs";"@"@3"G"L"LQrRSu"UU V Z ZD $r!uQ-1R4!B$;"4"4Qs";"@"@3"G"L"LQrRSu"UU V Z ZD $ rc  t|d}td\}}}td|||||||g} td|||||||g} td|||||||g} tdt \} } }|d jt |||||| zz |||zz}t || j| | z}|j t ||j| |z|dj|| r;|dj||s$|||| c|| <||<||  ||  c|| <|| <|j t ||||dz j| ||z||z|| ||z| zz || }|| }|| }|| j|||j|||j|||} || j|||j|||j|||} ||j|||j|||j|||}t|||d zzz ||d zzz |z }t|||d zzz ||d zzz |z }t|||d zzz ||d zzz |z }tt |||||z|z||z| zz ||z| z||z|zz z j||j|||z j}tt |||||z| z||z| zz ||z| z||z|zz z j||j|||z j}tt |||||z| z||z| zz ||z|z||z| zz z j||j|||z j}tt |||||z| z||z|zz ||z|z||z| zz z j||j|||z j}tt |||||z|z||z| zz ||z| z||z| zz z j||j|||z j}tt |||||z| z||z|zz ||z| z||z| zz z j||j|||z j}tt |||||z| z||z|zz j||j||j|||z j}tt |||||z|z||z| zz j||j||j|||z j}tt |||||z| z||z| zz j||j||j|||z j}|||gS) a Equations: .. math:: x' = c z F_2 - b y F_3, \enspace y' = a x F_3 - c z F_1, \enspace z' = b y F_1 - a x F_2 where `F_n = F_n (x, y, z, t)` 1. First integral: .. math:: a x^{2} + b y^{2} + c z^{2} = C_1 where `C` is an arbitrary constant. 2. Assuming the function `F_n` is independent of `t`: `F_n = F_n (x, y, z)`. Then on eliminating `t` and `z` from the first two equations of the system, one arrives at the first-order equation .. math:: \frac{dy}{dx} = \frac{a x F_3 (x, y, z) - c z F_1 (x, y, z)} {c z F_2 (x, y, z) - b y F_3 (x, y, z)} where `z = \pm \sqrt{\frac{1}{c} (C_1 - a x^{2} - b y^{2})}` References ========== -https://eqworld.ipmnet.ru/en/solutions/sysode/sode0405.pdf rlrrrrrrrrurr) rzrrrrr5rrrr%rr) rrrrrrr r{r|r?rrrrrrryrrrrrrrrrrrrrrrrs ryrr s8  *Bi GAq! S1Q41qtQ/0A S1Q41qtQ/0A S1Q41qtQ/0A40JBB AT!A$q\AaDG+ad2g5 6Bbf##AbD)AHH]2b6 " ( (2 ./ !uyy21 !B% 0uae "qudUQqTE !adHHd1Q4lRU" ) )!AaD&2,1ad2*E FG !A!A$aAaD 2AaD  1a ( - -ad1 5B 2AaD  1a ( - -ad1 5B 2AaD  1a ( - -ad1 5B a1fqAv%q( )D a1fqAv%q( )D a1fqAv%q( )D ad1!A#b&1R-!A#b&1R-!@ F Fq N S STUVWXYVZ [[ \ ` `C ad1!A#b&1R-!A#b&1R-!@ F Fq N S STUVWXYVZ [[ \ ` `C ad1!A#b&1R-!A#b&1R-!@ F Fq N S STUVWXYVZ [[ \ ` `C ad1!A#b&1R-!A#b&1R-!@ F Fq N S STUVWXYVZ [[ \ ` `C ad1!A#b&1R-!A#b&1R-!@ F Fq N S STUVWXYVZ [[ \ ` `C ad1!A#b&1R-!A#b&1R-!@ F Fq N S STUVWXYVZ [[ \ ` `C $qtA,!A#b&1Q3r6/!7!7#!>!C!CAc!J!O!OPQRSTURV!WW X \ \D $qtA,!A#b&1Q3r6/!7!7#!>!C!CAc!J!O!OPQRSTURV!WW X \ \D $qtA,!A#b&1Q3r6/!7!7#!>!C!CAc!J!O!OPQRSTURV!WW X \ \D $ rc h t|d}td\}}}tdt\} } } td|||||||g} td|||||||g} td|||||||g}td t\}}}|d j t ||||||zz |||zz}t ||j ||z}|jt ||j | |z|dj||r;|dj||s$||||c||<||<||  || c||<|| <|jt ||||dz j ||| ||z|||zz z|| }|| }||}||j|||j|||j|||}||j|||j|||j|||}||j|||j|||j|||}||| zz|| zz| z}||| zz|| zz| z}||| zz|| zz| z}tt | |||||z||zz z|||z||zz zz j||j|| |z j}tt | |||||z||zz z|||z||zz zz j||j|| |z j}tt | |||||z||zz z|||z||zz zz j||j|| |z j}tt | |||||z||zz z|||z||zz zz j||j|| |z j}tt | |||||z||zz z|||z||zz zz j||j|| |z j}tt | |||||z||zz z|||z||zz zz j||j|| |z j}tt | |||||z||zz zj||j||j|| |z j} tt | |||||z||zz zj||j||j|| |z j}!tt | |||||z||zz zj||j||j|| |z j}"| |!|"gS) aB .. math:: x' = x (c F_2 - b F_3), \enspace y' = y (a F_3 - c F_1), \enspace z' = z (b F_1 - a F_2) where `F_n = F_n (x, y, z, t)` and are arbitrary functions. First Integral: .. math:: \left|x\right|^{a} \left|y\right|^{b} \left|z\right|^{c} = C_1 where `C` is an arbitrary constant. If the function `F_n` is independent of `t`, then, by eliminating `t` and `z` from the first two equations of the system, one arrives at a first-order equation. References ========== -https://eqworld.ipmnet.ru/en/solutions/sysode/sode0406.pdf rlrrrurrrrrr) rzrr rrrr5rrrrr)#rrrrrrr r{r|r?rrrrrrrrrryrrrrrrrrrrrrrrrrs# ryrr s&  *Bi GAq!1JBB S1Q41qtQ/0A S1Q41qtQ/0A S1Q41qtQ/0A40JBB AT!A$]QqT"W,qtBw6 7Bbf##AbD)AHH]2b6 " ( (2 ./ !uyy21 !B% 0uae "qudUQqTE !adHHd1Q4mbe# * *1Q41R51Q471B+C DE !A!A$aAaD 2AaD!  ! !!A$ * / /!a 8B 2AaD!  ! !!A$ * / /!a 8B 2AaD!  ! !!A$ * / /!a 8B q1"uHQUNaR D q1"uHQUNaR D q1"uHQUNaR D beQAqtad{Oa2"o#F"L"LQPT"U"Z"Z[\^`ab^c"dd e i iC beQAqtad{Oa2"o#F"L"LQPT"U"Z"Z[\^`ab^c"dd e i iC beQAqtad{Oa2"o#F"L"LQPT"U"Z"Z[\^`ab^c"dd e i iC beQAqtad{Oa2"o#F"L"LQPT"U"Z"Z[\^`ab^c"dd e i iC beQAqtad{Oa2"o#F"L"LQPT"U"Z"Z[\^`ab^c"dd e i iC beQAqtad{Oa2"o#F"L"LQPT"U"Z"Z[\^`ab^c"dd e i iC $r!ua.Aqtad{O#9#9!S#A#F#Fq##N#S#STUWYZ[W\#]] ^ b bD $r!ua.Aqtad{O#9#9!S#A#F#Fq##N#S#STUWYZ[W\#]] ^ b bD $r!ua.Aqtad{O#9#9!S#A#F#Fq##N#S#STUWYZ[W\#]] ^ b bD $ r)rrr)rlrlr)rlr)NrTNNNr)TN)NFNr)T)NN)__doc__ sympy.corerrrrrsympy.core.containersrsympy.core.exprr r sympy.core.functionr r r rrrrsympy.core.multidimensionalrsympy.core.numbersrrrsympy.core.relationalrrsympy.core.sortingrrsympy.core.symbolrrrrsympy.core.sympifyrsympy.core.traversalrsympy.logic.boolalgr r!r"sympy.functionsr#r$r%(sympy.functions.combinatorial.factorialsr&sympy.integrals.integralsr' sympy.polysr(r)r*r+sympy.polys.polytoolsr, sympy.seriesr-sympy.series.seriesr.sympy.simplifyr/r0r1r2r3r4sympy.simplify.radsimpr5 sympy.solversr6r7sympy.utilitiesr8sympy.utilities.iterablesr9r:r;sympy.solvers.deutilsr<r=r>r rzrnrrrrrrSrTrrUrrrrRrrrrrrr<rNr@rr\rwrrrrrrrrrrrrrrrrsinglerrrr>rryrsdL,+',1//.8::&3..**>.??(&!!0),::BB". d.J$48*+\H~GTdL@dtQUY]@F Qh6nEPNb 1GGTyx 43%j 1||~yx &XvNbx-v2h$LNbGTJZ!F3,j;,|4+Z+Z$L-^/lb$/d5n:x9v1jBAr