Looking for a way to solve a 4th degree polynomial equation with constraints at runtime

I’m looking for a way to solve a single 4th degree polynomial equation with real coefficients and constraints at runtime.


x⁴ + x³ + x² + x + c = 0 | C being a constant.With a single constraint(in my case x>0).

I have looked into some libraries such as www.meta-numerics.net but it does not include ways to add constraints to methods such as Meta.Numerics.Analysis.FunctionMath.FindZero().

Specifically, what I need is a function/method that can find the smallest root/zero of a 4th degree polynomial equation as long as the root/zero is greater than 0. Efficiency is important since I need to solve the equation several times every couple seconds on runtime.

Any help/insight is greatly appreciated.

Edit: Corrected the misleading title.

Uhm your question is quite unusual and barely related to Unity. Also what you presented here is not a linear equation at all since it has a higher degree than 1 ^^. So your title is misleading as you have a polynomial.

The question also seems a bit vague. Are you looking for a general way to solve any quartic polynomial? (So the form ax⁴ + bx³ + cx² + dx + e = 0) Or do you really just looking for the solutions for x⁴ + x³ + x² + x + e = 0 (so all coefficients are 1?). If it’s the second case it should be clear that there is no solution if e >= 0 so “e” must be negative. However if you actually looking for the general quartic polynomial, have a look over here and here

Though as already mentioned this question is pretty much off-topic here on UnityAnswers since it has nothing to do with Unity. This is a pure math / C# problem.