Using Julia and Polynomials.jl (https://juliamath.github.io/Polynomials.jl/stable/) with Nimjl https://github.com/clonkk/nimjl) - I used this method in the past for Polynomial of any order
import nimjl
Julia.init(1):
Pkg:
add("Polynomials")
jlUseModule("Polynomials")
var p = Julia.Polynomial([1, 12, -4, 8])
echo p
#1 + 12*x - 4*x^2 + 8*x^3
var s = Julia.roots(p)
echo s
# ComplexF64[-0.08080510243721191 + 0.0im, 0.29040255121860614 - 1.2093793342224015im, 0.29040255121860614 + 1.2093793342224015im]
Using a raw Nim you probably want to start at : https://github.com/SciNim/polynumeric but it's more experimental.
import polynumeric
var p = Poly(cofs: @[8'f32, -4, 12, 1])
var s = p.roots()
echo s
That said for finding read roots of a cubic polynomial it does the job. If you need more advanced functionality, feel free to open a PR. Like @xigoi said, the formulas aren't that complicated.
There also looks to be a wrapper for SymEngine derived from SymPy but in C++. Looks like it has a solve_poly as well as diff and a few others.
https://github.com/SciNim/symengine.nim
Example:
let x = newSymbol("x") # symbol
let y = newSymbol("y") # symbol
let xPlusY = x + y # expression
echo diff(x^2, x) # first derivative