Recent

Author Topic: Complex numbers in Free Pascal  (Read 9998 times)

dracon

  • New Member
  • *
  • Posts: 18
Complex numbers in Free Pascal
« on: April 26, 2017, 04:38:31 pm »
Hello to all.

Making a google search regarding the title of the topic, I found the following link:

http://free-pascal-general.1045716.n5.nabble.com/What-about-complex-numbers-td4874526.html

Never the less, when I tried to implement the very same program I got an error saying that

Code: Pascal  [Select][+][-]
  1. Compiling dummy.pas
  2. dummy.pas(3,6) Fatal: Can't find unit UCOMPLEX used by DUMMY
  3. Fatal: Compilation aborted
  4. Error: /usr/bin/ppcx64 returned an error exitcode
  5.  

Is there any way to implement complex numbers in free pascal?

thank you.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Complex numbers in Free Pascal
« Reply #1 on: April 26, 2017, 04:50:50 pm »
afaik unit ucomplex is part of rtl-extra and should be there.

Either this unit is not part of 64-bit build (would be odd ?) or your installation is unable to locate the unit.

Compile with -va and post/analyze the result to see if it is the latter case.

PS: since you're on linux, check the filename casing. use "ucomplex" instead.
« Last Edit: April 26, 2017, 04:52:32 pm by molly »

dracon

  • New Member
  • *
  • Posts: 18
Re: Complex numbers in Free Pascal
« Reply #2 on: April 26, 2017, 05:10:19 pm »
....
[0.020] Unitsearch: UCOMPLEX.pp
[0.020] Searching file UCOMPLEX.pp... not found
[0.020] Searching file ucomplex.pp... not found
[0.020] Searching file UCOMPLEX.PP... not found
[0.020] Unitsearch: UCOMPLEX.pas
[0.020] Searching file UCOMPLEX.pas... not found
[0.020] Searching file ucomplex.pas... not found
[0.020] Searching file UCOMPLEX.PAS... not found
[0.020] Unitsearch: /usr/lib/fpc/3.0.2/units/x86_64-linux/rtl/UCOMPLEX.pp
[0.020] Searching file /usr/lib/fpc/3.0.2/units/x86_64-linux/rtl/UCOMPLEX.pp... not found
[0.020] Searching file /usr/lib/fpc/3.0.2/units/x86_64-linux/rtl/ucomplex.pp... not found
[0.020] Searching file /usr/lib/fpc/3.0.2/units/x86_64-linux/rtl/UCOMPLEX.PP... not found
[0.020] Unitsearch: /usr/lib/fpc/3.0.2/units/x86_64-linux/rtl/UCOMPLEX.pas
[0.020] Searching file /usr/lib/fpc/3.0.2/units/x86_64-linux/rtl/UCOMPLEX.pas... not found
[0.020] Searching file /usr/lib/fpc/3.0.2/units/x86_64-linux/rtl/ucomplex.pas... not found
[0.020] Searching file /usr/lib/fpc/3.0.2/units/x86_64-linux/rtl/UCOMPLEX.PAS... not found
[0.020] Unitsearch: /usr/lib64/fpc/3.0.2/UCOMPLEX.pp
[0.020] Searching file /usr/lib64/fpc/3.0.2/UCOMPLEX.pp... not found
[0.020] Searching file /usr/lib64/fpc/3.0.2/ucomplex.pp... not found
[0.020] Searching file /usr/lib64/fpc/3.0.2/UCOMPLEX.PP... not found
[0.020] Unitsearch: /usr/lib64/fpc/3.0.2/UCOMPLEX.pas
[0.020] Searching file /usr/lib64/fpc/3.0.2/UCOMPLEX.pas... not found
[0.020] Searching file /usr/lib64/fpc/3.0.2/ucomplex.pas... not found
[0.020] Searching file /usr/lib64/fpc/3.0.2/UCOMPLEX.PAS... not found
[0.020] test.pas(3,6) Fatal: Can't find unit UCOMPLEX used by DUMMY
[0.023] Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode

dracon

  • New Member
  • *
  • Posts: 18
Re: Complex numbers in Free Pascal
« Reply #3 on: April 26, 2017, 05:11:35 pm »
the case does not solve the problem...

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Complex numbers in Free Pascal
« Reply #4 on: April 26, 2017, 05:18:07 pm »
Looks like there is no rtl-extra installed at all.

Which platform (distribution) and what fpc did you download ? did you use your package manager ti install free pascal ? Some distribution have split up the packages into separate ones which all have to be installed 'manually' by the package installer.

dracon

  • New Member
  • *
  • Posts: 18
Re: Complex numbers in Free Pascal
« Reply #5 on: April 26, 2017, 05:21:16 pm »
I have Solus linux (www.Solus-Project.com) and I have used their package manager (eopkg) to install the latest FP (3.0.2).

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Complex numbers in Free Pascal
« Reply #6 on: April 26, 2017, 05:22:52 pm »
I am not allowed to view that website (forbidde) and have no desire to look up on which distribution it is based.. so on what distribution is that linux based ?

dracon

  • New Member
  • *
  • Posts: 18
Re: Complex numbers in Free Pascal
« Reply #7 on: April 26, 2017, 05:26:08 pm »
It is an independent distro. I have heard that their package manager is a fork of PiSi Linux (turkish distro) -but I am not sure about it.


molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Complex numbers in Free Pascal
« Reply #9 on: April 26, 2017, 05:34:55 pm »
Ah ok. the last posted links help.

rtl-extra is part of the package (and so is unit ucomplex) so should have been installed. That leaves you with wrong path setup, e.g. Free Pascal is unable to locate unit ucomplex because the rtl-extra directory is not part of Free Pascal search path.

look at option -Fu in your file fpc.cfg. Also make sure the correct version of fpc.cfg is loaded/used, especially when you had a previous installation of Free Pascal.

The -va option and the produced log is able to tell you which fpc.cfg was loaded and from which location. It also show you which directories FPC should use to search for (compiled) units.

As your second link showed, (lines 1926/1927) it should be looking for:
Quote
/usr/lib/fpc/3.0.2/units/x86_64-linux/rtl-extra/ucomplex.o
/usr/lib/fpc/3.0.2/units/x86_64-linux/rtl-extra/ucomplex.ppu

edit: that means you should be looking at an entry inside fpc.cfg that matces your setup and afaik should look something like:
Code: [Select]
-Fu/usr/lib/fpc/$FPCVERSION/units/$FPCTARGET/*
« Last Edit: April 26, 2017, 06:00:33 pm by molly »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Complex numbers in Free Pascal
« Reply #10 on: April 26, 2017, 05:53:01 pm »
You could also try the DMath library at https://sourceforge.net/projects/dmath/

It covers much more than just complex numbers. It comes with several example program sources in Pascal, including
one called "complex". The console output is shown below.
Unfortunately the library is not presented as a Lazarus package, so you have to assemble the units needed by hand. However, it would be simple to turn the library into a Lazarus package.

Code: Pascal  [Select][+][-]
  1. Complex number definition/conversion/output:
  2.  
  3.        z rectangular                   z polar
  4.    ----------------------     --------------------------
  5.     0.000 +     0.000 * i     0.000 * Exp(    0.000 * i)
  6.     0.500 +     0.500 * i     0.707 * Exp(    0.785 * i)
  7.    -0.500 +     0.500 * i     0.707 * Exp(    2.356 * i)
  8.    -0.500 -     0.500 * i     0.707 * Exp(   -2.356 * i)
  9.     0.500 -     0.500 * i     0.707 * Exp(   -0.785 * i)
  10.     1.000 +     0.000 * i     1.000 * Exp(    0.000 * i)
  11.     1.000 +     1.000 * i     1.414 * Exp(    0.785 * i)
  12.     0.000 +     1.000 * i     1.000 * Exp(    1.571 * i)
  13.    -1.000 +     1.000 * i     1.414 * Exp(    2.356 * i)
  14.    -1.000 +     0.000 * i     1.000 * Exp(    3.142 * i)
  15.    -1.000 -     1.000 * i     1.414 * Exp(   -2.356 * i)
  16.     0.000 -     1.000 * i     1.000 * Exp(   -1.571 * i)
  17.     1.000 -     1.000 * i     1.414 * Exp(   -0.785 * i)
  18.     5.000 +     0.000 * i     5.000 * Exp(    0.000 * i)
  19.     5.000 +     3.000 * i     5.831 * Exp(    0.540 * i)
  20.     0.000 +     3.000 * i     3.000 * Exp(    1.571 * i)
  21.    -5.000 +     3.000 * i     5.831 * Exp(    2.601 * i)
  22.    -5.000 +     0.000 * i     5.000 * Exp(    3.142 * i)
  23.     5.000 -     3.000 * i     5.831 * Exp(   -0.540 * i)
  24.     0.000 -     3.000 * i     3.000 * Exp(   -1.571 * i)
  25.  
  26. Press <Enter> to continue
  27.  
  28. Complex arithmetic: +, -, *, /, ^
  29.  
  30.   Let z1  =     1.000 +     1.000 * i
  31.       z2  =     1.732 -     1.000 * i
  32.  
  33.   z1 + z2 =     2.732 +     0.000 * i
  34.   z1 - z2 =    -0.732 +     2.000 * i
  35.   z1 * z2 =     2.732 +     0.732 * i
  36.   z1 / z2 =     0.183 +     0.683 * i
  37.   z1 ^ z2 =     2.113 +     3.393 * i
  38.  
  39. Press <Enter> to continue
  40.  
  41.              z                          Ln(z)                  Exp(Ln(z))    
  42.   -------------------------   -----------------------   -----------------------
  43.  1    0.000 +     0.000 * i           undefined
  44.  2    0.500 +     0.500 * i    -0.347 +     0.785 * i     0.500 +     0.500 * i
  45.  3   -0.500 +     0.500 * i    -0.347 +     2.356 * i    -0.500 +     0.500 * i
  46.  4   -0.500 -     0.500 * i    -0.347 -     2.356 * i    -0.500 -     0.500 * i
  47.  5    0.500 -     0.500 * i    -0.347 -     0.785 * i     0.500 -     0.500 * i
  48.  6    1.000 +     0.000 * i     0.000 +     0.000 * i     1.000 +     0.000 * i
  49.  7    1.000 +     1.000 * i     0.347 +     0.785 * i     1.000 +     1.000 * i
  50.  8    0.000 +     1.000 * i     0.000 +     1.571 * i     0.000 +     1.000 * i
  51.  9   -1.000 +     1.000 * i     0.347 +     2.356 * i    -1.000 +     1.000 * i
  52. 10   -1.000 +     0.000 * i     0.000 +     3.142 * i    -1.000 +     0.000 * i
  53. 11   -1.000 -     1.000 * i     0.347 -     2.356 * i    -1.000 -     1.000 * i
  54. 12    0.000 -     1.000 * i     0.000 -     1.571 * i     0.000 -     1.000 * i
  55. 13    1.000 -     1.000 * i     0.347 -     0.785 * i     1.000 -     1.000 * i
  56. 14    5.000 +     0.000 * i     1.609 +     0.000 * i     5.000 +     0.000 * i
  57. 15    5.000 +     3.000 * i     1.763 +     0.540 * i     5.000 +     3.000 * i
  58. 16    0.000 +     3.000 * i     1.099 +     1.571 * i     0.000 +     3.000 * i
  59. 17   -5.000 +     3.000 * i     1.763 +     2.601 * i    -5.000 +     3.000 * i
  60. 18   -5.000 +     0.000 * i     1.609 +     3.142 * i    -5.000 +     0.000 * i
  61. 19    5.000 -     3.000 * i     1.763 -     0.540 * i     5.000 -     3.000 * i
  62. 20    0.000 -     3.000 * i     1.099 -     1.571 * i     0.000 -     3.000 * i
  63.  
  64. Press <Enter> to continue
  65.  
  66.              z                        ArcSin(z)              Sin(ArcSin(z))  
  67.   -------------------------   -----------------------   -----------------------
  68.  1    0.000 +     0.000 * i     0.000 +     0.000 * i     0.000 +     0.000 * i
  69.  2    0.500 +     0.500 * i     0.452 +     0.531 * i     0.500 +     0.500 * i
  70.  3   -0.500 +     0.500 * i    -0.452 +     0.531 * i    -0.500 +     0.500 * i
  71.  4   -0.500 -     0.500 * i    -0.452 -     0.531 * i    -0.500 -     0.500 * i
  72.  5    0.500 -     0.500 * i     0.452 -     0.531 * i     0.500 -     0.500 * i
  73.  6    1.000 +     0.000 * i     1.571 +     0.000 * i     1.000 +     0.000 * i
  74.  7    1.000 +     1.000 * i     0.666 +     1.061 * i     1.000 +     1.000 * i
  75.  8    0.000 +     1.000 * i     0.000 +     0.881 * i     0.000 +     1.000 * i
  76.  9   -1.000 +     1.000 * i    -0.666 +     1.061 * i    -1.000 +     1.000 * i
  77. 10   -1.000 +     0.000 * i    -1.571 +     0.000 * i    -1.000 +     0.000 * i
  78. 11   -1.000 -     1.000 * i    -0.666 -     1.061 * i    -1.000 -     1.000 * i
  79. 12    0.000 -     1.000 * i     0.000 -     0.881 * i     0.000 -     1.000 * i
  80. 13    1.000 -     1.000 * i     0.666 -     1.061 * i     1.000 -     1.000 * i
  81. 14    5.000 +     0.000 * i     1.571 -     2.292 * i     5.000 -     0.000 * i
  82. 15    5.000 +     3.000 * i     1.024 +     2.453 * i     5.000 +     3.000 * i
  83. 16    0.000 +     3.000 * i     0.000 +     1.818 * i     0.000 +     3.000 * i
  84. 17   -5.000 +     3.000 * i    -1.024 +     2.453 * i    -5.000 +     3.000 * i
  85. 18   -5.000 +     0.000 * i    -1.571 +     2.292 * i    -5.000 +     0.000 * i
  86. 19    5.000 -     3.000 * i     1.024 -     2.453 * i     5.000 -     3.000 * i
  87. 20    0.000 -     3.000 * i     0.000 -     1.818 * i     0.000 -     3.000 * i
  88.  
  89. Press <Enter> to continue
  90.  
  91.              z                        ArcCos(z)              Cos(ArcCos(z))  
  92.   -------------------------   -----------------------   -----------------------
  93.  1    0.000 +     0.000 * i     1.571 +     0.000 * i     0.000 +     0.000 * i
  94.  2    0.500 +     0.500 * i     1.119 -     0.531 * i     0.500 +     0.500 * i
  95.  3   -0.500 +     0.500 * i     2.023 -     0.531 * i    -0.500 +     0.500 * i
  96.  4   -0.500 -     0.500 * i     2.023 +     0.531 * i    -0.500 -     0.500 * i
  97.  5    0.500 -     0.500 * i     1.119 +     0.531 * i     0.500 -     0.500 * i
  98.  6    1.000 +     0.000 * i     0.000 +     0.000 * i     1.000 +     0.000 * i
  99.  7    1.000 +     1.000 * i     0.905 -     1.061 * i     1.000 +     1.000 * i
  100.  8    0.000 +     1.000 * i     1.571 -     0.881 * i     0.000 +     1.000 * i
  101.  9   -1.000 +     1.000 * i     2.237 -     1.061 * i    -1.000 +     1.000 * i
  102. 10   -1.000 +     0.000 * i     3.142 +     0.000 * i    -1.000 +     0.000 * i
  103. 11   -1.000 -     1.000 * i     2.237 +     1.061 * i    -1.000 -     1.000 * i
  104. 12    0.000 -     1.000 * i     1.571 +     0.881 * i     0.000 -     1.000 * i
  105. 13    1.000 -     1.000 * i     0.905 +     1.061 * i     1.000 -     1.000 * i
  106. 14    5.000 +     0.000 * i     0.000 +     2.292 * i     5.000 -     0.000 * i
  107. 15    5.000 +     3.000 * i     0.547 -     2.453 * i     5.000 +     3.000 * i
  108. 16    0.000 +     3.000 * i     1.571 -     1.818 * i     0.000 +     3.000 * i
  109. 17   -5.000 +     3.000 * i     2.595 -     2.453 * i    -5.000 +     3.000 * i
  110. 18   -5.000 +     0.000 * i     3.142 -     2.292 * i    -5.000 +     0.000 * i
  111. 19    5.000 -     3.000 * i     0.547 +     2.453 * i     5.000 -     3.000 * i
  112. 20    0.000 -     3.000 * i     1.571 +     1.818 * i     0.000 -     3.000 * i
  113.  
  114. Press <Enter> to continue
  115.  
  116.              z                        ArcTan(z)              Tan(ArcTan(z))  
  117.   -------------------------   -----------------------   -----------------------
  118.  1    0.000 +     0.000 * i     0.000 +     0.000 * i     0.000 +     0.000 * i
  119.  2    0.500 +     0.500 * i     0.554 +     0.402 * i     0.500 +     0.500 * i
  120.  3   -0.500 +     0.500 * i    -0.554 +     0.402 * i    -0.500 +     0.500 * i
  121.  4   -0.500 -     0.500 * i    -0.554 -     0.402 * i    -0.500 -     0.500 * i
  122.  5    0.500 -     0.500 * i     0.554 -     0.402 * i     0.500 -     0.500 * i
  123.  6    1.000 +     0.000 * i     0.785 +     0.000 * i     1.000 +     0.000 * i
  124.  7    1.000 +     1.000 * i     1.017 +     0.402 * i     1.000 +     1.000 * i
  125.  8    0.000 +     1.000 * i           undefined
  126.  9   -1.000 +     1.000 * i    -1.017 +     0.402 * i    -1.000 +     1.000 * i
  127. 10   -1.000 +     0.000 * i    -0.785 +     0.000 * i    -1.000 +     0.000 * i
  128. 11   -1.000 -     1.000 * i    -1.017 -     0.402 * i    -1.000 -     1.000 * i
  129. 12    0.000 -     1.000 * i           undefined
  130. 13    1.000 -     1.000 * i     1.017 -     0.402 * i     1.000 -     1.000 * i
  131. 14    5.000 +     0.000 * i     1.373 +     0.000 * i     5.000 +     0.000 * i
  132. 15    5.000 +     3.000 * i     1.424 +     0.087 * i     5.000 +     3.000 * i
  133. 16    0.000 +     3.000 * i     1.571 +     0.347 * i     0.000 +     3.000 * i
  134. 17   -5.000 +     3.000 * i    -1.424 +     0.087 * i    -5.000 +     3.000 * i
  135. 18   -5.000 +     0.000 * i    -1.373 +     0.000 * i    -5.000 +     0.000 * i
  136. 19    5.000 -     3.000 * i     1.424 -     0.087 * i     5.000 -     3.000 * i
  137. 20    0.000 -     3.000 * i    -1.571 -     0.347 * i    -0.000 -     3.000 * i
  138.  
  139. Press <Enter> to continue
  140.  
  141.              z                        ArcSinh(z)            Sinh(ArcSinh(z))
  142.   -------------------------   -----------------------   -----------------------
  143.  1    0.000 +     0.000 * i     0.000 +     0.000 * i     0.000 +     0.000 * i
  144.  2    0.500 +     0.500 * i     0.531 +     0.452 * i     0.500 +     0.500 * i
  145.  3   -0.500 +     0.500 * i    -0.531 +     0.452 * i    -0.500 +     0.500 * i
  146.  4   -0.500 -     0.500 * i    -0.531 -     0.452 * i    -0.500 -     0.500 * i
  147.  5    0.500 -     0.500 * i     0.531 -     0.452 * i     0.500 -     0.500 * i
  148.  6    1.000 +     0.000 * i     0.881 +     0.000 * i     1.000 +     0.000 * i
  149.  7    1.000 +     1.000 * i     1.061 +     0.666 * i     1.000 +     1.000 * i
  150.  8    0.000 +     1.000 * i     0.000 +     1.571 * i     0.000 +     1.000 * i
  151.  9   -1.000 +     1.000 * i    -1.061 +     0.666 * i    -1.000 +     1.000 * i
  152. 10   -1.000 +     0.000 * i    -0.881 +     0.000 * i    -1.000 +     0.000 * i
  153. 11   -1.000 -     1.000 * i    -1.061 -     0.666 * i    -1.000 -     1.000 * i
  154. 12    0.000 -     1.000 * i    -0.000 -     1.571 * i     0.000 -     1.000 * i
  155. 13    1.000 -     1.000 * i     1.061 -     0.666 * i     1.000 -     1.000 * i
  156. 14    5.000 +     0.000 * i     2.312 +     0.000 * i     5.000 +     0.000 * i
  157. 15    5.000 +     3.000 * i     2.460 +     0.534 * i     5.000 +     3.000 * i
  158. 16    0.000 +     3.000 * i     1.763 +     1.571 * i     0.000 +     3.000 * i
  159. 17   -5.000 +     3.000 * i    -2.460 +     0.534 * i    -5.000 +     3.000 * i
  160. 18   -5.000 +     0.000 * i    -2.312 +     0.000 * i    -5.000 +     0.000 * i
  161. 19    5.000 -     3.000 * i     2.460 -     0.534 * i     5.000 -     3.000 * i
  162. 20    0.000 -     3.000 * i    -1.763 -     1.571 * i    -0.000 -     3.000 * i
  163.  
  164. Press <Enter> to continue
  165.  
  166.              z                        ArcCosh(z)            Cosh(ArcCosh(z))
  167.   -------------------------   -----------------------   -----------------------
  168.  1    0.000 +     0.000 * i     0.000 +     1.571 * i     0.000 +     0.000 * i
  169.  2    0.500 +     0.500 * i     0.531 +     1.119 * i     0.500 +     0.500 * i
  170.  3   -0.500 +     0.500 * i     0.531 +     2.023 * i    -0.500 +     0.500 * i
  171.  4   -0.500 -     0.500 * i     0.531 -     2.023 * i    -0.500 -     0.500 * i
  172.  5    0.500 -     0.500 * i     0.531 -     1.119 * i     0.500 -     0.500 * i
  173.  6    1.000 +     0.000 * i    -0.000 +     0.000 * i     1.000 +     0.000 * i
  174.  7    1.000 +     1.000 * i     1.061 +     0.905 * i     1.000 +     1.000 * i
  175.  8    0.000 +     1.000 * i     0.881 +     1.571 * i     0.000 +     1.000 * i
  176.  9   -1.000 +     1.000 * i     1.061 +     2.237 * i    -1.000 +     1.000 * i
  177. 10   -1.000 +     0.000 * i     0.000 +     3.142 * i    -1.000 +     0.000 * i
  178. 11   -1.000 -     1.000 * i     1.061 -     2.237 * i    -1.000 -     1.000 * i
  179. 12    0.000 -     1.000 * i     0.881 -     1.571 * i     0.000 -     1.000 * i
  180. 13    1.000 -     1.000 * i     1.061 -     0.905 * i     1.000 -     1.000 * i
  181. 14    5.000 +     0.000 * i     2.292 -     0.000 * i     5.000 -     0.000 * i
  182. 15    5.000 +     3.000 * i     2.453 +     0.547 * i     5.000 +     3.000 * i
  183. 16    0.000 +     3.000 * i     1.818 +     1.571 * i     0.000 +     3.000 * i
  184. 17   -5.000 +     3.000 * i     2.453 +     2.595 * i    -5.000 +     3.000 * i
  185. 18   -5.000 +     0.000 * i     2.292 +     3.142 * i    -5.000 +     0.000 * i
  186. 19    5.000 -     3.000 * i     2.453 -     0.547 * i     5.000 -     3.000 * i
  187. 20    0.000 -     3.000 * i     1.818 -     1.571 * i     0.000 -     3.000 * i
  188.  
  189. Press <Enter> to continue
  190.  
  191.              z                        ArcTanh(z)            Tanh(ArcTanh(z))
  192.   -------------------------   -----------------------   -----------------------
  193.  1    0.000 +     0.000 * i     0.000 +     0.000 * i     0.000 +     0.000 * i
  194.  2    0.500 +     0.500 * i     0.402 +     0.554 * i     0.500 +     0.500 * i
  195.  3   -0.500 +     0.500 * i    -0.402 +     0.554 * i    -0.500 +     0.500 * i
  196.  4   -0.500 -     0.500 * i    -0.402 -     0.554 * i    -0.500 -     0.500 * i
  197.  5    0.500 -     0.500 * i     0.402 -     0.554 * i     0.500 -     0.500 * i
  198.  6    1.000 +     0.000 * i           undefined
  199.  7    1.000 +     1.000 * i     0.402 +     1.017 * i     1.000 +     1.000 * i
  200.  8    0.000 +     1.000 * i     0.000 +     0.785 * i     0.000 +     1.000 * i
  201.  9   -1.000 +     1.000 * i    -0.402 +     1.017 * i    -1.000 +     1.000 * i
  202. 10   -1.000 +     0.000 * i           undefined
  203. 11   -1.000 -     1.000 * i    -0.402 -     1.017 * i    -1.000 -     1.000 * i
  204. 12    0.000 -     1.000 * i     0.000 -     0.785 * i     0.000 -     1.000 * i
  205. 13    1.000 -     1.000 * i     0.402 -     1.017 * i     1.000 -     1.000 * i
  206. 14    5.000 +     0.000 * i     0.203 -     1.571 * i     5.000 -     0.000 * i
  207. 15    5.000 +     3.000 * i     0.147 +     1.481 * i     5.000 +     3.000 * i
  208. 16    0.000 +     3.000 * i     0.000 +     1.249 * i     0.000 +     3.000 * i
  209. 17   -5.000 +     3.000 * i    -0.147 +     1.481 * i    -5.000 +     3.000 * i
  210. 18   -5.000 +     0.000 * i    -0.203 +     1.571 * i    -5.000 +     0.000 * i
  211. 19    5.000 -     3.000 * i     0.147 -     1.481 * i     5.000 -     3.000 * i
  212. 20    0.000 -     3.000 * i     0.000 -     1.249 * i     0.000 -     3.000 * i
  213.  
  214. Press <Enter> to continue
  215.  
  216.              z                     z^c, c=0.5+0.5*i           (z^c)^(1/c)    
  217.   -------------------------   -----------------------   -----------------------
  218.  1    0.000 +     0.000 * i     0.000 +     0.000 * i     0.000 +     0.000 * i
  219.  2    0.500 +     0.500 * i     0.554 +     0.124 * i     0.500 +     0.500 * i
  220.  3   -0.500 +     0.500 * i     0.139 +     0.219 * i    -0.500 +     0.500 * i
  221.  4   -0.500 -     0.500 * i     0.595 -     2.666 * i    -0.500 -     0.500 * i
  222.  5    0.500 -     0.500 * i     1.051 -     0.668 * i     0.500 -     0.500 * i
  223.  6    1.000 +     0.000 * i     1.000 +     0.000 * i     1.000 +     0.000 * i
  224.  7    1.000 +     1.000 * i     0.678 +     0.431 * i     1.000 +     1.000 * i
  225.  8    0.000 +     1.000 * i     0.322 +     0.322 * i     0.000 +     1.000 * i
  226.  9   -1.000 +     1.000 * i     0.080 +     0.357 * i    -1.000 +     1.000 * i
  227. 10   -1.000 +     0.000 * i     0.000 +     0.208 * i    -1.000 +     0.000 * i
  228. 11   -1.000 -     1.000 * i     2.071 -     3.260 * i    -1.000 -     1.000 * i
  229. 12    0.000 -     1.000 * i     1.551 -     1.551 * i     0.000 -     1.000 * i
  230. 13    1.000 -     1.000 * i     1.719 -     0.383 * i     1.000 -     1.000 * i
  231. 14    5.000 +     0.000 * i     1.550 +     1.611 * i     5.000 -     0.000 * i
  232. 15    5.000 +     3.000 * i     0.750 +     1.684 * i     5.000 +     3.000 * i
  233. 16    0.000 +     3.000 * i     0.185 +     0.768 * i    -0.000 +     3.000 * i
  234. 17   -5.000 +     3.000 * i    -0.378 +     0.539 * i    -5.000 +     3.000 * i
  235. 18   -5.000 +     0.000 * i    -0.335 +     0.322 * i    -5.000 +     0.000 * i
  236. 19    5.000 -     3.000 * i     2.591 +     1.816 * i     5.000 -     3.000 * i
  237. 20    0.000 -     3.000 * i     3.693 -     0.889 * i     0.000 -     3.000 * i
  238.  
  239. Press <Enter> to continue
  240.  
  241.              z                        Ln(Gamma(z))              Gamma(z)    
  242.   -------------------------   -----------------------   -----------------------
  243.  1    0.000 +     0.000 * i           undefined
  244.  2    0.500 +     0.500 * i     0.112 -     0.751 * i     0.818 -     0.763 * i
  245.  3   -0.500 +     0.500 * i     0.459 -     3.107 * i    -1.581 -     0.055 * i
  246.  4   -0.500 -     0.500 * i     0.459 +     3.107 * i    -1.581 +     0.055 * i
  247.  5    0.500 -     0.500 * i     0.112 +     0.751 * i     0.818 +     0.763 * i
  248.  6    1.000 +     0.000 * i     0.000 +     0.000 * i     1.000 +     0.000 * i
  249.  7    1.000 +     1.000 * i    -0.651 -     0.302 * i     0.498 -     0.155 * i
  250.  8    0.000 +     1.000 * i    -0.651 -     1.872 * i    -0.155 -     0.498 * i
  251.  9   -1.000 +     1.000 * i    -0.997 -     4.229 * i    -0.172 +     0.326 * i
  252. 10   -1.000 +     0.000 * i           undefined
  253. 11   -1.000 -     1.000 * i    -0.997 +     4.229 * i    -0.172 -     0.326 * i
  254. 12    0.000 -     1.000 * i    -0.651 +     1.872 * i    -0.155 +     0.498 * i
  255. 13    1.000 -     1.000 * i    -0.651 +     0.302 * i     0.498 +     0.155 * i
  256. 14    5.000 +     0.000 * i     3.178 +     0.000 * i    24.000 +     0.000 * i
  257. 15    5.000 +     3.000 * i     2.244 +     4.714 * i     0.016 -     9.433 * i
  258. 16    0.000 +     3.000 * i    -4.343 -     0.517 * i     0.011 -     0.006 * i
  259. 17   -5.000 +     3.000 * i   -11.594 -    12.024 * i     0.000 +     0.000 * i
  260. 18   -5.000 +     0.000 * i           undefined
  261. 19    5.000 -     3.000 * i     2.244 -     4.714 * i     0.016 +     9.433 * i
  262. 20    0.000 -     3.000 * i    -4.343 +     0.517 * i     0.011 +     0.006 * i
  263.  
  264. Press <Enter> to continue
  265.  
  266. The 3 cube roots of (-1+i)
  267.  
  268.             z                         z^(1/3)                  [z^(1/3)]^3  
  269.      ----------------------    ----------------------    ----------------------
  270.  0   -1.000 +     1.000 * i     0.794 +     0.794 * i    -1.000 +     1.000 * i
  271.  1   -1.000 +     1.000 * i    -1.084 +     0.291 * i    -1.000 +     1.000 * i
  272.  2   -1.000 +     1.000 * i     0.291 -     1.084 * i    -1.000 +     1.000 * i
  273.  
  274. Press <Enter> to continue
  275.  
  276. Heap dump by heaptrc unit
  277. 1740 memory blocks allocated : 68540/78880
  278. 1740 memory blocks freed     : 68540/78880
  279. 0 unfreed memory blocks : 0
  280. True heap size : 65536
  281. True free heap : 65536

dracon

  • New Member
  • *
  • Posts: 18
Re: Complex numbers in Free Pascal
« Reply #11 on: April 26, 2017, 07:09:24 pm »
That is very interesting... I will give it a try. Never the less it is a same that this is not included in the default FP collection!

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Complex numbers in Free Pascal
« Reply #12 on: April 26, 2017, 07:59:32 pm »
If - for whatever reason - ucomplex is not installed on your system why don't you just copy the unit to your project folder?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Complex numbers in Free Pascal
« Reply #13 on: April 26, 2017, 08:23:12 pm »
That is very interesting... I will give it a try. Never the less it is a same that this is not included in the default FP collection!

The default collection is the .tar installer from the FPC site. And it definitely has rtl-extra.

Distributions make their own packaging decisions, you might want to file a bug report with your distributions (packaging sub project)

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Complex numbers in Free Pascal
« Reply #14 on: April 26, 2017, 08:40:12 pm »
Marco,  how about adding ucomplex to or calling it from NumLib? The type complex in NumLib is not completely implemented and a pain to use. ucomplex is MUCH better.

 

TinyPortal © 2005-2018