Question: Function approximation based on set of points

Dear Community!

I'm struggleing with a problem long since. I highly appreciate any help with this theme.

The problem is the following:

- I have a set of points, what comes from a numerical solution of a complex, but periodical function. Therefore I have a set of points (X;Y). The points are doesn't matter, but in my case, it look like this:

I want to use the Fourier-method to approximate this points with a function.

The best result I could get is this:

But it is not acceptable due to the high inaccuracy at the starting, and finishing points (there is a diagram inaccuracy %):

I'm feel like, I'm doing something wrong. Unfortunately, I had no time to look deep into the math here. Can somebody tell me, that how can I get a better result, using this method?

Thank you very much for the help in advance.

Best regards

Dávid

Please Wait...