Open marcelosena opened 4 years ago
Please post a MWE
Here, sorry:
using ApproxFun
r = 0.06
δ = 0.1007
μ = 0.18
σ = 0.09
θ = 1.5
λ = 0.01
ℓ = 0.9
γ = 0.06
ϕ = 0.01
x = Fun()
u₀ = 1*x # initial guess
N = u->[u(0.19)-0.19;u(0) - 0; 0.5*σ^2*u'' + (x*δ + 1/(2*θ) + x/θ + x^2/(2*θ) + x*(r-λ) + μ )*u' + (-δ - 1/θ - x/θ - r)*u + u^2/(2*θ*u') ]
u = newton(N,u₀)
Updated guess and boundary conditions, I believe these to be more proper, although still have the same error.
Can you please include the error message when running the code
Here is the full output in REPL when running the code:
┌ Warning: Maximum length 1000000 reached.
└ @ ApproxFunBase C:\Users\Marcelo\.julia\packages\ApproxFunBase\Jv4NR\src\Caching\matrix.jl:124
ERROR: AssertionError: abs(last(g)) < tol
Stacktrace:
[1] coefficients(::Array{Float64,1}, ::JacobiWeight{Chebyshev{ChebyshevInterval{Float64},Float64},ChebyshevInterval{Float64},Float64,Float64}, ::JacobiWeight{Chebyshev{ChebyshevInterval{Float64},Float64},ChebyshevInterval{Float64},Float64,Int64}) at C:\Users\Marcelo\.julia\packages\ApproxFunSingularities\MaPTr\src\JacobiWeightChebyshev.jl:20
[2] coefficients at C:\Users\Marcelo\.julia\packages\ApproxFunSingularities\MaPTr\src\JacobiWeight.jl:106 [inlined]
[3] coefficients(::Array{Float64,1}, ::JacobiWeight{Chebyshev{ChebyshevInterval{Float64},Float64},ChebyshevInterval{Float64},Float64,Float64}, ::Chebyshev{ChebyshevInterval{Float64},Float64}, ::JacobiWeight{Ultraspherical{Int64,ChebyshevInterval{Float64},Float64},ChebyshevInterval{Float64},Float64,Int64}) at C:\Users\Marcelo\.julia\packages\ApproxFunBase\Jv4NR\src\Space.jl:312
[4] defaultcoefficients(::Array{Float64,1}, ::JacobiWeight{Chebyshev{ChebyshevInterval{Float64},Float64},ChebyshevInterval{Float64},Float64,Float64}, ::JacobiWeight{Ultraspherical{Int64,ChebyshevInterval{Float64},Float64},ChebyshevInterval{Float64},Float64,Int64}) at C:\Users\Marcelo\.julia\packages\ApproxFunBase\Jv4NR\src\Space.jl:341
[5] coefficients(::Array{Float64,1}, ::JacobiWeight{Chebyshev{ChebyshevInterval{Float64},Float64},ChebyshevInterval{Float64},Float64,Float64}, ::JacobiWeight{Ultraspherical{Int64,ChebyshevInterval{Float64},Float64},ChebyshevInterval{Float64},Float64,Int64}) at C:\Users\Marcelo\.julia\packages\ApproxFunSingularities\MaPTr\src\JacobiWeight.jl:93
[6] coefficients(::Array{Float64,1}, ::JacobiWeight{Chebyshev{ChebyshevInterval{Float64},Float64},ChebyshevInterval{Float64},Float64,Float64}, ::Ultraspherical{Int64,ChebyshevInterval{Float64},Float64}) at C:\Users\Marcelo\.julia\packages\ApproxFunSingularities\MaPTr\src\JacobiWeight.jl:106
[7] coefficients at C:\Users\Marcelo\.julia\packages\ApproxFunBase\Jv4NR\src\Fun.jl:49 [inlined]
[8] (::Base.var"#3#4"{typeof(coefficients)})(::Tuple{Fun{JacobiWeight{Chebyshev{ChebyshevInterval{Float64},Float64},ChebyshevInterval{Float64},Float64,Float64},Float64,Array{Float64,1}},Ultraspherical{Int64,ChebyshevInterval{Float64},Float64}}) at .\generator.jl:36
[9] iterate at .\generator.jl:47 [inlined]
[10] collect_to!(::Array{Array{Float64,1},1}, ::Base.Generator{Base.Iterators.Zip{Tuple{Array{Fun{S,Float64,Array{Float64,1}} where S,1},ApproxFunBase.ArraySpace{Space{D,Float64} where D,1,DomainSets.Point{Float64},Float64}}},Base.var"#3#4"{typeof(coefficients)}}, ::Int64, ::Tuple{Int64,Int64}) at .\array.jl:710
[11] collect_to_with_first!(::Array{Array{Float64,1},1}, ::Array{Float64,1}, ::Base.Generator{Base.Iterators.Zip{Tuple{Array{Fun{S,Float64,Array{Float64,1}} where S,1},ApproxFunBase.ArraySpace{Space{D,Float64} where D,1,DomainSets.Point{Float64},Float64}}},Base.var"#3#4"{typeof(coefficients)}}, ::Tuple{Int64,Int64}) at .\array.jl:689
[12] collect(::Base.Generator{Base.Iterators.Zip{Tuple{Array{Fun{S,Float64,Array{Float64,1}} where S,1},ApproxFunBase.ArraySpace{Space{D,Float64} where D,1,DomainSets.Point{Float64},Float64}}},Base.var"#3#4"{typeof(coefficients)}}) at .\array.jl:670
[13] map at .\abstractarray.jl:2154 [inlined]
[14] coefficients(::Array{Fun{S,Float64,Array{Float64,1}} where S,1}, ::ApproxFunBase.ArraySpace{Space{D,Float64} where D,1,DomainSets.Point{Float64},Float64}) at C:\Users\Marcelo\.julia\packages\ApproxFunBase\Jv4NR\src\Spaces\ArraySpace.jl:208
[15] coefficients(::Array{Any,1}, ::ApproxFunBase.ArraySpace{Space{D,Float64} where D,1,DomainSets.Point{Float64},Float64}) at C:\Users\Marcelo\.julia\packages\ApproxFunBase\Jv4NR\src\Spaces\ArraySpace.jl:211
[16] \(::ApproxFunBase.InterlaceOperator{Float64,1,Chebyshev{ChebyshevInterval{Float64},Float64},ApproxFunBase.ArraySpace{Space{D,Float64} where D,1,DomainSets.Point{Float64},Float64},ApproxFunBase.CachedIterator{Tuple{Int64,Int64},ApproxFunBase.BlockInterlacer{Tuple{FillArrays.Ones{Int64,1,Tuple{InfiniteArrays.OneToInf{Int64}}}}}},ApproxFunBase.CachedIterator{Tuple{Int64,Int64},ApproxFunBase.BlockInterlacer{Tuple{StaticArrays.SArray{Tuple{1},Int64,1,1},StaticArrays.SArray{Tuple{1},Int64,1,1},FillArrays.Ones{Int64,1,Tuple{InfiniteArrays.OneToInf{Int64}}}}}},Tuple{InfiniteArrays.SignedInfinity,InfiniteArrays.Infinity}}, ::Array{Any,1}; kwds::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\Marcelo\.julia\packages\ApproxFunBase\Jv4NR\src\Operators\ldiv.jl:11
[17] \(::ApproxFunBase.InterlaceOperator{Float64,1,Chebyshev{ChebyshevInterval{Float64},Float64},ApproxFunBase.ArraySpace{Space{D,Float64} where D,1,DomainSets.Point{Float64},Float64},ApproxFunBase.CachedIterator{Tuple{Int64,Int64},ApproxFunBase.BlockInterlacer{Tuple{FillArrays.Ones{Int64,1,Tuple{InfiniteArrays.OneToInf{Int64}}}}}},ApproxFunBase.CachedIterator{Tuple{Int64,Int64},ApproxFunBase.BlockInterlacer{Tuple{StaticArrays.SArray{Tuple{1},Int64,1,1},StaticArrays.SArray{Tuple{1},Int64,1,1},FillArrays.Ones{Int64,1,Tuple{InfiniteArrays.OneToInf{Int64}}}}}},Tuple{InfiniteArrays.SignedInfinity,InfiniteArrays.Infinity}}, ::Array{Any,1}) at C:\Users\Marcelo\.julia\packages\ApproxFunBase\Jv4NR\src\Operators\ldiv.jl:4
[18] \(::Array{Operator{Float64},1}, ::Array{Any,1}; kwds::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\Marcelo\.julia\packages\ApproxFunBase\Jv4NR\src\Operators\ldiv.jl:52
[19] \(::Array{Operator{Float64},1}, ::Array{Any,1}) at C:\Users\Marcelo\.julia\packages\ApproxFunBase\Jv4NR\src\Operators\ldiv.jl:52
[20] newton(::var"#138#139", ::Fun{Chebyshev{ChebyshevInterval{Float64},Float64},Float64,Array{Float64,1}}; maxiterations::Int64, tolerance::Float64) at C:\Users\Marcelo\.julia\packages\ApproxFun\hDuHj\src\Extras\autodifferentiation.jl:101
[21] newton(::Function, ::Fun{Chebyshev{ChebyshevInterval{Float64},Float64},Float64,Array{Float64,1}}) at C:\Users\Marcelo\.julia\packages\ApproxFun\hDuHj\src\Extras\autodifferentiation.jl:95
[22] top-level scope at REPL[393]:1
The Warning: Maximum length 1000000 reached
means something has failed to converge. Likely your initial guess is not accurate enough and the Newton solver has spun out of control.
May I suggest a homotopy method for producing the initial guess? That is, choose "nicer" parameters that converge and use that as initial guesses as you approach the desired parameters.
Hi, I am trying to solve a two-point bvp with ApproxFun but receive the following error: ERROR: AssertionError: abs(last(g)) < tol I had a hard time searching what this error is supposed to mean (is it in the documentation somewhere?), but should I interpret it as an error on my end (not properly specifying the problem)? Or is it something else? Thanks.