Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
A package provides implementation of complex numbers and mathematical functions for complex numbers.
A package provides implementation of complex numbers and some mathematical functions for complex numbers.
The Complex
class represents a complex number which has a real part and an
imaginary part. It is expressed in form a + bi
, where:
a
: the real partb
: the imaginary parti
: the imaginary unit
You can also create a complex number using cmplx
function.
import { cmplx } from "@babia/complex"; const cmplx1 = cmplx(1, 9); // 1 + 9i const cmplx2 = cmplx(5, 4); // 5 + 4i
The Complex
class has methods to perform basic operations, such as add()
,
sub()
, etc.
import { cmplx } from "@babia/complex"; const cmplx1 = cmplx(1, 9); // 1 + 9i const cmplx2 = cmplx(5, 4); // 5 + 4i cmplx1.add(cmplx2); // (1 + 9i) + (5 + 4i) cmplx1.sub(cmplx2); // (1 + 9i) - (5 + 4i)
Besides that, this package also has ComplexMath
which provides basic
mathematics functionality for complex numbers, such as sin()
, atan()
,
log()
, etc.
import { ComplexMath, cmplx } from "@babia/complex"; const cmplx1 = cmplx(1, 9); // 1 + 9i const cmplx2 = cmplx(5, 4); // 5 + 4i ComplexMath.sqrt(cmplx1); ComplexMath.log(cmplx1); ComplexMath.pow(cmplx2, 3);
Based on http://netlib.sandia.gov/cephes/c9x-complex and https://pkg.go.dev/math/cmplx.
Add Package
deno add jsr:@babia/complex
Import symbol
import * as mod from "@babia/complex";
---- OR ----
Import directly with a jsr specifier
import * as mod from "jsr:@babia/complex";
Add Package
npx jsr add @babia/complex
Import symbol
import * as mod from "@babia/complex";
Add Package
yarn dlx jsr add @babia/complex
Import symbol
import * as mod from "@babia/complex";
Add Package
pnpm dlx jsr add @babia/complex
Import symbol
import * as mod from "@babia/complex";
Add Package
bunx jsr add @babia/complex
Import symbol
import * as mod from "@babia/complex";