Skip to content

Instantly share code, notes, and snippets.

@CarloWood
CarloWood / README_numerical_stable_parabola_roots.md
Last active August 30, 2024 16:50
Numerical stable way to find the local extremes of a cubic (maximum and/or minimum).

Consider having a cubic of the form

  f(x) = a x^3 + b x^2 + c x + d

and you want to know if this cubic has a local minimum and if so, where that minimum is.

Then do the following in your code (make sure that a isn't equal to zero):

// Calculate the discriminant of the derivative of the cubic.
@CarloWood
CarloWood / gist:5b5378f4bcaf67d7b4f2ff07a39b979e
Created December 28, 2020 02:00
Debug output for evio test application that switches protocol after 16300 bytes, limiting the buffer to 16000 bytes at the same time (shows that a deadlock is avoided).
NOTICE : Debug output is turned on.
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from change_specsFixture
[ RUN ] change_specsFixture.change_specs
THREADPOOL : Entering add_threads(30)
ThreadPool00 NOTICE : Thread started. Set debug margin to "ThreadPool00 ".
ThreadPool01 NOTICE : Thread started. Set debug margin to "ThreadPool01 ".
ThreadPool02 NOTICE : Thread started. Set debug margin to "ThreadPool02 ".
ThreadPool03 NOTICE : Thread started. Set debug margin to "ThreadPool03 ".