Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newton for simple PDE gives NaN result #887

Open
dstahlke opened this issue May 28, 2023 · 1 comment
Open

Newton for simple PDE gives NaN result #887

dstahlke opened this issue May 28, 2023 · 1 comment

Comments

@dstahlke
Copy link

This simple test gives a NaN result:

using ApproxFun

xdom = Chebyshev(-1..1)
x = Fun(identity, xdom)

N(u, v) = [u - x; v + x]

u0 = 0*x
v0 = 0*x
newton(N, [u0, v0])

Result:

2-element Vector{Fun{Chebyshev{IntervalSets.ClosedInterval{Int64}, Float64}, Float64, Vector{Float64}}}:
 Fun(Chebyshev(-1..1), [NaN, NaN, NaN, NaN])
 Fun(Chebyshev(-1..1), [NaN, NaN, NaN])

And I don't know if it's related, but with a two-dimensional domain it gives a different error:

using ApproxFun

xdom = Chebyshev(-1..1)
ydom = Chebyshev(-1..1)
x, y = Fun(identity, xdom*ydom)

N(u, v) = [u - x; v + y]

u0 = 0*x
v0 = 0*x
newton(N, [u0, v0])

Result:

ERROR: LoadError: ArgumentError: invalid argument #4 to LAPACK call
Stacktrace:
  [1] chklapackerror
    @ ~/apps/julia-1.9.0/share/julia/stdlib/v1.9/LinearAlgebra/src/lapack.jl:38 [inlined]
  [2] gesdd!(job::Char, A::Matrix{Float64})
    @ LinearAlgebra.LAPACK ~/apps/julia-1.9.0/share/julia/stdlib/v1.9/LinearAlgebra/src/lapack.jl:1665
  [3] _svd!
    @ ~/apps/julia-1.9.0/share/julia/stdlib/v1.9/LinearAlgebra/src/svd.jl:125 [inlined]
  [4] svd!(A::Matrix{Float64}; full::Bool, alg::LinearAlgebra.DivideAndConquer)
    @ LinearAlgebra ~/apps/julia-1.9.0/share/julia/stdlib/v1.9/LinearAlgebra/src/svd.jl:105
  [5] svd!
    @ ~/apps/julia-1.9.0/share/julia/stdlib/v1.9/LinearAlgebra/src/svd.jl:100 [inlined]
  [6] #svd#114
    @ ~/apps/julia-1.9.0/share/julia/stdlib/v1.9/LinearAlgebra/src/svd.jl:179 [inlined]
  [7] svd
    @ ~/apps/julia-1.9.0/share/julia/stdlib/v1.9/LinearAlgebra/src/svd.jl:178 [inlined]
  [8] LowRankFun(X::Matrix{Float64}, dx::Chebyshev{IntervalSets.ClosedInterval{Int64}, Float64}, dy::Chebyshev{IntervalSets.ClosedInterval{Int64}, Float64})
    @ ApproxFunBase ~/.julia/packages/ApproxFunBase/9nGis/src/Multivariate/LowRankFun.jl:59
dstahlke added a commit to dstahlke/ApproxFun.jl that referenced this issue Jun 12, 2023
Test case (requires also JuliaApproximation/ApproxFunBase.jl#479):
    using ApproxFun

    xdom = Chebyshev(-1..1)
    ydom = Chebyshev(-1..1)
    domain = xdom * ydom
    x,y = Fun(identity, domain)
    Dx = Derivative(Chebyshev()^2, [1,0])
    Dy = Derivative(Chebyshev()^2, [0,1])

    N(u, v) = [
        2*u - x;
        3*v + y
    ]

    u0 = one(x) * one(y)
    v0 = one(x) * one(y)
    u, v = newton(N, [u0, v0])

Bug report:
JuliaApproximation#887
@dstahlke
Copy link
Author

Both these test cases are fixed by the following PRs:
#891
JuliaApproximation/ApproxFunBase.jl#479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant