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

What is the difference between adjoint and a Derivative (newton solver)? #935

Open
GrigorySarnitsky opened this issue Mar 27, 2024 · 0 comments

Comments

@GrigorySarnitsky
Copy link

Not so much of an issue, but a highly confusing point. Apparently both ' and Derivative() compute the derivative but in different ways:

> Fun(x -> x^2)'
Fun(Chebyshev(), [0.0, 2.0])

and

> Derivative() * Fun(x -> x^2)
Fun(Ultraspherical(1), [0.0, 1.0])

This is the most confusing while using newton(). The example from the docs with ' works:

using ApproxFun
using Plots

N1(u, x = Fun()) = [u(-1.)-1., u(1.)+0.5, 0.001u'' + 6(1-x^2)u' + u^2 - 1];
u = newton(N1, 0 * Fun())

plot(u)

but changing it to

∂x = Derivative()
N1(u, x = Fun()) = [u(-1.)-1., u(1.)+0.5, 0.001 * (∂x^2 * u) + 6(1-x^2) * (∂x * u) + u^2 - 1];

throws an error:

MethodError: no method matching space(::ApproxFun.DualFun{Fun{Chebyshev{ChebyshevInterval{Float64}, Float64}, Float64, Vector{Float64}}, ConstantOperator{Float64, Chebyshev{ChebyshevInterval{Float64}, Float64}}})

Closest candidates are:
  space(::LowRankFun, ::Integer)
   @ ApproxFunBase [~/.julia/packages/ApproxFunBase/clvO0/src/Multivariate/LowRankFun.jl:348](http://localhost:8888/home/grigory/.julia/packages/ApproxFunBase/clvO0/src/Multivariate/LowRankFun.jl#line=347)
  space(::LowRankFun)
   @ ApproxFunBase [~/.julia/packages/ApproxFunBase/clvO0/src/Multivariate/LowRankFun.jl:349](http://localhost:8888/home/grigory/.julia/packages/ApproxFunBase/clvO0/src/Multivariate/LowRankFun.jl#line=348)
  space(::Fun)
   @ ApproxFunBase [~/.julia/packages/ApproxFunBase/clvO0/src/Fun.jl:339](http://localhost:8888/home/grigory/.julia/packages/ApproxFunBase/clvO0/src/Fun.jl#line=338)
  ...
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