Created
May 11, 2019 13:20
-
-
Save tae0y/39874454c6b9f2817ecf2efb07d19c8f to your computer and use it in GitHub Desktop.
gotour complex pow
This file contains 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
package main | |
import( | |
"fmt" | |
"math/cmplx" | |
) | |
func Cbrt(x complex128) complex128 { | |
t := x | |
for idx:=0; idx<1000; idx++ { | |
x = x - (x*x*x-t)/(3*x*x) | |
} | |
return x | |
} | |
func main() { | |
input := complex(8, 0) | |
fmt.Println(Cbrt(input)) | |
fmt.Println(cmplx.Pow(Cbrt(input),complex(3,0))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment