# What is the syntax for using Reap and Sow and WhenEvent with derivative = 0 with interpolating function?

I have a system of three ODEs. This system oscillates. I need to determine the frequency of each of the three solutions.

My file. You can download and modify this.

I’m new to Mathematica and I know this question has been asked multiple times, but I can’t get it working.

``{xSol, ySol, zSol} = NDSolveValue[{ode1, ode2, ode3, ic2}, {x, y, z}, {t, 0, 200}] ``

Plotting `xSol`, `ySol` and `zSol` (three interpolating functions) gives: Can anyone show me how to determine the frequency of this thing using `Reap` and `Sow` or FFT. I’ve been instructed already how to do this using EcoEvo package, but I’m also wondering how to do it without such a package.

Both the Reap/Sow solution and the FFT come pretty close to what I have and need. But I fail in modifying the mentioned solutions so that it works with my code.

How do I individually determine the frequency of `xSol`, `ySol` and `zSol`?

My implementation of WhenEvent

For example, when I try to use `WhenEvent`, I used it like this:

``{xSol, ySol, zSol} = NDSolveValue[{ode1, ode2, ode3, ic2, WhenEvent[x'[t] == 0, Sow[t]]}, {x, y, z}, {t, 0, 200}] ``

This gives me an error (which I presume to be about the WhenEvent) and my regular solutions. Because the solutions are correct, I think that the problem here is in the WhenEvent. Error: Event location failed to converge to the requested accuracy or precision within 100 iterations between t = … and t = ….

All suggestions and solutions are highly appreciated! Many thanks😊

Posted on Categories cheapest proxies