'("complex.txt" loaded)

i == .. '(complex :: 0 re 1 im)
j == (prop°'complex,'::,(prop°[0],'re,(prop°[1],'im,(),),),)°ee  // complex value

iscomplex == id is 'complex  // vollständig?

re == .. #re
im == .. #im

half == [half] fn 0.5
conj == [conj] fn fail
phase == [phase] fn fail  // statt arg
root == [root] op [1]^1/[0]
// cot  == [cot] fn cos / sin
// coth == [coth] fn cosh / sinh
// arccot == [arccot] fn fail
// arcoth == [arcoth] fn fail

// Funktionen nachschauen!
// artanh == [artanh] fn 0.5*ln°(1+id)/1-id
arcoth == [arcoth] fn 0.5*ln°(id+1)/id-1
arsech == [arsech] fn ln°(1+sqrt°1-sq)/id  // WP
arcsch == [arcsch] fn ln°(1+sqrt°1+sq)/id  // WP
// cart == isobj -> ([cart] fn ...) ; (...)°ee ? // fromcart?
// polar == isobj -> ([polar] fn ...) ; (...)°ee ? // frompolar?

// ------- class for complex numbers -------
// ([0] is 'complex) and ...) nötig?

// fails spezifizieren
complex  == .. { dict
   [add] == ([1] is 'complex)-> (((re°[0])+re°[1]) j (im°[0])+im°[1]);
            '[add] error '"complex objects expected.",id,
   [sub] == ([1] is 'complex)-> (((re°[0])-re°[1]) j (im°[0])-im°[1]);
            '[sub] error '"complex objects expected.",id,
   [mul] == ([1] is 'complex)-> ((((re°[0])*re°[1])-(im°[0])*im°[1])
                                j ((re°[0])*im°[1])+(im°[0])*re°[1]);
            '[mul] error '"complex objects expected.",id,
   [div] == ([1] is 'complex)->
              (((iszero°[2]) -> ('[div] error '"division by zero",([0],[1],),)
              ; ((((re°[0])*re°[1])+(im°[0])*im°[1])/[2])
                j (((im°[0])*re°[1])-(im°[1])*re°[0])/[2] )
              °[0],[1],((sq°re°[1])+sq°im°[1]),);
            '[div] error '"complex objects expected.",id,
   [round] == round°re  // provisorium
   [float] == float°re  // provisorium
   [zero] == .. '(complex :: 0 re 0 im)
   [one]  == .. '(complex :: 1 re 0 im)
   [half] == .. '(complex :: 0.5 re 0 im)
   [iszero] == (iszero°re) and (iszero°im)
   [isnum] == 'true
   [eq]  == ([1] is 'complex) -> (((re°[0])=re°[1]) and ((im°[0])=im°[1])) ; fail
   [conj] == re j neg°im
   [neg] == (neg°re) j neg°im                   // iscomplex nötig?
   [abs] == sqrt°(sq°re)+sq°im
   [phase] == im arctan2 re  // statt arg
   [sq] == id*id
   [exp] == (([0]*cos°[1]) j [0]*sin°[1])°(exp°re) ee im
         // ((exp°re)*cos°im) j (exp°re)*sin°im  // korrekt? ,exp doppelt
   [ln] == (ln°abs) j im arctan2 re  // Hauptzweig ,phase ,2pik auch?
   [lg] == ln / ln°(10 j 0)
   [ld] == ln / ln°(2 j 0)
   [pow] == ([1] is 'complex) -> (((abs°[0])<1E_161)->((iszero°[1])->(1 j 0);(0 j 0));exp°[1]*ln°[0]) ; fail // Probleme... oder Fehler?  Pi? Hauptzweig?
   [root] == ([1] is 'complex) -> (((abs°[1])<1E_161)->(0 j 0);exp°(ln°[1])/[0]) ; fail // 2pik auch? ,null-Probleme testen!
   [sqrt] == (abs<1E_161) -> zero ; exp°half*ln
   [sin] == ((exp - exp°neg) / i+i)°i*id
   [cos] == (half*(exp + exp°neg))°i*id
   [tan] == sin / cos
   [cot] == cos / sin
   [sec] == one / cos
   [csc] == one / sin
   [arcsin] == (neg°i)*ln°(i*id)+sqrt°one - sq
   [arccos] == (neg°i)*ln°id+sqrt°sq - one  // (neg°i)*ln°id+i*sqrt°(1 j 0) - sq // ((0.5*pi) j 0) - arcsin
   [arctan] == ((ln°(one+id)/one-id) / i+i)°i*id
   [arccot] == (neg°(ln°(id+one)/id - one) / i+i)°i*id // ((0.5*pi) j 0) - arctan
   [arcsec] == arccos°one/id  // WP
   [arccsc] == arcsin°one/id  // WP
   [sinh] == half*(exp - exp°neg)  //   (neg°i)*sin°i*id
   [cosh] == half*(exp + exp°neg)  //   cos°i*id
   [tanh] == sinh / cosh  //   (exp - exp°neg)/(exp + exp°neg)
   [coth] == cosh / sinh  //   (exp + exp°neg)/(exp - exp°neg)
   [sech] == one / cosh   //   (2 j 0)/(exp+exp°neg)
   [csch] == one / sinh   //   (2 j 0)/(exp-exp°neg)
   [arsinh] == ln°id+sqrt°sq + one
   [arcosh] == ln°id+sqrt°sq - one
   [artanh] == half*ln°(one+id)/one-id
   [arcoth] == half*ln°(id+one)/id-one
   [arsech] == ln°(one+sqrt°one-sq)/id  // WP
   [arcsch] == ln°(one+sqrt°one+sq)/id  // WP
// [cart] ==
// [polar] ==
   }

// komplex expp mit Reihe probiert
poti == [2]°((ispos°[1])->*[0],(pred°[1]),([0]*[2]),)°([0],(float°round°[1]),(1 j 0),)°ee
fact == (* \) ° '1,iota
expp == [2]°((ispos°[0])->*(pred°[0]),[1],([2]+([1]poti[0])/(fact°[0]) j 0),)°30,id,(1 j 0),


// GNU Lesser General Public License v2.1
