2
$\begingroup$

I have the given set of points:

points = {{1004.9591023489934`, 
   213.55957424496637`}, {998.3619966442955`, 
   297.1229131711409`}, {996.1629614093961`, 
   275.13256082214764`}, {989.5658557046982`, 
   386.55034605704714`}, {982.96875`, 
   360.1619232382552`}, {971.9735738255035`, 
   298.58893666107394`}, {963.1774328859062`, 
   305.186042365772`}, {954.3812919463089`, 
   270.00147860738275`}, {945.5851510067116`, 
   340.3706061241612`}, {941.1870805369128`, 
   296.3899014261747`}, {934.5899748322149`, 
   329.3754299496645`}, {927.9928691275168`, 
   274.3995490771813`}, {921.3957634228188`, 
   307.38507760067125`}, {910.4005872483222`, 
   305.186042365772`}, {908.201552013423`, 
   351.3657822986579`}, {890.6092701342284`, 
   210.62752726510075`}, {881.8131291946311`, 
   417.3368393456377`}, {864.2208473154362`, 
   245.81209102348998`}, {855.4247063758389`, 
   344.76867659395987`}, {848.827600671141`, 
   285.394725251678`}, {842.2304949664431`, 
   377.7542051174498`}, {826.8372483221477`, 
   265.603408137584`}, {820.2401426174498`, 
   274.3995490771813`}, {809.2449664429531`, 
   377.7542051174498`}, {802.6478607382551`, 
   252.40919672818814`}, {793.8517197986578`, 
   267.80244337248337`}, {785.0555788590605`, 
   393.14745176174506`}, {769.66`, 168.85`}, {758.67`, 
   674.62`}, {745.4729446308726`, 
   175.44296350671158`}, {730.0796979865772`, 
   346.96771182885925`}, {723.4825922818793`, 
   410.7397336409398`}, {719.0845218120807`, 
   274.3995490771814`}, {710.2883808724833`, 
   285.39472525167804`}, {705.8903104026846`, 
   252.40919672818808`}, {692.6960989932886`, 
   289.7927957214767`}, {688.29802852349`, 
   415.13780411073844`}, {677.3028523489934`, 
   313.9821833053693`}, {664.1086409395974`, 
   190.83621015100687`}, {655.3125000000001`, 
   443.72526216442975`}, {646.5163590604027`, 
   270.0014786073827`}, {639.9192533557048`, 
   248.01112625838942`}, {631.1231124161075`, 
   327.17639471476525`}, {617.9289010067115`, 
   373.3561346476512`}, {611.3317953020135`, 
   338.17157088926194`}, {598.1375838926175`, 
   221.6227034395975`}, {589.3414429530202`, 
   404.1426279362418`}, {580.5453020134229`, 
   259.00630243288606`}, {573.9481963087248`, 
   305.186042365772`}, {571.7491610738256`, 360.1619232382552`}}

and I would like to find a Fourier transform of these points.

So I tried the following:

enter image description here

but this does not give any continuous function that intersects each of these points.

I think the best step is to subject these points by the Fourier transform

$$\mathscr{F}\{f(t)\}=\int_{-\infty}^\infty f(t)e^{-i\omega t}d\omega$$

However, to do that, I would either need to use a functionality in mathematica that directly acts on these points, or I should model some piecewise-function to fit these points, and then transform that.

The latter is the best option, because then I would get a continuous function that cross each of these points.

On earlier occasions, I used

fun[t_] := 
 Piecewise[
  Table[{points[[i, 2]], points[[i, 1]] > t}, {i, 
    Length[points]}], 0]

however, this gives a flat line plot, which makes no sense.

How can this command be improved so that I can get a piecewise function which resembles:

enter image description here

?

I was even able to do this by hand a few years ago,

enter image description here

and got a function that was as long as half an A4 page.

UPDATE:

Tried this:

points = {{1004.9591023489934`, 
    213.55957424496637`}, {998.3619966442955`, 
    297.1229131711409`}, {996.1629614093961`, 
    275.13256082214764`}, {989.5658557046982`, 
    386.55034605704714`}, {982.96875`, 
    360.1619232382552`}, {971.9735738255035`, 
    298.58893666107394`}, {963.1774328859062`, 
    305.186042365772`}, {954.3812919463089`, 
    270.00147860738275`}, {945.5851510067116`, 
    340.3706061241612`}, {941.1870805369128`, 
    296.3899014261747`}, {934.5899748322149`, 
    329.3754299496645`}, {927.9928691275168`, 
    274.3995490771813`}, {921.3957634228188`, 
    307.38507760067125`}, {910.4005872483222`, 
    305.186042365772`}, {908.201552013423`, 
    351.3657822986579`}, {890.6092701342284`, 
    210.62752726510075`}, {881.8131291946311`, 
    417.3368393456377`}, {864.2208473154362`, 
    245.81209102348998`}, {855.4247063758389`, 
    344.76867659395987`}, {848.827600671141`, 
    285.394725251678`}, {842.2304949664431`, 
    377.7542051174498`}, {826.8372483221477`, 
    265.603408137584`}, {820.2401426174498`, 
    274.3995490771813`}, {809.2449664429531`, 
    377.7542051174498`}, {802.6478607382551`, 
    252.40919672818814`}, {793.8517197986578`, 
    267.80244337248337`}, {785.0555788590605`, 
    393.14745176174506`}, {769.66`, 168.85`}, {758.67`, 
    28}, {745.4729446308726`, 
    175.44296350671158`}, {730.0796979865772`, 
    346.96771182885925`}, {723.4825922818793`, 
    410.7397336409398`}, {719.0845218120807`, 
    274.3995490771814`}, {710.2883808724833`, 
    285.39472525167804`}, {705.8903104026846`, 
    252.40919672818808`}, {692.6960989932886`, 
    289.7927957214767`}, {688.29802852349`, 
    415.13780411073844`}, {677.3028523489934`, 
    313.9821833053693`}, {664.1086409395974`, 
    190.83621015100687`}, {655.3125000000001`, 
    443.72526216442975`}, {646.5163590604027`, 
    270.0014786073827`}, {639.9192533557048`, 
    248.01112625838942`}, {631.1231124161075`, 
    327.17639471476525`}, {617.9289010067115`, 
    373.3561346476512`}, {611.3317953020135`, 
    338.17157088926194`}, {598.1375838926175`, 
    221.6227034395975`}, {589.3414429530202`, 
    404.1426279362418`}, {580.5453020134229`, 
    259.00630243288606`}, {573.9481963087248`, 
    305.186042365772`}, {571.7491610738256`, 360.1619232382552`}};
draupnerfun[t_] := 
 Piecewise[
  Table[{points[[i, 2]], points[[i, 1]] > t}, {i, Length[points]}], 0]
p0 = Plot[draupnerfun[t], {t, 570, 1005}]

But I got this which is only one large step:

enter image description here

How do I rectify this last command to give all the peaks from the point set into a piecewise function?

Can this be done in Mathematica, and if so, how?

Thanks

$\endgroup$
5
  • $\begingroup$ To get an analytic function either in the time domain or frequency domain you will need to fit a function of your choice. Are you aiming to go through every data point or are you looking to fit a best function? One option is Interpolation it can be used as an ordinary function as any analytic function. However, if by analytic you mean that there are an infinite number of derivatives, or that the function is in some sense smooth then you will have to fit an appropriate function that has these properties. Interpolation will give a smooth function but with a limited number of derivatives. $\endgroup$
    – Hugh
    Commented Feb 9, 2023 at 11:36
  • $\begingroup$ Thanks Hugh, but that does not show to me any visible function, I would need to use this analytic function for an ODE. How can I extract that function information into an analytic form? $\endgroup$ Commented Feb 9, 2023 at 11:43
  • 1
    $\begingroup$ Why do you believe there might be a closed-form function that produces these points? $\endgroup$ Commented Feb 9, 2023 at 23:31
  • $\begingroup$ Because I have done a Fourier transform of a similar set of coordinates and got a result $\endgroup$ Commented Feb 10, 2023 at 10:04
  • 1
    $\begingroup$ You can locate high frequency components using ResourceFunction["IrregularPeriodogram"]. Not sure if that will help for what you want though. $\endgroup$ Commented Feb 10, 2023 at 18:40

1 Answer 1

5
$\begingroup$

Is this what you want to do?

First interpolate data and plot

f = Interpolation[points];
{t1, t2} = f[[1, 1]]
Plot[f[t], {t, t1, t2},
 Epilog -> {Red, Point[points]}, PlotRange -> All]

enter image description here

Now incorporate the interpolation function into an ODE

sol = y /. 
   First@NDSolve[{y''[t] + 0.1 y'[t] + 10^2  y[t] == f[t], y[t1] == 0,
       y'[t1] == 0}, y, {t, t1, t2}];
Plot[sol[t], {t, t1, t2}]

enter image description here

Does this do what you want?

Edit The solution to the ODE is expressed as another interpolation function. If you look at sol it will give you the interpolation function. If you want a solution in terms of elementary functions then I don't think your data can be expressed as an elementary function. If it could then you could use DSolve.

In[20]:= sol

Out[20]= InterpolatingFunction[{{571.749, 1004.96}}, <>]
$\endgroup$
8
  • $\begingroup$ Thanks Hugh. I am not sure I understand the last plot. What is it? $\endgroup$ Commented Feb 9, 2023 at 12:08
  • 1
    $\begingroup$ The last plot is the solution of the ODE with your data on the rhs. This is the differential equation of an oscillator with your data driving the system. There is a start-up transient and then the ODE settles down to follow your data. Play with the coefficients before y'[t] and y[t]to get different effects. $\endgroup$
    – Hugh
    Commented Feb 9, 2023 at 12:13
  • $\begingroup$ Can you extract $y$ here and get it "written out" ? $\endgroup$ Commented Feb 9, 2023 at 12:14
  • 1
    $\begingroup$ See edit. The ODE is just a standard textbook ODE I could have used something simpler or more complicated. My objective was to show how your data could be incorporated into an ODE $\endgroup$
    – Hugh
    Commented Feb 9, 2023 at 12:21
  • 1
    $\begingroup$ Still not sure what you want. Are you asking if your data could be the solution to a differential equation? There are probably infinitely many differential equations that would give your data. I would guess that any ordinary differential equation with time dependent coefficients would work. Please could you be more clear on what you are looking for? Again, if you think your data could be expressed as elementary functions then I don't think this is possible. $\endgroup$
    – Hugh
    Commented Feb 9, 2023 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.