Calculate the difference between the elements in a list
Your implementation is good and easy to understand.

When using List&lt;Double&gt; for input data, be sure to use an efficient implementation. Otherwise you could get really bad read performance. E.g., when you access elements by index, ArrayList&lt;Double&gt; will be much faster than LinkedList&lt;Double&gt; (\$O(n)\$ vs. \$O(n^2)\$ for your getSpeedS).

If you must support arbitrary types of List&lt;Double&gt; you would probably better off when you use Iterators instead of element access by index.

If you use an ArrayList and know its final size in advance, always construct it with the capacity needed (new ArrayList&lt;&gt;(size)). This avoids reallocation and copying of the internal array that holds the elements while adding elements.

If you need maximum performance, then use arrays (double[]) instead of lists. For large data sets they can speed up the creation of the input in-memory objects by factors greater than two. Additionally they may give you a significant advantage in read performance due to better utilization of processor caches compared to list implementations.