ODEINT 求解常微分方程(1)
An example of using ODEINT is with the following differential equation with parameter k=0.3, the initial condition y0=5 and the following differential equation.

import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt # function that returns dy/dt
def model(y,t):
k = 0.3
dydt = -k * y
return dydt # initial condition
y0 = 5 # time points
[t,dt] = np.linspace(0,20,retstep=True) # solve ODE
y = odeint(model,y0,t) # another way to do
y1=np.empty_like(t)
y1[0]=y0 for i in range(len(t)-1):
y1[i+1]=y1[i]+dt*model(y1[i],t) # plot results
plt.plot(t,y1,label='y1')
plt.plot(t,y,label='y')
plt.xlabel('time')
plt.ylabel('y(t)')
plt.legend(loc='best')
plt.show()

ODEINT 求解常微分方程(1)的更多相关文章
- ODEINT 求解常微分方程(4)
import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt # function tha ...
- ODEINT 求解常微分方程(3)
import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt # function tha ...
- ODEINT 求解常微分方程(2)
import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt # function tha ...
- MATLAB求解常微分方程:ode45函数与dsolve函数
ode45函数无法求出解析解,dsolve可以求出解析解(若有),但是速度较慢. 1. ode45函数 ①求一阶常微分方程的初值问题 [t,y] = ode45(@(t,y)y-2*t/y, ...
- 欧拉法求解常微分方程(c++)
#include<iostream> #include<iomanip> using namespace std; int main() { double x, y, h; ...
- 改进欧拉公式求解常微分方程(c++)
#include<iostream> #include<iomanip> using namespace std; int main() { double x,y,h,temp ...
- 梯形法求解常微分方程(c++)
#include<iostream> #include<iomanip> using namespace std; int main() { double x,y,yn,h,t ...
- 后退欧拉法求解常微分方程(c++)
#include<iostream> #include<iomanip> using namespace std; int main() { double x,y,yn,h,t ...
- 欧拉法求解常微分方程(c++)【转载】
摘自<c++和面向对象数值计算>,代码简洁明快,采用类进行封装实现代码,增强代码的重用性,通过继承可实现代码的重用,采用函数指针,通用性增强,在函数改变时只需要单独改变函数部分的代码,无需 ...
随机推荐
- Linux内存屏障浅析
根据该文章整理 https://blog.csdn.net/myxmu/article/details/8035025 1 解决的问题 内存屏障主要解决了单处理器下的乱序问题和多处理器下的内存同步问题 ...
- jQuery学习的几个不是问题的问题
原文在我的GitHubhttps://www.sogeisetsugo.tk/myBlog/jQuery学习的几个不是问题的问题
- python3.x 基础四:json与pickple
每次打开一个文件,只dump1次 json.dump(dump的内容,文件句柄) json.load(文件句柄) json可以处理列表/字典/字符串等简单数据类型,但是不能处理复杂的数据类型,如函数的 ...
- 【github技巧2】下载包加速
打开代下网站:https://g.widora.cn 直接输入 https开头的github地址 或需下载包地址的链接 获取链接 下载压缩包 备注:压缩包格式为tar,需要解压
- Java——native关键字
说明:在使用HashSet的过程中,查看Object.java过程中发现hashCode()方法是以native关键字修饰,没看到过该关键字,这里记录下来. native关键字用来修饰方法,是使用一些 ...
- [工具-002]把png图片转换成ico图标
最近我收到了上级的一个需求,我们需要使用产品的png图片,批量转换成ico图片,然后调用上一篇的方法,替换可执行程序的图标.一开始查看资料的时候,C#有直接可以转成ico图片的方法,很简单.但是生成的 ...
- Springboot 内置tomcat 基本配置收集整理
配置一: server:# tomcat 配置 tomcat: # 接收队列长度 accept-count: 1000 # 最小空闲线程数 min-spare-threads ...
- PMP | 备考笔记
(持续更新......) 五大过程组和十大知识领域是PMP的重要组成部分,也是这门课的重点线索,本文会逐步迭代.渐进明细的来补充完善这个体系. (先放个图吧) 以下每个模块记录自己有点模糊的地方 项目 ...
- 01 . Redis简介及部署主从复制
简介 Remote Dictionary Server, 翻译为远程字典服务, Redis是一个完全开源的基于Key-Value的NoSQL存储系统,他是一个使用ANSIC语言编写的,遵守BSD协议, ...
- 07 . Python3函数
Python3函数 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.Python提供了许多内建函数,比如print().我们可以直接调用 ...