提问人:Student Debil 提问时间:10/21/2023 最后编辑:Student Debil 更新时间:10/21/2023 访问量:50
Julia 中具有多种函数的积分
Integrals in Julia with multiple functions
问:
我是 Julia 的新手,我有一个代码:
using Symbolics, QuadGK, SymbolicNumericIntegration
@variables M, m_0, ξ, ϵ_σ, ϵ_r, R̃, ε, U_λ, α, β,v, λ, _ξ_, λ_c,φ
####################################
R̃ = ε^2 - U_λ - α * (α + 2*ε*λ*ϵ_σ)/ξ^2
X(ξ, ε, λ, α) = quadgk(_ξ_-> (λ + (α*ε)/(1-2/_ξ_))/( ( (α^2)/(1-2/_ξ_) + _ξ_^2 ) * sqrt(ε^2 - (1-2/_ξ_)*(1+λ^2/_ξ_^2) - (α^2+2*ε*λ*α)/(_ξ_^2)) ), ξ, Inf, rtol = 1e-5)[1]
S(ξ, ε, λ, α, ϵ_σ,φ) = exp(-(ε+ϵ_σ*v*sqrt(ε^2-1)*sin( (-X(ξ,ε, λ, α))*(φ-ϵ_σ*ϵ_r)))*(β)/sqrt(1-v^2) )[1]
print(integrate(ε*exp(-(ε+ϵ_σ*v*sqrt(ε^2-1)*sin( (-X(ξ,ε, λ, α))*(φ-ϵ_σ*ϵ_r)))*(β)/sqrt(1-v^2) )),(λ,0,10))
最后一个函数()给了我一个错误:integrate
ERROR: LoadError: MethodError: no method matching kronrod(::Type{Num}, ::Int64)
Closest candidates are:
kronrod(::Any, ::Integer, ::Real, ::Real; rtol, quad) at ~/.julia/packages/QuadGK/ZWSGN/src/weightedgauss.jl:90
kronrod(::Type{T}, ::Integer) where T<:AbstractFloat at ~/.julia/packages/QuadGK/ZWSGN/src/gausskronrod.jl:318
kronrod(::Integer, ::Real, ::Real) at ~/.julia/packages/QuadGK/ZWSGN/src/gausskronrod.jl:343
...
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/QuadGK/ZWSGN/src/gausskronrod.jl:566 [inlined]
[2] _cachedrule
@ ~/.julia/packages/QuadGK/ZWSGN/src/gausskronrod.jl:566 [inlined]
[3] cachedrule
@ ~/.julia/packages/QuadGK/ZWSGN/src/gausskronrod.jl:571 [inlined]
[4] do_quadgk(f::var"#1#2"{Num, Num, Num}, s::Tuple{Num, Num}, n::Int64, atol::Nothing, rtol::Float64, maxevals::Int64, nrm::typeof(LinearAlgebra.norm), segbuf::Nothing)
@ QuadGK ~/.julia/packages/QuadGK/ZWSGN/src/adapt.jl:7
[5] (::QuadGK.var"#50#51"{Nothing, Float64, Int64, Int64, typeof(LinearAlgebra.norm), Nothing})(f::Function, s::Tuple{Num, Num}, #unused#::Function)
@ QuadGK ~/.julia/packages/QuadGK/ZWSGN/src/adapt.jl:235
[6] handle_infinities(workfunc::QuadGK.var"#50#51"{Nothing, Float64, Int64, Int64, typeof(LinearAlgebra.norm), Nothing}, f::var"#1#2"{Num, Num, Num}, s::Tuple{Num, Num})
@ QuadGK ~/.julia/packages/QuadGK/ZWSGN/src/adapt.jl:134
[7] quadgk(::Function, ::Num, ::Vararg{Num}; atol::Nothing, rtol::Float64, maxevals::Int64, order::Int64, norm::Function, segbuf::Nothing)
@ QuadGK ~/.julia/packages/QuadGK/ZWSGN/src/adapt.jl:234
[8] quadgk(::Function, ::Num, ::Vararg{Any}; kws::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:rtol,), Tuple{Float64}}})
@ QuadGK ~/.julia/packages/QuadGK/ZWSGN/src/adapt.jl:229
[9] X(ξ::Num, ε::Num, λ::Num, α::Num)
@ Main ~/czarne_dziury.jl:8
[10] top-level scope
@ ~/czarne_dziury.jl:18
我试图用 QuadGK 计算这个积分,但它也不起作用。Cubature 和 HCubature 也出现错误。我知道这个积分很复杂,但对朱莉娅来说真的太复杂了吗?我希望这个问题有解决办法,出现错误的原因是因为我缺乏编程技能
答: 暂无答案
评论