2
$\begingroup$

I'm trying to work with a numerical function as a list of elements:

{{x1, y1}, f1}, {x2, y2}, f2}, ..., {xN, yN}, fN}}

I've produced the list in other programming language (c++) and imported it in the Mathematica with Import["file.txt", "Table"]. I had to solve the problem of repeating points by using:

Map[{#[[1, 1]], Mean[#[[All, 2]]]} &, 
 GatherBy[{{#1, #2}, #3} & @@@ Import["file.txt", "Table"], First]]

so far I've been able to interpolate it and show the result with Plot3D. However, if I try to interpolate the newest list, I get an error:

The element mesh has insufficient quality of -6.07539 10^-14. A
quality estimate below 0. may be caused by a wrong ordering of
element incidents or self-intersecting elements.

and

The quality -6.07539*10^-14 of the underlying mesh is too low. The
quality needs to be larger than 0.

I cannot post the list here as it has 171422 elements. I found some topics related to this (Interpolation function error: Interpolation::femimq and Interpolation::fememtlq), but rescaling one axis doesn't help. I also found something else (http://community.wolfram.com/groups/-/m/t/777582) but that doesn't work neither, as Union[] by checking if the points are too close is very very slow.

The mesh of {x,y} points consists of equidistant points x. Y points for each x are generated separately with varying step so the grid is not structured, but I can't imagine how could any "self intersections" raise from this setup. I also don't understand what "ordering" means in this case (as Mathematica mentions ordering in the error message); one cannot meaningfully/objectively order 2D points, the same goes for ordering complex numbers. What can I do to interpolate my function succesfully? Thank you for the help.

P.S. As requested, I managed to upload it on the scribd https://www.scribd.com/document/338778472/Z so you can try.

Here is the dropbox link for all three files that resist the interpolation command: https://www.dropbox.com/sh/z8ve3qs0x0djcm7/AAD7t5IZ_qBR6dVDBoDMGOIta?dl=0

I think I've found som brute-force solution: add to the coordinates some random list of small magnitude, like:

z[[All,1]] = z[[All, 1]] + RandomReal[10^-10*{-1, 1}, Dimensions[z[[All, 1]]]];

Although it obviously works here (the problematic triangle in mesh is made of three nearly collinear points, so moving them a little might solve a problem), I have a problem with this approach: it really looks a bit butchered. What if I need the data to be exactly the same as I got them? Even the coordinates? And why Mathematica can't just find mesh that works? Is there a theorem that ensures that for given set of 2D noncollinear points you can always create a triangular mesh with well defined triangles? I think that this is matter of alrogithm Mathematica uses to pick which points made triangles - if I rearrange some neighbour points to belong to other triangles, I can get well defined triangular mesh. Isn't there some more "scientific" approach to repair the mesh?

$\endgroup$
  • $\begingroup$ It would make it much easier to help if you provided the data. You can upload it to Dropbox or textuploader or a similar service $\endgroup$ – yohbs Feb 8 '17 at 15:17
  • $\begingroup$ TextUploader: "request entity too large". $\endgroup$ – user16320 Feb 8 '17 at 15:20
  • $\begingroup$ Try to upload the file on Dropbox (or similar service) and give the link for those who want to try. And perhaps a small subset of data post here to use as example. $\endgroup$ – ercegovac Feb 8 '17 at 15:38
  • $\begingroup$ Okay, I uploaded it on the scribd, an edit with a link was made to my question. $\endgroup$ – user16320 Feb 8 '17 at 15:43
  • $\begingroup$ In order to get to the data in scribd, it seems that one has to sign up for an account, and I need a new online account like a need a hole in the head. Can you use a service that doesn't require that? $\endgroup$ – MarcoB Feb 11 '17 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.