本文介绍了求解变系数二阶线性ODE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 对于可变系数二阶线性ODEFor the variable coefficients second order linear ODE $ x''(t)+ \beta_1(t)x'(t)+ \beta_0 x (t)= 0 $$x''(t)+\beta_1(t)x'(t)+\beta_0 x(t)=0$我有$ \beta_1(t)$和$ \beta_0(t)$的数值(就矢量而言) ,有人知道一些R软件包可以做到这一点吗?还有一些简单的例子也很不错。I have the numerical values (in terms of vectors) for $\beta_1(t)$ and $\beta_0(t)$, does anyone know some R package to do that? And some simple examples to illustrate would be great as well.我用Google搜索找到了 bvpSolve '可以求解常数系数值。I googled to find 'bvpSolve' can solve constant coefficients value.推荐答案要使用 deSolve ,必须制作二阶ODEIn order to use deSolve, you have to make your second-order ODEx''(t) + \beta_1(t) x'(t) + \beta_0 x(t)=0进入一对耦合的一阶ODE:into a pair of coupled first-order ODEs:x'(t) = y(t)y'(t) = - \beta_1(t) y(t) - \beta_0 x(t)然后很简单:gfun <- function(t,z,params) { g <- with(as.list(c(z,params)), { beta0 <- sin(2*pi*t) beta1 <- cos(2*pi*t) c(x=y, y= -beta1*y - beta0*x)) list(g,NULL)}library("deSolve")run1 <- ode(c(x=1,y=1),times=0:40,func=gfun,parms=numeric(0))我任意选择了一些初始条件( x(0)= 1 , x'(0)= 1 );您可能还想向模型添加参数(即,使 parms 成为 numeric(0)以外的东西)I picked some initial conditions (x(0)=1, x'(0)=1) arbitrarily; you might also want to add parameters to the model (i.e. make parms something other than numeric(0)) PS如果您不愿意手工转换为耦合的一阶ODE,并且想要一个可以无缝处理二阶ODE的程序包,那么我不知道答案...PS if you're not happy doing the conversion to coupled first-order ODEs by hand, and want a package that will seamlessly handle second-order ODEs, then I don't know the answer ... 这篇关于求解变系数二阶线性ODE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
05-16 06:20