当前位置:网站首页>Dsolve function of sympy
Dsolve function of sympy
2022-06-29 10:08:00 【It's mally!】
Notes
translate official sympy Kuzhi ODE
Want to use sympy Solving linear equations , But there is too little information on the Internet , Just want to try to translate .
Later it was found that there was 2 A good blog , Portal 1, Portal 2
User Functions
dsolve The function belongs to this user functions Within the scope of .
These functions use from sympy import * Import global namespace . These functions ( Unlike hint Functions), It is only for ordinary users Sympy.
s y m p y . s o l v e r s . o d e . d s o l v e \color{#008b45}{sympy.solvers.ode.dsolve} sympy.solvers.ode.dsolve
( ∗ e q ∗ , ∗ f u n c = N o n e ∗ , h i n t = ′ d e f a u l t ′ , s i m p l i f y = T r u e , i c s = N o n e , x i = N o n e , ∗ e t a = N o n e ∗ , ∗ x 0 = 0 ∗ , ∗ n = 6 ∗ , k w a r g s ) \color{#008b45}(*eq*, *func=None*, hint='default', simplify=True, ics=None, xi=None, \\*eta=None*, *x0=0*, *n=6*, kwargs) (∗eq∗,∗func=None∗,hint=′default′,simplify=True,ics=None,xi=None,∗eta=None∗,∗x0=0∗,∗n=6∗,kwargs)
Can solve any ( Supported by ) Ordinary differential equations and systems of ordinary differential equations .
For simple ordinary differential equations
Usage
The number of equations in the system of equations is 1,
d s o l v e ( e q , f ( x ) , h i n t ) \color{#008b45}dsolve(eq, f(x), hint) dsolve(eq,f(x),hint) -> Usage method hint In ordinary differential equations eq To solve the problem f(x).
Details
- eq It can be any ordinary differential equation that can be supported . It can be an equation , It can also be an expression , Suppose it equals 0.
- f(x) Its derivatives make up the differential equation . in the majority of cases , We don't need to provide it , It will be calculated automatically ( If it cannot be calculated, an error will be reported )
- hint It's what you want dsolve Solution method used . Use c l a s s i f y _ o d e ( e q , f ( x ) ) \color{#008b45}{classify\_ode(eq, f(x))} classify_ode(eq,f(x)) You can get one ODE All the methods that can be used . By default c l a s s i f y _ o d e ( ) \color{#008b45}{classify\_ode()} classify_ode().
- simplify It can be used o d e s i m p ( ) \color{#008b45}{odesimp ()} odesimp() To simplify the . For more information , See its DocString. for example , Turn this option off to disable func Solution or simplification of any constant . It will still integrate with this hint . Be careful , If this option is enabled , The solution may involve more than ODE The order of more arbitrary constants .
- xi and eta Is an infinitesimal function of an ordinary differential equation . They are infinitesimals of Lie groups of invariant point transformations of differential equations . The user can specify a value for infinitesimal . If not specified ,xi and eta Will be used with the help of various Heuristics i n f i n i t e s i m a l s ( ) \color{#008b45}{infinitesimals()} infinitesimals() Calculate .
- ics Is the initial of the differential equation / Set of boundary conditions . It should be in a form similar to { f ( x 0 ) : x 1 , f ( x ) . d i f f ( x ) . s u b s ( x , x 2 ) : x 3 } \color{#0000ff}{\{f(x0): x1, f(x).diff(x).subs(x, x2): x3\}} { f(x0):x1,f(x).diff(x).subs(x,x2):x3} give . For power series solutions , If no initial condition is specified , Then assume f(0) by c0, The solution of the power series is 0.
- x0 It's the point that needs to be solved .
- n Give the index of the variable to be solved
Hints
Jump first
Tips
- You can declare the derivative of an unknown function like this :
from sympy import Function,Derivative
from sympy.abc import x # x Is an independent variable
f= Function("f")(x) #f yes x Function of
f_=Derivative(f,x) #f_ yes f Yes x The derivative of
- stay test_ord .py You can see a series of how to use d s o l v e ( ) \color{#008b45}{dsolve()} dsolve() An example of .
- d s o l v e ( ) \color{#008b45}{dsolve()} dsolve() Always return an equality class ( Except the hint is all or all_Integral The situation of ). If possible , It will explicitly solve for the function being solved . otherwise , It returns an implicit solution . Any constant is called C1、C2 Symbols for, etc .
- Because all solutions are mathematically equivalent , So for ODE, Some prompts may return identical results . however , Usually two different prompts return the same solution in different formats . The two should be equivalent . Also pay attention to , Sometimes the values of any constant in two different solutions may be different , Because a constant can be “ absorption ” Other constants .
- use h e l p ( o d e . o d e < h i n t n a m e > ) \color{#008b45}{help(ode.ode_<hintname>)} help(ode.ode<hintname>) You can get more information about specific tips , One of them is without _Integral The name of the prompt for .
For ordinary differential equations
Usage
d s o l v e ( e q , f u n c ) \color{#008b45}{dsolve(eq, func)} dsolve(eq,func) -> Xie Changyou x(t),y(t),z(t) And so on eq.
Details
eq It can be an arbitrarily supported system of ordinary differential equations. It can be an equation , It can also be an expression , Suppose it equals 0.
func set up x(t) and y(t) Is a function of a variable , The variable and its partial derivatives constitute a system of ordinary differential equations . It will be automatically detected ( If you cannot detect , Will cause an error ).
Examples
from sympy import Function, dsolve, Eq, Derivative, sin, cos, symbols
from sympy.abc import x
f=Function('f')
ans=dsolve(Derivative(f(x),x,x)+9*f(x),f(x))
print(ans)
#Eq(f(x), C1*sin(3*x) + C2*cos(3*x))
边栏推荐
猜你喜欢

Cisco ASA、FTD和HyperFlex HX的漏洞分析复现

Binding mechanism of JVM methods

RecyclerView 通用适配器封装

zabbix4.4配置监控服务器指标,以及图形页乱码解决

JVM method return address

JVM之方法的绑定机制

Zabbix4.4 configure the indicators of the monitoring server and solve the garbled graphics pages

JVM之对象的内存布局

Flutter 基础组件之 Text

GridView of basic component of shutter
随机推荐
Database common interview questions (with answers)
Flutter 基础组件之 ListView
CodeForces - 1151B 思维
2020-09-18 referer认证 url转义
How to traverse objects in the vector container
弧形 View 和弧形 ViewPager
逆向思维-小故事
Middle order traversal of Li Kou 94 binary tree
A 3D Dual Path U-Net of Cancer Segmentation Based on MRI
Community Union
JNI.h说明
2019.10.27训练总结
另类实现 ScrollView 下拉头部放大
Leetcode MySQL database topic 176
The Stones Game【取石子博弈 & 思维】
sublime text3设置运行自己的Makefile
FreeRTOS (VIII) - time management
Summary of PHP memory horse technology research and killing methods
Recyclerview refreshes blinks and crashes when deleting items
券商经理给的开户二维码办理股票开户安全吗?我想开个户