JuliaNLSolvers / NLsolve.jl

Julia solvers for systems of nonlinear equations and mixed complementarity problems
Other
324 stars 66 forks source link

Changes to newton.jl so that newton with linesearches works with complex numbers #259

Closed SarThak191119 closed 3 years ago

SarThak191119 commented 3 years ago

Hi,

I made some changes in NLsolve which did not earlier have a method to actually incorporate complex numbers into its newton algorithm using line searches. Linesearches.jl takes inherently real arguments. Nlsolve creates an objective single parameter function passed on to Linesearches which is defined by fo given by the dot product of the multivariate input function. If the input function is now complex the dot product still gives a real number but the dot operator returns a complex type with imaginary part zero. Taking the real part solves that issue and subsequently, all jacobian transpose has been changed to adjoint so that it is compatible with complex numbers.

The other change that has been done is with respect to the derivative of the univariate function which can be shown to be the real part of the product of cache.g and cache.p.

Newton method with linesearches now converges to the roots of holomorphic multivariate functions. With non-holomorphic functions, it converges to roots if the initial starting point is sufficiently near.

pkofod commented 3 years ago

Yes, this seems correct. This is the same we've done in Optim. Thanks a lot!

codecov[bot] commented 3 years ago

Codecov Report

Merging #259 (2e7172f) into master (13e1079) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #259   +/-   ##
=======================================
  Coverage   87.57%   87.57%           
=======================================
  Files          12       12           
  Lines         531      531           
=======================================
  Hits          465      465           
  Misses         66       66           
Impacted Files Coverage Δ
src/solvers/newton.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 13e1079...2e7172f. Read the comment docs.