Skip to content

Instantly share code, notes, and snippets.

@raypereda
Created April 2, 2014 05:10
Show Gist options
  • Save raypereda/9928279 to your computer and use it in GitHub Desktop.
Save raypereda/9928279 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func Cbrt(x complex128) complex128 {
z := x
for i := 0; i < 10; i++ {
z = z - (z*z*z - x)/ (3*z*z)
}
return z
}
func main() {
fmt.Println(Cbrt(2))
x := Cbrt(2)
fmt.Println(x*x*x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment