Hello,
I am currently looking for code that is able to solve quartic equations, most likely through inputting the coefficients of the equation. I would much prefer if this code source was in Lua as the code from what I have seen is long and complex math wise, which I would not want to translate back into Lua.
Unless youāre doing some second-degree derivative ballistic trajectory equation mumbo jumbo, I donāt see any practical use case for quartic equations within a Roblox game
I mean, if it looks like this I doubt anyone has converted a quartic formula into programming language form
I am getting a turret to predict a path with gravity affecting the bullet. People have converted it, but not into Lua from what Iāve seen, which might take some time to convert.
It looks like youāre going to be the first one to do so then.
Thereās this article: https://github.com/CasualX/ProjectileSolverDemo
And then thereās also this:
Which claims to ācompensate for gravityā which Iāve yet to test for myself
He mentioned exponential gravity, is that some sort of pseudo gravity or just regular gravity?
I have no idea; like I said, I havenāt tested the gravity compensation myself, only went as far as opening up the demo and having a peek
I canāt really understand the language of the website you linked, it is using a language I have never used myself, but I did find a C written one. I am confused about one part of it. Each function has parameters of c
and s
, do you by any chance know what each might correlate too? I believe they are both arrays just donāt know what they are specified for.
(Was clicking on the wrong website somehow, looking over it now though)
ācā appears to be the input and āsā is the output. The function themselves doesnāt return the solution, they instead plop it inside the āsā table which contains all real solutions
Would c
be ordered from greatest power to lowest power? For example 7x^2+3x+17 would go in as
[7, 3, 17]?
Dude you have the source code in front of you
It also literally tells you that at the top within the comment block
Use rational root theorem.
Hi
Yeah right now the moduleās a bit broken, Iāll see if I can fix it and re-send the model
thanks for letting me know nonetheless
Hi itās me again so I just found this cool math module that uses Newton iteration to solve polynomials
It seems to be working fine for me (except for that duplicate answer)
Hi, would you mind giving the function you graphed in the image, I want to fix the duplicate answer problem and use that function to check if its fixed or not
0.1*x^4 + x^3 + 2.5*x^2 + 0.8*x - 1
Looking at your module it seems like you can fix it by adding a precision threshold for the hash
table check so that minuscule differences wonāt matter
Fixed, turns out math.round isnt practical when eliminating very similar answers from tables, thanks for the help!
Just ended up translating the github I linked and works perfectly.
you know i already did everything
also there was a native Lua formula for quartics, you just had to dig deeper
We are using the same sources and the translation of the code doesnāt take long at all so honestly Iād rather write it myself, but thanks.