cmplx

package
v1.26.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

cmplxパッケージは、複素数の基本的な定数と数学関数を提供します。 特殊なケースの処理は、C99標準の付録G IEC 60559互換の複素数演算に準拠しています。

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(x complex128) float64

Absはxの絶対値(またはモジュラスとも呼ばれる)を返します。

Example
package main

import (
	"github.com/shogo82148/std/fmt"
	"github.com/shogo82148/std/math/cmplx"
)

func main() {
	fmt.Printf("%.1f", cmplx.Abs(3+4i))
}
Output:
5.0

func Acos

func Acos(x complex128) complex128

Acosはxの逆余弦を返します。

func Acosh

func Acosh(x complex128) complex128

Acoshはxの逆双曲線余弦を返します。

func Asin

func Asin(x complex128) complex128

Asinはxの逆正弦を返します。

func Asinh

func Asinh(x complex128) complex128

Asinhはxの逆双曲線正弦を返します。

func Atan

func Atan(x complex128) complex128

Atanはxの逆正接を返します。

func Atanh

func Atanh(x complex128) complex128

Atanhはxの逆双曲線正接を返します。

func Conj

func Conj(x complex128) complex128

Conjはxの複素共役を返します。

func Cos

func Cos(x complex128) complex128

Cosはxの余弦を返します。

func Cosh

func Cosh(x complex128) complex128

Coshはxの双曲線余弦を返します。

func Cot

func Cot(x complex128) complex128

Cotはxの余接を返します。

func Exp

func Exp(x complex128) complex128

Expはe**xを返します。これはxの底eの指数です。

Example

ExampleExpはオイラーの公式を計算します。

package main

import (
	"github.com/shogo82148/std/fmt"
	"github.com/shogo82148/std/math"
	"github.com/shogo82148/std/math/cmplx"
)

func main() {
	fmt.Printf("%.1f", cmplx.Exp(1i*math.Pi)+1)
}
Output:
(0.0+0.0i)

func Inf

func Inf() complex128

Infは複素数の無限大、complex(+Inf, +Inf)を返します。

func IsInf

func IsInf(x complex128) bool

IsInfは、real(x)またはimag(x)のいずれかが無限大であるかどうかを報告します。

func IsNaN

func IsNaN(x complex128) bool

IsNaNは、real(x)またはimag(x)のいずれかがNaN(非数)であり、 どちらも無限大でないかどうかを報告します。

func Log

func Log(x complex128) complex128

Logはxの自然対数を返します。

func Log10

func Log10(x complex128) complex128

Log10はxの10を底とする対数を返します。

func NaN

func NaN() complex128

NaNは複素数の「非数」値を返します。

func Phase

func Phase(x complex128) float64

Phaseはxの位相(引数とも呼ばれる)を返します。 返される値の範囲は[-Pi, Pi]です。

func Polar

func Polar(x complex128) (r, θ float64)

Polarはxの絶対値rと位相θを返します。 そのため、x = r * e**θiとなります。 位相は範囲[-Pi, Pi]内にあります。

Example
package main

import (
	"github.com/shogo82148/std/fmt"
	"github.com/shogo82148/std/math"
	"github.com/shogo82148/std/math/cmplx"
)

func main() {
	r, theta := cmplx.Polar(2i)
	fmt.Printf("r: %.1f, θ: %.1f*π", r, theta/math.Pi)
}
Output:
r: 2.0, θ: 0.5*π

func Pow

func Pow(x, y complex128) complex128

Powはx**y、すなわちyの底xの指数を返します。 math.Pow との一般的な互換性のために:

Pow(0, ±0)は1+0iを返します
real(c)<0の場合のPow(0, c)は、imag(c)がゼロの場合はInf+0iを返し、それ以外の場合はInf+Inf iを返します。

func Rect

func Rect(r, θ float64) complex128

Rectは、極座標r, θを持つ複素数xを返します。

func Sin

func Sin(x complex128) complex128

Sinはxの正弦を返します。

func Sinh

func Sinh(x complex128) complex128

Sinhはxの双曲線正弦を返します。

func Sqrt

func Sqrt(x complex128) complex128

Sqrtはxの平方根を返します。 結果のrは、real(r) ≥ 0 かつ imag(r)がimag(x)と同じ符号になるように選ばれます。

func Tan

func Tan(x complex128) complex128

Tanはxの正接を返します。

func Tanh

func Tanh(x complex128) complex128

Tanhはxの双曲線正接を返します。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL