Strange zeros provided by nlsolve
NormannR opened this issue · comments
Good afternoon,
I am a new user of Julia and experience problems with the function nlsolve.
I installed the package NLsolve this morning through the command Pkg.add("NLsolve")
. Its version is 0.13.0 according to the command Pkg.installed()
.
Following the instructions from the associated github page, I wanted to test the nlsolve function with the following code, but the solution provided by nlsolve is not satisfactory. Indeed, nlsolve gives back 1.0 as a solution of the equation cos(x) = 0
using NLsolve
R = Array{Float64}(1)
function f!(R,x)
R[1] = cos(x[1])
return R
end
x0 = Array{Float64}(1)
x0[1] = 0.5
x = nlsolve(f!, x0, show_trace=true)
println("The solution is $(x.zero)")
What am I doing wrong ?
Thanks in advance for your help,
Normann
You have an old version where the syntax was different. Update to 1.0.0
Thank you very much for your quick answer.
I do not get it. I installed for the first time the package this morning. Should not it be the latest version ? I carried out a few commands to ensure that the latest version of the package is installed, but I am unable to get the 1.0.0 version:
julia> Pkg.update()
INFO: Updating METADATA...
INFO: Computing changes...
INFO: No packages to install, update or removejulia> Pkg.rm("NLsolve")
INFO: Removing DiffBase v0.3.2
INFO: Removing NLsolve v0.13.0
INFO: Package database updatedjulia> Pkg.add("NLsolve")
INFO: Installing DiffBase v0.3.2
INFO: Installing NLsolve v0.13.0
INFO: Building SpecialFunctions
How could I get this 1.0.0 version ?
Thanks again for your help
What else do you have installed? Show Pkg.status()
and we can help. Sorry for this inconvenience! I will note in the README that it is for v1.0.0 and higher only.
Thank you for your reactivity
Pkg.status() returns the following lines
julia> Pkg.status()
18 required packages:
- Atom 0.6.8
- Compat 0.52.0
- Conda 0.7.1
- DSGE 0.4.0
- DataFrames 0.10.1
- Distributions 0.15.0
- ExcelReaders 0.8.2
- ForwardDiff 0.7.3
- IJulia 1.7.0
- JuMP 0.18.0
- LsqFit 0.3.0
- NLsolve 0.13.0
- Optim 0.11.0
- Plots 0.15.0
- PyCall 1.15.0
- PyPlot 2.3.2
- QuantEcon 0.14.1
- Taro 0.5.0
106 additional packages:- ASTInterpreter2 0.1.1
- AbstractFFTs 0.2.1
- AxisAlgorithms 0.2.0
- BinDeps 0.8.6
- Blink 0.6.0
- Blosc 0.3.0
- BufferedStreams 0.3.3
- Calculus 0.2.2
- CodeTools 0.4.7
- CodecZlib 0.4.2
- Codecs 0.4.0
- ColorTypes 0.6.7
- Colors 0.8.2
- CommonSubexpressions 0.0.1
- Contour 0.4.0
- DSP 0.3.4
- DataArrays 0.6.2
- DataStructures 0.7.4
- DataValues 0.3.1
- DebuggerFramework 0.1.2
- DiffBase 0.3.2
- DiffResults 0.0.3
- DiffRules 0.0.3
- Distances 0.5.0
- DocSeeker 0.1.0
- DualNumbers 0.3.0
- FFTW 0.0.4
- FileIO 0.6.1
- FixedPointNumbers 0.4.5
- FredData 0.2.0
- GZip 0.3.0
- HDF5 0.8.8
- Hiccup 0.1.1
- HttpCommon 0.4.0
- HttpParser 0.3.0
- HttpServer 0.3.0
- Interpolations 0.7.3
- IterTools 0.2.1
- IterableTables 0.7.0
- IteratorInterfaceExtensions 0.0.2
- JLD 0.8.3
- JSON 0.16.4
- JavaCall 0.5.2
- Juno 0.4.0
- KernelDensity 0.4.1
- LNR 0.0.2
- LaTeXStrings 0.3.0
- Lazy 0.12.0
- LegacyStrings 0.3.0
- LibExpat 0.4.1
- Libz 0.2.4
- LightGraphs 0.11.1
- LineSearches 3.2.5
- Loess 0.3.0
- MacroTools 0.4.0
- MathProgBase 0.7.0
- MbedTLS 0.5.5
- Measures 0.1.0
- Media 0.3.0
- Missings 0.2.6
- Mustache 0.3.0
- Mux 0.2.3
- NLSolversBase 3.1.0
- NLopt 0.3.6
- NaNMath 0.3.1
- NamedTuples 4.0.0
- Nullables 0.0.3
- OptimBase 1.0.0
- PDMats 0.8.0
- Parameters 0.8.1
- PlotThemes 0.2.0
- PlotUtils 0.4.4
- Polynomials 0.2.1
- PositiveFactorizations 0.1.0
- Primes 0.2.0
- QuadGK 0.2.0
- Ratios 0.2.0
- RecipesBase 0.2.3
- Reexport 0.1.0
- Requests 0.5.1
- Requires 0.4.3
- ReverseDiffSparse 0.8.1
- Rmath 0.3.2
- Roots 0.5.0
- SHA 0.5.6
- ShowItLikeYouBuildIt 0.2.0
- Showoff 0.1.1
- SimpleTraits 0.5.1
- SortingAlgorithms 0.2.0
- SpecialFunctions 0.3.8
- StatPlots 0.7.0
- StateSpaceRoutines 0.1.0
- StaticArrays 0.6.6
- StatsBase 0.19.5
- StatsFuns 0.5.0
- StringDistances 0.2.0
- TableTraits 0.1.0
- TableTraitsUtils 0.1.3
- Tokenize 0.4.2
- TranscodingStreams 0.4.1
- URIParser 0.3.0
- WebSockets 0.4.0
- WinRPM 0.3.1
- WinReg 0.2.0
- WoodburyMatrices 0.2.2
- ZMQ 0.5.1
Could be DSGE. Did you install that yourself? Also is this JuliaPro or normal Julia?
Edit That is: try to Pkg.rm("DSGE")
I use Julia v0.6.2. A colleague installed it on my computer, with this DSGE module. I do research in macroeconomics and DSGE models are fashionable in this field.
This DSGE module was the guilty party here, indeed ! I uninstalled it and was able to get the 1.0.0 version for NLsolve. Thank very much for your quick and accurate answers ! I would not have found alone with my stammering computer skills...
Wish you the best,
Normann
They are compatible, you just entered the scene at a very unfortunate time where we just upgraded, and DSGE havn't caught up yet! (fellow economist here, hi!)
It is reassuring to know that bad luck played a significant role in this issue. Thank you again !