Last active
September 3, 2025 02:51
-
-
Save ckhung/51c92363bca79dd165435b217c1ec5f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Norman Wildberger + Dean Rubine | |
| # Finding a root of a cubic polynomial with geode | |
| # https://youtu.be/oIHd3zDDDCE?si=BIlgB9ub57UPdJ38&t=1730 | |
| def Q(t2, t3): | |
| return 1 + (t2+t3) * (1+2*t2+3*t3+5*t2*t2+16*t2*t3+12*t3*t3) | |
| def shift(C, ap): | |
| return [ | |
| C[0] + ap*C[1] + ap*ap*C[2] + ap*ap*ap*C[3], | |
| C[1] + 2*ap*C[2] + 3*ap*ap*C[3], | |
| C[2] + 3*ap*C[3], | |
| C[3] | |
| ] | |
| def cubic_root(Coef, x0): | |
| C = Coef | |
| x = x0 | |
| for i in range(5): | |
| C = shift(Coef, x) | |
| print(C) | |
| C1 = -C[1] | |
| t2 = C[0]*C[2]/C1/C1 | |
| t3 = C[0]*C[0]*C[3]/C1/C1/C1 | |
| x += C[0]/C1*Q(t2, t3) | |
| print(x) | |
| cubic_root([-5,-2,0,1], 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment