- Home /

# 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.

E.g.,

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.

**Answer** by Bunny83
·
Apr 19, 2020 at 03:34 AM

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.

@Bunny83 Sorry for the confusion, I've been searching this for a while and often the "linear" word is included so I just assumed it where, it is indeed a polynomial equation.

I am looking for a general way to solve a 4th degree polynomial, not the specific x⁴ + x³ + x² + x + e = 0, the one I'm working with has different coefficients.

The reason I'm asking this in "Unity Answers" is because whatever way to solve my problem needs to be compatible with unity and as I mentioned before "Efficiency is important since I need to solve the equation several times every couple seconds on runtime."

I'll take a look at the links you provided, thanks.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Multiple Cars not working 1 Answer

Limit Rotation Issues 1 Answer

How to you make a number squared in C#? 2 Answers

Linear optimization 0 Answers

Distribute terrain in zones 3 Answers