A Tour of Go Advanced Exercise: Complex cube roots
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的更多相关文章
- exercise.tour.go google的go官方教程答案
/* Exercise: Loops and Functions #43 */ package main import ( "fmt" "math" ) fun ...
- 摘记 pyinstaller 使用自定义 spec
下面的是官网的文档, 我们可以用自定义spec的方式把想要的文件打包到目标文件夹里面 例如: 我们在程序中用了一个图标 test.ico, 如果我们只用 pyinstaller -w test.py ...
- EBS Custom Password Rules
https://blogs.oracle.com/manojmadhusoodanan/entry/custom_password_rules Custom Password Rules By Man ...
- OPC and .NET
Note: recent OPC standards, including Unified Architecture (UA) and Express Interface (Xi) were desi ...
- iOS Testing with Xcode 阅读笔记
官方文档直通车 Performance Testing A baseline is a combination of the average time performance in ten runs ...
- 理工科应该的知道的C/C++数学计算库(转)
理工科应该的知道的C/C++数学计算库(转) 作为理工科学生,想必有限元分析.数值计算.三维建模.信号处理.性能分析.仿真分析...这些或多或少与我们常用的软件息息相关,假如有一天你只需要这些大型软件 ...
- java-信息安全(一)-BASE64,MD5,SHA,HMAC
概述 信息安全基本概念: BASE64 编码格式 MD5(Message Digest algorithm 5,信息摘要算法) SHA(Secure Hash Algorithm,安全散列算法) HM ...
- 在WINDOWS中安装使用GSL(MinGW64+Sublime Text3 & Visual Studio)
本文介绍在Windows下安装使用GSL库,涉及GSL两个版本(官方最新版及GSL1.8 VC版).msys shell.GCC.G++等内容,最终实现对GSL安装及示例基于MinGW64在Subli ...
- 常见的C++数学计算库
来源: https://blog.csdn.net/panhao762/article/details/55276811 作为理工科学生,想必有限元分析.数值计算.三维建模.信号处理.性能分析.仿真分 ...
随机推荐
- android 点击重新加载界面设计
在项目中经常会遇到这样的场合,用户点击了一个界面后要提示等待加载,最后有可能显示加载失败,点击屏幕再重试加载.下面是该实例的代码: layout: loading.xml <?xml versi ...
- SPRING IN ACTION 第4版笔记-第九章Securing web applications-004-对密码加密passwordEncoder
一. 1.Focusing on the authentication query, you can see that user passwords are expected to be stored ...
- 分布式事务的管理--atomikos
在一些业务场景及技术架构下,跨库的事务时不可避免的,这时候如何统一管理事务,保证事务的强一致性是整个系统稳定.可用基石.一些中间件如tuxedo.cics就是凭借这个能力占据了金融.电信.银行等很大的 ...
- 219. Contains Duplicate II
题目: Given an array of integers and an integer k, find out whether there are two distinct indices i a ...
- HDU4908——BestCoder Sequence(BestCoder Round #3)
BestCoder Sequence Problem DescriptionMr Potato is a coder.Mr Potato is the BestCoder.One night, an ...
- 智传播客hadoop视频学习笔记(共2天)
第一天:1.答疑解惑• 就业前景• 学习hadoop要有什么基础• hadoop会像塞班一样,热一阵子吗• hadoop学习起来容易还是困难• 课堂上的学习方法(所有实验必须按照要求做,重原 ...
- NFC(10)NDEF uri格式规范及读写示例(解析与封装ndef uri)
只有遵守NDEF uri 格式规范的数据才能写到nfc标签上. NDEF uri 格式规范 uri 只有两部分: 第1个字节是uri协议映射值,如:0x01 表示uri以 http://www.开头. ...
- 在XML里的XSD和DTD以及standalone的使用2----具体使用详解
如何定义XSD并在XML中使用XSD 同时XSD可以对XML中的格式进行约束,当约束失败时给出提示. 下面以下使用VS2010为平台进行演示. 1.新建一个项目,然后在项目中添加xml架构文件(.xs ...
- c# 产生随机字符串,包括大小写字母和数字
#region MyRegion //產生密碼 protected static string GetPwd() { return CreateRandomNum123(2) + CreateRand ...
- (转载) ExtJs大比拼JQuery:Dom文档操作
此次不生产水,做一次搬运工. http://www.cnblogs.com/lipan/archive/2011/12/07/2269815.html