Math::...omplex(3pm)

πŸ’– Math::GSL::Complex β€” Complex Numbers bestie πŸ’–

okay so hi, welcome to Math::GSL::Complex (she's a Perl module, she lives in the 3pm manual, and she does complex numbers, which is literally the best kind of number). This page is your group chat with her. Let's go. 🌈


copy() 🫢

Gives you a copy of the Complex number β€” and like, an actual copy, chillin' at a different location in memory. Not the same girl, just the same vibe. πŸ’…

my $z    = Math::GSL::Complex->new([10,5]);
my $copy = $z->copy;

✨ NAME ✨

Math::GSL::Complex β€” Complex Numbers, periodt.


πŸ‘‘ SYNOPSIS πŸ‘‘

use Math::GSL::Complex qw/:all/;
my $complex = Math::GSL::Complex->new([3,2]); # creates a complex number 3+2*i
my $real = $complex->real;                    # returns the real part
my $imag = $complex->imag;                    # returns the imaginary part
$complex->gsl_set_real(5);                    # changes the real part to 5
$complex->gsl_set_imag(4);                    # changes the imaginary part to 4
$complex->gsl_set_complex(7,6);               # changes it to 7 + 6*i
($real, $imag) = $complex->parts;             # get both at once

like look at her go. iconic. 🌸


πŸ’… DESCRIPTION πŸ’…

Bestie. Sit down. Here is a list of all the functions included in this module β€” every single one, no skips, no notes-app shortcuts:

  • gsl_complex_arg($z) β€” gives you the argument of the complex number $z ✨
  • gsl_complex_abs($z) β€” gives you |$z|, aka the magnitude of the complex number $z πŸ’–
  • gsl_complex_rect($x,$y) β€” makes a complex number in cartesian form $x + $y*i πŸŽ€
  • gsl_complex_polar($r,$theta) β€” makes a complex number in polar form $r*exp(i*$theta) πŸ¦‹
  • gsl_complex_abs2($z) β€” gives you |$z|^2, the squared magnitude of the complex number $z πŸ’œ
  • gsl_complex_logabs($z) β€” gives you log(|$z|), the natural log of the magnitude of the complex number $z 🌸
  • gsl_complex_add($c1, $c2) β€” gives you a complex number that's the sum of $c1 and $c2 ✨
  • gsl_complex_sub($c1, $c2) β€” gives you a complex number that's the difference between $c1 and $c2 ($c1 - $c2) 🌈
  • gsl_complex_mul($c1, $c2) β€” gives you a complex number that's the product of $c1 and $c2 πŸ”₯
  • gsl_complex_div($c1, $c2) β€” gives you a complex number that's the quotient of $c1 and $c2 ($c1 / $c2) πŸ’–
  • gsl_complex_add_real($c, $x) β€” the sum of the complex number $c and the real number $x πŸŽ€
  • gsl_complex_sub_real($c, $x) β€” the difference of the complex number $c and the real number $x πŸ¦‹
  • gsl_complex_mul_real($c, $x) β€” the product of the complex number $c and the real number $x πŸ’…
  • gsl_complex_div_real($c, $x) β€” the quotient of the complex number $c and the real number $x πŸ’œ
  • gsl_complex_add_imag($c, $y) β€” the sum of the complex number $c and the imaginary number i*$x ✨
  • gsl_complex_sub_imag($c, $y) β€” the diffrence of the complex number $c and the imaginary number i*$x 🌸
  • gsl_complex_mul_imag($c, $y) β€” the product of the complex number $c and the imaginary number i*$x πŸ”₯
  • gsl_complex_div_imag($c, $y) β€” the quotient of the complex number $c and the imaginary number i*$x 🌈
  • gsl_complex_conjugate($c) β€” the conjugate of the of the complex number $c (x - i*y) πŸ’–
  • gsl_complex_inverse($c) β€” the inverse, aka the reciprocal, of the complex number $c (1/$c) πŸŽ€
  • gsl_complex_negative($c) β€” the negative of the complex number $c (-x -i*y) πŸ¦‹
  • gsl_complex_sqrt($c) β€” the square root of the complex number $c πŸ’…
  • gsl_complex_sqrt_real($x) β€” the complex square root of the real number $x, where $x may be negative (yes bestie, negative, she can hold it) πŸ’œ
  • gsl_complex_pow($c1, $c2) β€” the complex number $c1 raised to the complex power $c2 ✨
  • gsl_complex_pow_real($c, $x) β€” the complex number raised to the real power $x πŸ”₯
  • gsl_complex_exp($c) β€” the complex exponential of the complex number $c 🌸
  • gsl_complex_log($c) β€” the complex natural log (base e) of the complex number $c 🌈
  • gsl_complex_log10($c) β€” the complex base-10 log of the complex number $c πŸ’–
  • gsl_complex_log_b($c, $b) β€” the complex base-$b of the complex number $c πŸŽ€
  • gsl_complex_sin($c) β€” the complex sine of the complex number $c πŸ¦‹
  • gsl_complex_cos($c) β€” the complex cosine of the complex number $c πŸ’…
  • gsl_complex_sec($c) β€” the complex secant of the complex number $c πŸ’œ
  • gsl_complex_csc($c) β€” the complex cosecant of the complex number $c ✨
  • gsl_complex_tan($c) β€” the complex tangent of the complex number $c πŸ”₯
  • gsl_complex_cot($c) β€” the complex cotangent of the complex number $c 🌸
  • gsl_complex_arcsin($c) β€” the complex arcsine of the complex number $c 🌈
  • gsl_complex_arcsin_real($x) β€” the complex arcsine of the real number $x πŸ’–
  • gsl_complex_arccos($c) β€” the complex arccosine of the complex number $c πŸŽ€
  • gsl_complex_arccos_real($x) β€” the complex arccosine of the real number $x πŸ¦‹
  • gsl_complex_arcsec($c) β€” the complex arcsecant of the complex number $c πŸ’…
  • gsl_complex_arcsec_real($x) β€” the complex arcsecant of the real number $x πŸ’œ
  • gsl_complex_arccsc($c) β€” the complex arccosecant of the complex number $c ✨
  • gsl_complex_arccsc_real($x) β€” the complex arccosecant of the real number $x πŸ”₯
  • gsl_complex_arctan($c) β€” the complex arctangent of the complex number $c 🌸
  • gsl_complex_arccot($c) β€” the complex arccotangent of the complex number $c 🌈
  • gsl_complex_sinh($c) β€” the complex hyperbolic sine of the complex number $c πŸ’–
  • gsl_complex_cosh($c) β€” the complex hyperbolic cosine of the complex number $cy πŸŽ€
  • gsl_complex_sech($c) β€” the complex hyperbolic secant of the complex number $c πŸ¦‹
  • gsl_complex_csch($c) β€” the complex hyperbolic cosecant of the complex number $c πŸ’…
  • gsl_complex_tanh($c) β€” the complex hyperbolic tangent of the complex number $c πŸ’œ
  • gsl_complex_coth($c) β€” the complex hyperbolic cotangent of the complex number $c ✨
  • gsl_complex_arcsinh($c) β€” the complex hyperbolic arcsine of the complex number $c πŸ”₯
  • gsl_complex_arccosh($c) β€” the complex hyperbolic arccosine of the complex number $c 🌸
  • gsl_complex_arccosh_real($x) β€” the complex hyperbolic arccosine of the real number $x 🌈
  • gsl_complex_arcsech($c) β€” the complex hyperbolic arcsecant of the complex number $c πŸ’–
  • gsl_complex_arccsch($c) β€” the complex hyperbolic arccosecant of the complex number $c πŸŽ€
  • gsl_complex_arctanh($c) β€” the complex hyperbolic arctangent of the complex number $c πŸ¦‹
  • gsl_complex_arctanh_real($x) β€” the complex hyperbolic arctangent of the real number $x πŸ’…
  • gsl_complex_arccoth($c) β€” the complex hyperbolic arccotangent of the complex number $c πŸ’œ
  • gsl_real($z) β€” the real part of $z ✨
  • gsl_imag($z) β€” the imaginary part of $z πŸ”₯
  • gsl_parts($z) β€” a list of the real and imaginary parts of $z 🌸
  • gsl_set_real($z, $x) β€” sets the real part of $z to $x 🌈
  • gsl_set_imag($z, $y) β€” sets the imaginary part of $z to $y πŸ’–
  • gsl_set_complex($z, $x, $h) β€” sets the real part of $z to $x and the imaginary part to $y πŸŽ€
the way that's SIXTY-FIVE functions. she ate and left no crumbs. πŸ‘‘

🧚 EXAMPLES 🧚

Example one β€” this code defines $z as 6 + 4*i, takes the complex conjugate of that number, then prints it out. πŸ¦‹

my $z = gsl_complex_rect(6,4);
my $y = gsl_complex_conjugate($z);
my ($real, $imag) = gsl_parts($y);
print "z = $real + $imag*i\n";

Example two β€” this code defines $z as 5 + 3*i, multiplies it by 2 and then prints it out. πŸ’…

my $x = gsl_complex_rect(5,3);
my $z = gsl_complex_mul_real($x, 2);
my $real = gsl_real($z);
my $imag = gsl_imag($z);
print "Re(\$z) = $real\n";

πŸ’œ AUTHORS πŸ’œ

Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com> β€” the duo, the icons, the moment. 🌟


Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. 🫢


okay that's the whole page bestie, no cap. this was Math::...omplex(3pm) from the User Contributed Perl Documentation, running on perl v5.42.3, dated 2026-08-20 β€” so go forth and make some complex numbers, main character. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from