From c1b477a1b2b796617c4e345a7296a8d429d7a067 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Sun, 26 Feb 2023 18:36:05 -0500 Subject: Update to v0.4 feature: compute the 2-point correlation function in easyeq. feature: compute the Fourier transform of the 2-point correlation function in anyeq and easyeq. feature: compute the local maximum of the 2-point correlation function and its Fourier transform. feature: compute the compressibility for anyeq. feature: allow for linear spacing of rho's. feature: print the scattering length. change: ux and uk now return real numbers. fix: error in the computation of the momentum distribution: wrong definition of delta functions. fix: various minor bugs. optimization: assign explicit types to variables. --- src/optimization.jl | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/optimization.jl (limited to 'src/optimization.jl') diff --git a/src/optimization.jl b/src/optimization.jl new file mode 100644 index 0000000..bacead7 --- /dev/null +++ b/src/optimization.jl @@ -0,0 +1,94 @@ +# gradient descent: find local minimum of function of one variable from initial guess +# numerically estimate the derivative +@everywhere function gradient_descent( + f::Function, + x0::Float64, + delta::Float64, # shift is delta*df + dx::Float64, # finite difference for numerical derivative evaluation + maxiter::Int64 # interrupt and fail after maxiter steps +) + counter=0 + + # init + x=x0 + + while countermaxstep + step=maxstep*sign(step) + end + + x=x+step + + # fail if off to infinity + if x==Inf || x==-Inf + return(x,val) + end + counter+=1 + end + + # fail + return(Inf,Inf) +end + -- cgit v1.2.3-70-g09d2