I have NSolve solution that gives me roots but not in right order as expected. When I plot data, I am getting the following image (an illustrated simple example):
Ideally, my data should be sorted so that it can be plotted like this:
Below is the code that simulates roots solution:
I have access to Mathematica v9.
My root solution is always symmetrical in y-axis or have one curves at center. The first idea is to fold along the x-axis, take the derivative so that it will give me min,max points that are close to each other at the intersection of supposed two sine waves and then flip the other halves from that point. The other approach is spline fit but it works only for one curve. Has any one experience with this form of fitting? Is it possible to do on two curves intersecting? Any ideas for sorting roots data so that they are ordered for sine waves instead of abs(sine waves)? How do I find seemingly intersecting points?
I also add code that gives similar results using NSolve. Is it possible to modify NSolve to correct the problem without being aware of equation that makes this root solution. That is why I called it a blackbox.
You're complaining that they are Abs, but then that is what you have in your code right? e2 = Abs[…] ?
The equations in e's represent simulated model of output I get from NSolve used to find roots. I used e's as a toymodel of my problem. They are simple to implement and good way to test new routines used to correct output (to get separate sine waves)