BaseMax / CubicEquationCalculator

Cubic Solver: Cubic Equation Calculator (A X^3 + B X^2 + C X^1 + D = 0)
https://basemax.github.io/CubicEquationCalculator/cubic.html
GNU General Public License v3.0
6 stars 1 forks source link

Theory reference #1

Open Hanlin-Dong opened 1 year ago

Hanlin-Dong commented 1 year ago

Hi, thanks a lot for publishing such a beautiful code. I'm wondering what book or article gives the theory that you write this code?

BaseMax commented 1 year ago

Heya Hanlin, This project is for year ago so I think i used available projects and other software, and a few science articles.

P.S: My education field is Pure Mathematics and I am doing research at the University. Feel free to say me if there is any kind of errors or problems in the code.

Department of Pure Mathematics, Faculty of Mathematical Sciences, University of Kashan, Kashan 87317-53153, I. R. Iran

Hanlin-Dong commented 1 year ago

Hi BaseMax, thanks for the reply. There's no problem at all. I just wanted to know how the expressions are derived. I found the Cardano fomula, but the expressions in your code look much prettier. So I wished if you could tell me where to find articles teaching how to derive these expressions. It's okay if time is too long and you cannot remember where to find them. Thank you.

BaseMax commented 1 year ago

Hi Hanlin, I will search about it later and try to see if I can find out it... I need to check the project again.

For your side, Maybe it's easier to explore the cubic version of this program: https://github.com/BaseMax/CubicEquationCalculator

Hanlin-Dong commented 1 year ago

Hi BaseMax, I tried to write some code on solving cubic equations these days, and also tried your code. However, I found that its result is sometimes wrong when the equation have three real roots. For example, when the coefficients are [1., 800., 3600., 1.], the correct answer should be around [-795, -4.53, -0.000278]. However, the results from your function is [132, -262, 130]. (Run with node v14). Just a report for this issue. Thanks.

BaseMax commented 1 year ago

Hi Hanlin, Can you provide more details about the issue you are referring to?

Thanks in advance.

Hanlin-Dong commented 1 year ago

The function just return incorrect answers, as I described above. After some debug, I found that it may be caused by the cut-off errors in the arccos calculation.

Hanlin-Dong commented 1 year ago

My last comment was incorrect. I have found a bug in the code and pulled a request.

BaseMax commented 1 year ago

Thanks, https://github.com/Hanlin-Dong/CubicEquationCalculator/commit/59188cfffeb093c482836df391e6c05d7ab3081c.

Please send a Pull Request when the patch is ready.