- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对此非常陌生,我在网上找不到任何帮助,如果之前已经回答过,我很抱歉。我试图在常微分方程上遵循这个简单的例子
using DifferentialEquations
f(t,u) = 1.01*u
u0=1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob,Tsit5(),reltol=1e-8,abstol=1e-8)
using Plots
plot(sol,linewidth=5,title="Solution to the linear ODE with a thick line",
xaxis="Time (t)",yaxis="u(t) (in μm)",label="My Thick Line!") # legend=false
plot!(sol.t, t->0.5*exp(1.01t),lw=3,ls=:dash,label="True Solution!")
但是当我调用solve函数时出现这个错误
MethodError: no method matching f(::Float64, ::DiffEqBase.NullParameters, ::Float64)
Closest candidates are:
f(::Any, ::Any) at /Users/diogomiguez/.julia/pluto_notebooks/Cute science.jl#==#dbde1a90-407c-11eb-15ad-394234f71852:1
(::DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing})(::Float64, ::Vararg{Any,N} where N)@diffeqfunction.jl:248
initialize!(::OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.CompositeAlgorithm{Tuple{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType}},OrdinaryDiffEq.AutoSwitchCache{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType},Rational{Int64},Int64}},false,Float64,Nothing,Float64,DiffEqBase.NullParameters,Float64,Float64,Float64,Array{Float64,1},OrdinaryDiffEq.ODECompositeSolution{Float64,1,Array{Float64,1},Nothing,Nothing,Array{Float64,1},Array{Array{Float64,1},1},DiffEqBase.ODEProblem{Float64,Tuple{Float64,Float64},false,DiffEqBase.NullParameters,DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},OrdinaryDiffEq.CompositeAlgorithm{Tuple{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType}},OrdinaryDiffEq.AutoSwitchCache{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType},Rational{Int64},Int64}},OrdinaryDiffEq.CompositeInterpolationData{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64},OrdinaryDiffEq.Rosenbrock23ConstantCache{Float64,DiffEqBase.TimeDerivativeWrapper{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,DiffEqBase.NullParameters},DiffEqBase.UDerivativeWrapper{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,DiffEqBase.NullParameters},Float64,Float64,DiffEqBase.DefaultLinSolve}},OrdinaryDiffEq.AutoSwitchCache{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType},Rational{Int64},Int64}}},DiffEqBase.DEStats},DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64},OrdinaryDiffEq.Rosenbrock23ConstantCache{Float64,DiffEqBase.TimeDerivativeWrapper{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,DiffEqBase.NullParameters},DiffEqBase.UDerivativeWrapper{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,DiffEqBase.NullParameters},Float64,Float64,DiffEqBase.DefaultLinSolve}},OrdinaryDiffEq.AutoSwitchCache{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType},Rational{Int64},Int64}},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),typeof(LinearAlgebra.opnorm),DiffEqBase.CallbackSet{Tuple{},Tuple{}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,Base.Order.ForwardOrdering},DataStructures.BinaryHeap{Float64,Base.Order.ForwardOrdering},Nothing,Nothing,Int64,Tuple{},Tuple{},Tuple{}},Float64,Float64,Nothing,OrdinaryDiffEq.DefaultInit}, ::OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64})@low_order_rk_perform_step.jl:565
initialize!(::OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.CompositeAlgorithm{Tuple{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType}},OrdinaryDiffEq.AutoSwitchCache{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType},Rational{Int64},Int64}},false,Float64,Nothing,Float64,DiffEqBase.NullParameters,Float64,Float64,Float64,Array{Float64,1},OrdinaryDiffEq.ODECompositeSolution{Float64,1,Array{Float64,1},Nothing,Nothing,Array{Float64,1},Array{Array{Float64,1},1},DiffEqBase.ODEProblem{Float64,Tuple{Float64,Float64},false,DiffEqBase.NullParameters,DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},OrdinaryDiffEq.CompositeAlgorithm{Tuple{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType}},OrdinaryDiffEq.AutoSwitchCache{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType},Rational{Int64},Int64}},OrdinaryDiffEq.CompositeInterpolationData{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64},OrdinaryDiffEq.Rosenbrock23ConstantCache{Float64,DiffEqBase.TimeDerivativeWrapper{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,DiffEqBase.NullParameters},DiffEqBase.UDerivativeWrapper{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,DiffEqBase.NullParameters},Float64,Float64,DiffEqBase.DefaultLinSolve}},OrdinaryDiffEq.AutoSwitchCache{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType},Rational{Int64},Int64}}},DiffEqBase.DEStats},DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64},OrdinaryDiffEq.Rosenbrock23ConstantCache{Float64,DiffEqBase.TimeDerivativeWrapper{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,DiffEqBase.NullParameters},DiffEqBase.UDerivativeWrapper{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,DiffEqBase.NullParameters},Float64,Float64,DiffEqBase.DefaultLinSolve}},OrdinaryDiffEq.AutoSwitchCache{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType},Rational{Int64},Int64}},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),typeof(LinearAlgebra.opnorm),DiffEqBase.CallbackSet{Tuple{},Tuple{}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,Base.Order.ForwardOrdering},DataStructures.BinaryHeap{Float64,Base.Order.ForwardOrdering},Nothing,Nothing,Int64,Tuple{},Tuple{},Tuple{}},Float64,Float64,Nothing,OrdinaryDiffEq.DefaultInit}, ::OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64},OrdinaryDiffEq.Rosenbrock23ConstantCache{Float64,DiffEqBase.TimeDerivativeWrapper{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,DiffEqBase.NullParameters},DiffEqBase.UDerivativeWrapper{DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,DiffEqBase.NullParameters},Float64,Float64,DiffEqBase.DefaultLinSolve}},OrdinaryDiffEq.AutoSwitchCache{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType},Rational{Int64},Int64}})@composite_perform_step.jl:39
#__init#399(::Tuple{}, ::Tuple{}, ::Tuple{}, ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::Nothing, ::Bool, ::Bool, ::Float64, ::Nothing, ::Float64, ::Bool, ::Bool, ::Rational{Int64}, ::Nothing, ::Nothing, ::Rational{Int64}, ::Int64, ::Int64, ::Int64, ::Rational{Int64}, ::Bool, ::Int64, ::Nothing, ::Nothing, ::Int64, ::typeof(DiffEqBase.ODE_DEFAULT_NORM), ::typeof(LinearAlgebra.opnorm), ::typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), ::typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::String, ::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::OrdinaryDiffEq.DefaultInit, ::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol,Symbol},NamedTuple{(:default_set, :second_time),Tuple{Bool,Bool}}}, ::typeof(DiffEqBase.__init), ::DiffEqBase.ODEProblem{Float64,Tuple{Float64,Float64},false,DiffEqBase.NullParameters,DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem}, ::OrdinaryDiffEq.CompositeAlgorithm{Tuple{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType}},OrdinaryDiffEq.AutoSwitch{OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.Rosenbrock23{0,false,DiffEqBase.DefaultLinSolve,DataType},Rational{Int64},Int64}}, ::Tuple{}, ::Tuple{}, ::Tuple{}, ::Type{Val{true}})@solve.jl:429
#__solve#398@solve.jl:4[inlined]
#__solve#1(::Bool, ::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:second_time,),Tuple{Bool}}}, ::typeof(DiffEqBase.__solve), ::DiffEqBase.ODEProblem{Float64,Tuple{Float64,Float64},false,DiffEqBase.NullParameters,DiffEqBase.ODEFunction{false,typeof(Main.workspace465.f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem}, ::Nothing)@default_solve.jl:7
#__solve#463@solve.jl:230[inlined]
__solve@solve.jl:217[inlined]
#solve_call#451@solve.jl:65[inlined]
solve_call@solve.jl:52[inlined]
#solve_up#453@solve.jl:89[inlined]
solve_up@solve.jl:79[inlined]
#solve#452@solve.jl:74[inlined]
solve@solve.jl:72[inlined]
top-level scope@Local: 1[inlined]
也可能有帮助:
->Pkg.status("DifferentialEquations")
Status `~/.julia/environments/v1.5/Project.toml`
[0c46a032] DifferentialEquations v6.15.0
最佳答案
看来您一直在关注 this example来自 DifferentialEquations.jl
文件;奇怪的是,Google 似乎优先考虑 v2.0 的文档(请参阅链接中的 URL)。
v6.15 的文档是 here ; API 现在已更改为预期 f
的三个参数.将您的代码更改为
f(u,p,t) = 1.01*u
你应该没有问题。正如您在
MethodError
中看到的那样, 需要一个带有三个参数的函数,这就是您遇到问题的原因。
关于julia - 微分方程求解()不起作用( Julia ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65344695/
我正在使用混合效应模型,并且由于我的方法的特殊性我需要解决下面模型的积分,然后制作图表获得的估计值。 换句话说,我需要求解下面的积分: 其中,di^2 是我模型中的 Var3,dh 是混合效应模型对应
我有一个方程组,我想用数值方法求解它。给定起始种子,我想得到一个接近的解决方案。让我解释。 我有一个常量向量,X,值: X <- (c(1,-2,3,4)) 和一个向量 W 的权重: W <- (c(
假设我有以下方程组: a * b = 5 sqrt(a * b^2) = 10 如何求解 R 中 a 和 b 的这些方程? 我想这个问题可以说是一个优化问题,具有以下功能......? fn <- f
我在 R 中有一个简单的通量模型。它归结为两个微分方程,对模型中的两个状态变量进行建模,我们将它们称为 A和 B .它们被计算为四个分量通量的简单差分方程 flux1-flux4 , 5 个参数 p1
R有什么办法吗?求解给定单变量函数的反函数?动机是我以后告诉R使用值向量作为反函数的输入,以便它可以吐出反函数值。 例如,我有函数 y(x) = x^2 ,逆是 y = sqrt(x) .有没有办法R
我在字符串中有以下方程 y = 18774x + 82795 求解x我会这样做:- x = (y-82795) / 18774 我知道y的值 但是方程一直在变化,并且始终采用字符串格式 是否可以简单地
如果我用 diophantine(2*x+3*y-5*z-77) 我收到了这个结果。 {(t_0, -9*t_0 - 5*t_1 + 154, -5*t_0 - 3*t_1 + 77)} 到目前为止还
我正在尝试求解仅限于正解的 ODE,即: dx/dt=f(x) x>=0。 在 MATLAB 中这很容易实现。 R 是否有任何变通方法或包来将解决方案空间限制为仅正值? 这对我来说非常重要,不幸的是没
下面的 ANTLR 文法中的 'expr' 规则显然是相互左递归的。作为一个 ANTLR 新手,我很难解决这个问题。我已经阅读了 ANTLR 引用书中的“解决非 LL(*) 冲突”,但我仍然没有看到解
我有一个关于在 R 中求解函数的可能性的非常基本的问题,但知道答案确实有助于更好地理解 R。 我有以下等式: 0=-100/(1+r)+(100-50)/(1+r)^2+(100-50)/(1+r)^
我正在编写使用递归回溯来解决 8 个皇后问题的代码(将 n 个国际象棋皇后放在 n × n 的棋盘上,这样皇后就不会互相攻击)。 我的任务是创建两个方法:编写一个公共(public)solveQuee
我不知道在以下情况下如何进行,因为最后一个方程没有所有 4 个变量。所以使用了等式下面的代码,但这是错误的......有谁知道如何进行? 方程: 3a + 4b - 5c + d = 10 2a +
假设我们有这个递归关系,它出现在 AVL 树的分析中: F1 = 1 F2 = 2 Fn = Fn - 1 + Fn - 2 + 1(其中 n ≥ 3) 你将如何解决这个递归以获得 F(n) 的封闭形
在Maple中,有谁知道是否存在一个函数来求解变量?例如,我正在尝试求解 r 的 solve4r=(M-x^y)*(r^(-1)) mod (p-1)。所以我知道 M、x、y 和 p 的值,但不知道
我也问过这个here在声音设计论坛上,但问题是沉重的计算机科学/数学,所以它实际上可能属于这个论坛: 因此,通过读取文件中的二进制文件,我能够成功地找到关于 WAV 文件的所有信息,除了 big si
我有以下问题: 设 a 和 b 为 boolean 变量。是否可以设置 a 和 b 的值以使以下表达式的计算结果为 false? b or (((not a) or (not a)) or (a or
我需要用 C 求解这个超越方程: x = 2.0 - 0.5sen(x) 我试过这个: double x, newx, delta; x = 2.0 - 0.5; newx = sin(x); del
我在 Windows 上使用 OpenCV 3.1。 一段代码: RNG rng; // random number generator cv::Mat rVec = (cv::Mat_(3, 1)
我正在尝试求解一个包含 3 个变量和数量可变的方程的方程组。 基本上,系统的长度在 5 到 12 个方程之间,无论有多少个方程,我都试图求解 3 个变量。 看起来像这样: (x-A)**2 + (y-
我正在尝试为有限差分法设计一种算法,但我有点困惑。所讨论的 ODE 是 y''-5y'+10y = 10x,其中 y(0)=0 且 y(1)=100。所以我需要一种方法来以某种方式获得将从关系中乘以“
我是一名优秀的程序员,十分优秀!