R语言常微分方程数值解海强作业

本文介绍了如何使用R语言的deSolve包求解常微分方程,包括一阶微分方程的人口增长模型和一阶多元线性微分方程组的Lorenz模型。此外,还探讨了欧拉方法及其改进的Adams-Bashforth方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

**

  1. 调包解法

**
一阶微分方程:一元以人口增长为例
在这里插入图片描述
我们使用R package deSolve ODEs 函数。
A simplified form of the syntax for solving ODEs is: ode(y, times, func, parms, …)
where times holds the times at which output is wanted, y holds the initial conditions, func is the name of the R function that describes the differential equations,andparmscontainsthe parametervalues(oris NULL)
dy/dx.
Ode()的y相当于y(0) times相当与dx,function 相当与ry(1-y/k)

r <- 1
K <- 10
yini <- 2
derivs <- function(t, y, parms) list(r * y * (1-y/K))
library(deSolve)
times <- seq(from = 0, to = 20, by = 0.2)
out <- ode(y = yini, times = times, func = derivs, parms = NULL)
我们换个y(0)=12,输出out2.
r <- 1
K <- 10
yini <- 12
derivs <- function(t, y, parms) list(r * y * (1-y/K))
librar

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值