Triangular numbers: Difference between revisions

Content added Content deleted
m (Minor rephrasing to be more correct)
m (→‎{{header|Julia}}: precision -> 18)
Line 402: Line 402:


function tetrahedral_root(x)
function tetrahedral_root(x)
return Float64(round((3x + sqrt(9 * big(x)^2 - 1/27))^(1/3) +
return Float64(round((3x + sqrt(9 * x^big"2" - big"1"/27))^(big"1"/3) +
(3x - sqrt(9 * big(x)^2 - 1/27))^(1/3) - 1, digits=11))
(3x - sqrt(9 * x^big"2" - big"1"/27))^(big"1"/3) - 1, digits=18))
end
end


Line 460: Line 460:
Roots of 21408696:
Roots of 21408696:
triangular-root: 6543.0
triangular-root: 6543.0
tetrahedral-root: 503.56182697464
tetrahedral-root: 503.5618269746365
pentatopic-root: 149.06094737526587
pentatopic-root: 149.06094737526587


Line 470: Line 470:
Roots of 14545501785001:
Roots of 14545501785001:
triangular-root: 5.3936071581451725e6
triangular-root: 5.3936071581451725e6
tetrahedral-root: 44355.77738407323
tetrahedral-root: 44355.777384073255
pentatopic-root: 4321.0
pentatopic-root: 4321.0
</pre>
</pre>