Skip to main content
provide custom `arctan` instead of relying on built-in `arctan` function
Source Link
Kai Burghardt
  • 1.1k
  • 1
  • 6
  • 13

Pascal, ≥ 162162 194 bytes

“Extended Pascal” (ISO standard 10206) defines that complex numbers are part of the language. When calling one of these functions, a real argument is automatically promoted to a complex value (because the formal parameter list says the function requires a complex number).

functionconst i=cmplx(0,1);type r=complex;function s(x:complexr):complex;beginr;begin s:=cmplx=−i*ln(0,−1sqrt(1−x*x)*ln+i*x);end;function c(x:r):r;begin c:=−i*ln(sqrt(1−x*xx*x−1)+cmplx+x);end;function t(0,1x:r)*x:r;begin t:=i/2*ln((1−i*x)end/(1+i*x));end

Ungolfed:

    const
        i = cmplx(0, 1);
    
    function arcsin(protected x: complex): complex;
        begin
            arcsin := cmplx(0, −1)−i * ln(sqrt(1 − sqr(x)) + cmplx(0, 1)i * x);
        end;
     
    function carccos(protected x: complex):complex;begin ccomplex;
        begin
            arccos :=cmplx(0,−1)*ln= −i * ln(sqrt(x*x−1sqr(x)+x − 1)end + x);
         end;
    
    function arccosarctan(protected x: complex): complex;
        begin
            arccosarctan := cmplx(0,i −1)/ 2 * ln(sqrt(sqr(1 − i * x) / (1) + i * x));
        end;

Arc tangent is actually already part of the language. Both in ISO standard 7185 (built“Standard Pascal”) and ISO standard 10206 (“Extended Pascal”) the built-in function arctan) is available. Since complex numbers are defined by EP, only the latter accepts and can return complex values.

arctan(x)

Pascal, ≥ 162 bytes

“Extended Pascal” (ISO standard 10206) defines that complex numbers are part of the language.

function s(x:complex):complex;begin s:=cmplx(0,−1)*ln(sqrt(1−x*x)+cmplx(0,1)*x)end
    function arcsin(protected x: complex): complex;
        begin
            arcsin := cmplx(0, −1) * ln(sqrt(1 − sqr(x)) + cmplx(0, 1) * x);
        end;
 function c(x:complex):complex;begin c:=cmplx(0,−1)*ln(sqrt(x*x−1)+x)end
     function arccos(protected x: complex): complex;
        begin
            arccos := cmplx(0, −1) * ln(sqrt(sqr(x)  1) + x);
        end;

Arc tangent is already part of the language (built-in function arctan).

arctan(x)

Pascal, 162 194 bytes

“Extended Pascal” (ISO standard 10206) defines that complex numbers are part of the language. When calling one of these functions, a real argument is automatically promoted to a complex value (because the formal parameter list says the function requires a complex number).

const i=cmplx(0,1);type r=complex;function s(x:r):r;begin s:=−i*ln(sqrt(1−x*x)+i*x);end;function c(x:r):r;begin c:=−i*ln(sqrt(x*x−1)+x);end;function t(x:r):r;begin t:=i/2*ln((1−i*x)/(1+i*x));end

Ungolfed:

    const
        i = cmplx(0, 1);
    
    function arcsin(protected x: complex): complex;
        begin
            arcsin := −i * ln(sqrt(1 − sqr(x)) + i * x);
        end;
    
    function arccos(protected x: complex): complex;
        begin
            arccos := −i * ln(sqrt(sqr(x) − 1) + x);
        end;
    
    function arctan(protected x: complex): complex;
        begin
            arctan := i / 2 * ln((1 − i * x) / (1 + i * x));
        end;

Arc tangent is actually already part of the language. Both in ISO standard 7185 (“Standard Pascal”) and ISO standard 10206 (“Extended Pascal”) the built-in function arctan is available. Since complex numbers are defined by EP, only the latter accepts and can return complex values.

Source Link
Kai Burghardt
  • 1.1k
  • 1
  • 6
  • 13

Pascal, ≥ 162 bytes

“Extended Pascal” (ISO standard 10206) defines that complex numbers are part of the language.

function s(x:complex):complex;begin s:=cmplx(0,−1)*ln(sqrt(1−x*x)+cmplx(0,1)*x)end
    function arcsin(protected x: complex): complex;
        begin
            arcsin := cmplx(0, −1) * ln(sqrt(1 − sqr(x)) + cmplx(0, 1) * x);
        end;
function c(x:complex):complex;begin c:=cmplx(0,−1)*ln(sqrt(x*x−1)+x)end
    function arccos(protected x: complex): complex;
        begin
            arccos := cmplx(0, −1) * ln(sqrt(sqr(x) − 1) + x);
        end;

Arc tangent is already part of the language (built-in function arctan).

arctan(x)