Skip to content

Instantly share code, notes, and snippets.

@tarsisazevedo
Created December 27, 2013 02:06
Show Gist options
  • Select an option

  • Save tarsisazevedo/8141490 to your computer and use it in GitHub Desktop.

Select an option

Save tarsisazevedo/8141490 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math/cmplx"
)
func Cbrt(x complex128) complex128 {
z := complex128(1)
return z - ((cmplx.Pow(z, 3) - x) / 3 * cmplx.Pow(z, 2))
}
func main() {
fmt.Println(Cbrt(2))
fmt.Println(cmplx.Pow(2, 1.0/3.0))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment