# Difference between revisions of "complex number"

From Lazarus wiki

m (Fixed template loop) |
m (Change page template and remove categories (defined in the template)) |
||

Line 1: | Line 1: | ||

− | {{ | + | {{omplex_number}} |

Complex numbers is a mathematical concept providing solutions to equations such as <math>x^2 = -1</math>. | Complex numbers is a mathematical concept providing solutions to equations such as <math>x^2 = -1</math>. | ||

Line 37: | Line 37: | ||

* [https://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/release_3_0_4/packages/rtl-extra/src/inc/ucomplex.pp?view=markup <tt>packages/rtl-extra/src/inc/ucomplex.pp</tt> source code] | * [https://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/release_3_0_4/packages/rtl-extra/src/inc/ucomplex.pp?view=markup <tt>packages/rtl-extra/src/inc/ucomplex.pp</tt> source code] | ||

* [https://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/release_3_0_4/packages/numlib/src/typ.pas?view=markup#l134 <tt>packages/numlib/src/typ.pas</tt> source code] | * [https://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/release_3_0_4/packages/numlib/src/typ.pas?view=markup#l134 <tt>packages/numlib/src/typ.pas</tt> source code] | ||

− | |||

− | |||

− |

## Revision as of 21:13, 2 May 2020

Complex numbers is a mathematical concept providing solutions to equations such as [math]x^2 = -1[/math].
In FPC's default runtime library the unit `uComplex`

defines a type `complex`

and lots of operator and other functions.
`u`

in `uComplex`

stands for the Greek letter μ, meaning “micro”, as the implementation is kept as simple as possible.

In extended Pascal, which FPC plans to implement one day, the data type `complex`

is defined as part of the language.

```
program complexDemo(input, output, stderr);
uses
uComplex;
var
x, y: complex;
begin
// specifying real and imaginary part
x := -5 + 2 * i;
// specifying magnitude and phase angle
// y := sqrt(2) * (cos(pi/4) + i * sin(pi/4))
y.re := 1;
y.im := 1;
x := x + y;
// there is no toString functionality:
writeLn('x = ', x.re, ' + ', x.im, 'i');
end.
```

## see also

- DMath, a mathematical library also containing a complex number implementation
- LMath, further development of LMath library, with completer support for complex numbers, where operators over them are defined.
- NumLib documentation, where
`typ.complex`

is an`object`