Hi all, possibly a simple/silly question: how do I pass parameters to the function for which I want to find the set of roots in two (or more dimensions) using IntervalRootFinding? In 1D I can use an anonymous function roots(x -> f(x,p), X)
where p is a struct I’ve previously defined, and X the interval. In 2D I’ve tried roots( (x,y) -> f2d( (x,y), p), X×X)
, but get a "MethodError: No method matching.
Thanks in advance
Hi, the problem here isnt the parameter its the signature of the anonymous function. Basically, your function gets called with a single argument, not 2 arguments (x and y)
this should work roots( x -> f2d( (x[1],x[2]), p), X×X)
see also Home · IntervalRootFinding.jl
Answering my own question (writing it out helped thinking). This works: roots( ((x,y), ) -> f2d( (x,y), p), X×X)
. I would think the extra comma is there so that (x,y)
is interpreted as a tuple in a tuple with one element. Hope this helps somebody else.
Thanks again
1 Like