bachrathyd / MDBM.jl

Multi-Dimensional Bisection Method: Julia package to determine the set of roots for 'any' parameter dimension and 'any' codimension
MIT License
33 stars 5 forks source link

Axis points order #21

Closed Noloben closed 4 years ago

Noloben commented 4 years ago

Thank you for your module, it's very useful for my computations. Though, I need a clarification on certain issue.

Repeating your first example ("Computation of a circle") I used axis grids as follows:

ax_x = Axis([-5, 0, 5], "x"); 
ax_y = Axis([-5, 0, 5], "y"); 

and everything worked well. But when I performed

f(x,y)=x^2+y^2-9
ax_x=Axis([0, -5, 5], "x")
ax_y=Axis([0, -5, 5], "y")
mymdbm=MDBM_Problem(f, [ax_x, ax_y])
solve!(mymdbm, 5)
x_sol,y_sol=getinterpolatedsolution(mymdbm)
scatter(x_sol, y_sol)

only bottom-left quarter was calculated. Is it important that axis grid is sorted? 2020-07-04_23-25

Right now I'm going to use MDBM to find intersection of an arbitrary surface with known minima points with a horizontal surface (i. e. solutions of f(x, y)-f0, and we know where minima of f(x, y) are located). I was going to set x-axis grid points as [absoluteLeft, Minimum1x, Minimum2x, ..., absoluteRight] and similar with y-axis. Will it be possible of there will be some problems?

Do I need to sort x-axis and y-axis points ascending? If so, is it OK that x-axis and y-axis points do not coincide for each given minimum? For example, will intersection of 2nd x-axis point and 5th y-axis point be considered?

bachrathyd commented 4 years ago

Hi! Theoretically, it is possible to use unsorted vectors as a grid (however, it is pointless). In this case, the initial grid is like a folded paper and there will be overlapping regions. In your example, there are two initial segments for both axes: [0,-5] and [-5,5] which will be divided later. The first segment is ok (there are proper sign changes), but the second is too large so the solution is lost.

So I suggest sorting the axes (ascending or descending)! The repeated points should not be a problem.

See the test for unsorted axes with repeated points:

using MDBM
using Plots
f(x,y)=x^2+y^2-9
ax_x=Axis([0, -5, -5, 0,0,0, 5], "x")
ax_y=Axis([0, -5, -5, 0,0,0, 5], "y")
mymdbm=MDBM_Problem(f, [ax_x, ax_y])
solve!(mymdbm,5)
x_sol,y_sol=getinterpolatedsolution(mymdbm)
scatter(x_sol, y_sol)

image