Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Basic solving equation with NLsove

$
0
0

Total Julia noob here.

So I would like to ultimately solve an equation f(x,a)=0 for x many times as I vary a and plot the solution as a function of a. Before getting to that though, I am first trying to learn to use NLsolve in a very simple case of the function f(x)=x+1.

I am a bit confused on the usage of NLsolve.
Based on the example in the docs https://github.com/JuliaNLSolvers/NLsolve.jl I try

function f!(F, x)
    F=x+1
end

function j!(J,x)
    J=1
end

NLsolve(f!, j!, 1)

(I am unsure of what to put in the third argument of NLsolve which I guess is the initial condition but I tried a couple things like 1 and [ 0.1; 1.2] which was in the example).

I get this error: https://paste.gg/p/anonymous/d15bfc129c704142888eebc455d3c82c

I would like this to tell me that x=-1.
Any recommendations on how to fix error?

Thanks!

7 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles