python求微分方程 洛伦兹,用scipy在python中求解二维微分方程

初学者在尝试用Python的scipy库求解包含两个变量的二维微分方程时遇到错误。原始代码在处理y为0的特殊情况时出错。通过修改函数以避免除以零,并打印ODE函数评估,问题得到解决。正确代码显示在t=0.64230232515时存在奇异点,导致解决方案失去连续可微性。
摘要由CSDN通过智能技术生成

i am a newbie to python. I have a simple differential systems, which consists of two variables and two differential equations and initial conditions x0=1, y0=2:

dx/dt=6*y

dy/dt=(2t-3x)/4y

now i am trying to solve these two differential equations and i choose odeint. Here is my code:

import matplotlib.pyplot as pl

import numpy as np

from scipy.integrate import odeint

def func(z,b):

x, y=z

return [6*y, (b-3*x)/(4*y)]

z0=[1,2]

t = np.linspace(0,10,11)

b=2*t

xx=odeint(func, z0, b)

pl.figure(1)

pl.plot(t, xx[:,0])

pl.legend()

pl.show()

but the result is incorrect and there is a error message:

D0vlb.png

Excess work done on this ca

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值