Let's explore Go's built-in support for complex numbers via the complex64 and complex128 types. For cube roots, Newton's method amounts to repeating:

Find the cube root of 2, just to make sure the algorithm works. There is a Pow function in the math/cmplx package.

package main

import "fmt"

func Cbrt(x complex128) complex128 {
z := complex128()
for i := ;i < ;i++{
z = z - (z*z*z -x)/(*z*z)
}
return z
} func main() {
fmt.Println(Cbrt())
}

A Tour of Go Advanced Exercise: Complex cube roots的更多相关文章

  1. exercise.tour.go google的go官方教程答案

    /* Exercise: Loops and Functions #43 */ package main import ( "fmt" "math" ) fun ...

  2. 摘记 pyinstaller 使用自定义 spec

    下面的是官网的文档, 我们可以用自定义spec的方式把想要的文件打包到目标文件夹里面 例如: 我们在程序中用了一个图标 test.ico, 如果我们只用 pyinstaller -w test.py ...

  3. EBS Custom Password Rules

    https://blogs.oracle.com/manojmadhusoodanan/entry/custom_password_rules Custom Password Rules By Man ...

  4. OPC and .NET

    Note: recent OPC standards, including Unified Architecture (UA) and Express Interface (Xi) were desi ...

  5. iOS Testing with Xcode 阅读笔记

    官方文档直通车 Performance Testing A baseline is a combination of the average time performance in ten runs ...

  6. 理工科应该的知道的C/C++数学计算库(转)

    理工科应该的知道的C/C++数学计算库(转) 作为理工科学生,想必有限元分析.数值计算.三维建模.信号处理.性能分析.仿真分析...这些或多或少与我们常用的软件息息相关,假如有一天你只需要这些大型软件 ...

  7. java-信息安全(一)-BASE64,MD5,SHA,HMAC

    概述 信息安全基本概念: BASE64 编码格式 MD5(Message Digest algorithm 5,信息摘要算法) SHA(Secure Hash Algorithm,安全散列算法) HM ...

  8. 在WINDOWS中安装使用GSL(MinGW64+Sublime Text3 & Visual Studio)

    本文介绍在Windows下安装使用GSL库,涉及GSL两个版本(官方最新版及GSL1.8 VC版).msys shell.GCC.G++等内容,最终实现对GSL安装及示例基于MinGW64在Subli ...

  9. 常见的C++数学计算库

    来源: https://blog.csdn.net/panhao762/article/details/55276811 作为理工科学生,想必有限元分析.数值计算.三维建模.信号处理.性能分析.仿真分 ...

随机推荐

  1. linux查看在线用户 who命令参数及用法

    linux who 命令 详解 Linux最常用命令之一 功能说明:显示目前登入系统的用户信息. 语 法:who [-Himqsw][--help][--version][am i][记录文件] 补充 ...

  2. 【无聊放个模板系列】POJ 3678 2-SAT

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  3. [itint5]完全二叉树节点个数的统计

    http://www.itint5.com/oj/#4 这题是利用完全二叉树的性质计算节点数目.那么是通过比较左右子树的最左结点的高度来看那边是满的,然后递归计算. //使用getLeftChildN ...

  4. Android:安卓资源引用符号的含义

    @代表引用资源 @*代表引用系统的非public资源,如: @*android:color/white @[package:]type/name引用自定义资源,如: android:text=&quo ...

  5. Android:属性scaleType与图片的显示

    ImageView是Android中的基础图片显示控件,该控件有个重要的属性是ScaleType,该属性用以表示显示图片的方式, 共有8种取值 matrix 用矩阵来绘制(从左上角起始的矩阵区域) f ...

  6. Android四大基本组件

    Android四大基本组件分别是 Activity:整个应用程序的门面,负责与用户进行交互. Service:承担大部分工作. Content Provider内容提供者:负责对外提供数据,并允许需要 ...

  7. 179. Largest Number

    题目: Given a list of non negative integers, arrange them such that they form the largest number. For ...

  8. 174. Dungeon Game

    题目: The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dung ...

  9. php.ini – 配置文件详解

    详见: https://my.oschina.net/miaowang/blog/299546 这个文件必须命名为''php.ini''并放置在httpd.conf中的PHPIniDir指令指定的目录 ...

  10. javascript 小日历

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx. ...