Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cubic.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ const cubicSolve = (a, b, c, d) => {
// Only option left is that all roots are real and unequal (to get here, q < 0)
else {
const dum1 = Math.acos(r / Math.sqrt(-q * -q * -q))
const temp = -term1 + 2.0 * Math.sqrt(-q)
const temp = 2.0 * Math.sqrt(-q)

roots[0].real = temp * Math.cos(dum1 / 3.0)
roots[1].real = temp * Math.cos((dum1 + 2.0 * Math.PI) / 3.0)
roots[2].real = temp * Math.cos((dum1 + 4.0 * Math.PI) / 3.0)
roots[0].real = -term1 + temp * Math.cos(dum1 / 3.0)
roots[1].real = -term1 + temp * Math.cos((dum1 + 2.0 * Math.PI) / 3.0)
roots[2].real = -term1 + temp * Math.cos((dum1 + 4.0 * Math.PI) / 3.0)

return roots
}
Expand Down