Complex variable functions principal and
non-principal solution
; update 2015-03-01
what to do to avoid error?
gamma Γ('1+2i') ; Riemann zeta ζ('2+3i') ; ALERT
symbolic calculator ; function call calculator
complex operation mix with real value function? See here
arc-sin/cos/tan, arc-hyper-sin/cos/tan Operator change.
complex2.htm A B C not compare answer. D use cpowf('1+2i','3+4i')
complex4.htm A B C compare answer with Andreas Greuer answer.
complex4.htm D use ('1+2i')^('3+4i')  
This is NOT DONE.
This file is written under MSIE 9.0   Document   Compare
complex number online reference 01   02   03   04   05
<a name=alertmsg>
This file is personal home work. Output
may contain error. Please verify first.

Liu,Hsinhan did not attempt to improve output number
effective digits. A long number right side digits may be
useless. Reader must verify first. 2014-10-07-20-59

This file has complex function source code.
But can not promise they are all correct.
Below has thirty test button on left column.
[complex01] and [complex02] are input boxes.
[complex output] is output for principal value.
One-to-many function output to Box1. Non-principal
value answer no confirmation. You need to verify
first. 9803220737

Proof +1=-1. if know the mathematics rule leak hole,
then one can "proof"

<a name=testSet1>
Below is complex function for add/subtract/multiply/division etc. non-math operation.

verify input complex1input complex2   function name red has c1,c2
; ; ; + caddf(c1,c2) a203111917
; ; ; - csubf(c1,c2) a203120950
; ; ; * cmulf(c1,c2) a203121003
; ; ; / cdivf(c1,c2) a203121018
; ; ; $ conjf(c1) a203121310
; ; ; Ⓝ cnewf(c1,c2) a203121318
; ; ; | cabsf(c1) a203121329
; ; ; √ csqrt(c1) a203121357
; ; ;  cmulr(c1,c2) a203121410
; ; ; Ⓐ cargf(c1) a203121427
; ; ; ◎ cpolr(c1) a203121553
; ; ; ╚ cxryi(c1) a203121601
; ; ; ⓝ cnegf(c1) a203121625
; ; ; Ⓡ cgetr(c1) a203121634
; ; ; Ⓘ cgeti(c1) a203121638

E= 2.718281828459045 ; PI= 3.141592653589793
1 0 = delete function name, make room for input box. 9804130942
If LiuHH answer is undefined, go here for solution. a209262121
Above is complex function for add/subtract/multiply/division etc. non-math operation.
<a name=testSet2>
Below is complex function, math operation, many-to-one. no need to use +2*n*PI 9803161014
complex01=c1 in function name, complex02=c2 in function name.
cexpf('1+2i')=exp('1+2i') is regular complex exponential function.
cexpi() is not regular e^complex. cexpi() simplify imaginary cexpf('3i') to cexpi(3)
cexpi(3) = cexpf('3i') no need to use "i", no need to use quote. 9805181224
cexpf('1+3i')=cexpi('1+3i')=2.718281828459045^('1+3i') ; cexpf(2)=cexpi('2+0i')
Input 2 to yellow box, cexpi(c1) see 2 as 2i, Greuer code take as 2. answer different.

verify  yellow input complex1input complex2   function name red has c1,c2
; ; ;  cexpi(c1) a203131935
; ; ; Ⓔ cexpf(c1) a203132015
; ; ; Ⓢ csinf(c1) a203132027
; ; ; Ⓒ ccosf(c1) a203132032
; ; ; Ⓣ ctanf(c1) a203132037
; ; ; ⒮ csinh(c1) a203132041
; ; ; ⒞ ccosh(c1) a203132045
; ; ; ⒯ ctanh(c1) a203132048
red ; ; ; @ cdotf(c1,c2) a203132054
Program will convert red box value to complex conjugate.
dot product, complex separated by ';' ONLY. 2013-03-31-18-09.
dot product use 〈u, v_conj〉, 〈u_conj, v〉 answer conjugate to each other.

If LiuHH answer is undefined, change string complex to array complex.
Please uncheck next check box. 2013-09-26-21-00
If answer is real 1, imaginary 2 output array complex 1,2, Good for draw curve.

Above function all not output to box1 below.
Below function all do output to box1 below.
<a name=testSet3>
06/30/1998 08:33 AM 106,496 SUPER_PI.EXE
Below is one-to-many functions, use +2*n*PI n is arbitrary integer. 9803151835
E= 2.718281828459045 ; PI= next line by SUPER_PI.EXE
3.14159265358979323846264338327950288419716939937510 ...
verify  c1^c2 input complex1input complex2   function name red has c1,c2
; ; ; Ⓛ clogf(c1,nBgn,nEnd)
; ; ; ^ cpowf(c1,c2,nB,nE)
; ; ; ㊀ casin(c1,rtsq01,nB,nE)
; ; ; ㊁ cacos(c1,rtsq01,nB,nE)
; ; ; ㊂ catan(c1,rtsq01,nB,nE)
; ; ; ㈠ asinh(c1,rtsq01,nB,nE)
; ; ; ㈡ acosh(c1,rtsq01,nB,nE)
; ; ; ㈢ atanh(c1,rtsq01,nB,nE)
; ; ; Test error on purpose

If LiuHH answer is undefined, go here for solution. a209262121
one-to-many function has +2*n*PI its n range=

Function argument is following
c1 and c2 are given (input) complex numbers.
rtsq01 determine square root take '+' (rtsq01!=1) or take '-' (rtsq01==1)
If omit rtsq01, default take '+' (root01=0)
nBgn,nEnd is n range in 2*n*PI [9803242228]
If omit nBgn,nEnd default n=0 to 0 for principal answer.
If assign nBgn and omit nEnd , return one value for n=nBgn
if assign both nBgn and nEnd , return n=[nBgn,nEnd] solution.
When return value is more than one, programmer need to use
manager function to arrange output for easy reading.
Otherwise ten complex number answer, twenty real/imag
numbers all string together.
This file has manager function, example clogfMan(clArg1)
and all function ...Man()
Box1, answer

Box2, equation doc.



Above complex functions test boxes
below complex number calculator.
below complex4.htm allow input (1+2i)*(3+4i) is NOT true.
complex4.htm allow symbolic equation is written in progress.
Below same as complex2.htm must input cmulf('1+2i','3+4i')
Below still need input function equation. 2013-03-25-23-30

Below has "test box3 command" button, it is in fact 
a small calculator. Alert: complex add/subtract
and multiply/division are all carry out by functions
error (1+2*i)+(3+4*i) , correct caddf('1+2*i','3+4*i')
error (1+2*i)-(3+4*i) , correct csubf('1+2*i','3+4*i')
error (1+2*i)*(3+4*i) , correct cmulf('1+2*i','3+4*i')
error (1+2*i)/(3+4*i) , correct cdivf('1+2*i','3+4*i')
(1+2*i) is error, '1+2*i' is correct. 9803161923

Use search engine search for next string
Operator Overloading In Javascript
This page explain why-not-operator-overloading-in-javascript
For complex number c1,c2 we can not use c3=c1+c2
must use c3=caddf(c1,c2).  

2013-06-19-16-28 add next record
2009-04-10-19-42-48 in google search for
Operator Overloading In Javascript
Results 1 - 20 of 20 for "Operator Overloading In Javascript". (0.21 seconds) 

Why not Operator Overloading in JavaScript? at noumena
Jan 27, 2009 ... A blog about the JavaScript Infovis Toolkit and other stuff. - 22k - Cached - Similar pages
2009-04-10-19-44-36 Liu,Hsinhan access next page
Next two [test box3] see note at docA142
page ans
click to run MSIE 6.0
Box3, JS command /*=*/ stop print; //^ add blank line
 Box6 not accept if,while  Box3 document

Examples ;

Box4, output for Box3   goto box6

zeta max loop

Next lines choose setting. 0=|value| < tiny . Draw curve must have two "Good for".
If answer is real 1, imaginary 2
If answer is real 1, imaginary 0
1.0e-6>=user tiny>1.e-16
If tiny=1.e-13, answer=2.e-14+3.e-14i, output
Box11 debug    
Box12 debug
Box5, debug output ;  

boxd05.value='string' ;

<a name="gammadata">
2015-01-08-21-47 include next Γ(1/2) to Γ(1/5)
2014-12-31-00-41 access
Introduction to the Gamma Function ; Pascal Sebah and Xavier Gourdon
Up to 50 digits, the numerical values of some of those constants are :
Γ(1/2) = 1.77245385090551602729816748334114518279754945612238...
Γ(1/3) = 2.67893853470774763365569294097467764412868937795730...
Γ(1/4) = 3.62560990822190831193068515586767200299516768288006...
Γ(1/5) = 4.59084371199880305320475827592915200343410999829340
Above data can be used to verify complex4.htm Γ(1/2) to Γ(1/5) accuracy.
Gamma function minimum at x0.
x0 = 1.46163214496836234126265954232572132846819620400644...
Γ(x0) = 0.88560319441088870027881590058258873320795153366990...,
it was first computed by Gauss, Legendre .

Above "Box3, JS command" box value, no matter how
many lines, eval(Box3.value) once. If(){...}else{...}
structure cross several lines OK.

Below "Box6, input" box value, each line one evaluation,
that is eval(line.value) once. If(){...}else{...} structure
cross several lines ERROR. a204191521

Below run button use function bye09a()
change 0.99999999999+2.0000000000001i to 1+2i

Above run button
NOT use bye09a(), answer 0.99999999+2.000000001i stay as is.

Complex number calculator accept + - * /
Program environment:Window 7; MSIE 9.0.8112.16421; Acer Aspire 5750Z-4830
If input equation without parenthesis clear group, program auto group.
Calculation priority may not be your intention, and answer is unexpected.
Please verify answer and verify auto group. At Box10, history list check
to on, see auto group history. Insert your parenthesis group when necessary.
Complex operator use Unicode, if operator is square, computer did
not install that font. Win7 has all operator fonts, WinXP not all.

write complex as '1.2+3.4i' ; not "1.2+3.4i", not (1.2+3.4i) !!
Absolute operator "|" can not use twice. "|A" OK, "|A|" error ! See example c8.
Box6, input symbolic or function call setting
Variable name must NOT use Javascript reserved words. Can not use 'if', 'do' etc.  
Box6 convert +,-,*,/ to function call. Box3 accept if,while ; Box6 document

run⇒ ;
Box7, answer ; Box 8,9,10 dbg off

Do not modify output Box7 equation, modify input Box6 equation.
run⇒ ; setting
Box10, history list     function

Box8, logictt2.htm debug   run⇒ ; 3

Click red run⇒[s2ff] first, if box7/8/9 all empty, then click blue run⇒[s2ff]
Box9, complex4 debug   run⇒ why 8to3?

boxd09.value='string' ; oneLInd[] ; + - ; ;
rbyte=!!ΓⒷ門 //'!' is ANSI , '!' is Unicode , '!' = '!!' ; 門(1,2,3)=gatef(1,2,3)

<a name="js_List">
Following are Javascript reserved words. Please click "jsKeyWord".
You cannot use them as variable name.

    toPage button

<a name="verifys2f2">

<a name="docA001">
2013-03-16-10-50 start 
This file
is a complex number calculator. Earlier 
version are , local , local
Complex equation derivation is at , local
tutc0006.htm is self study (TUTor) Chinese 
page 0006. LiuHH intend to translate 
tutc0006.htm to English page at
and expect upload before 2013-03-31.

<a name="docA002">
2012-12 uploaded Math Logic Truth Table
In logictt2.htm LiuHH convert 
symbolic equation (P → Q) to 
function equation PiftQ(P,Q) 
After done Chinese Truth Table page
LiuHH did not continue logic study. 
LiuHH turn attention to complex2.htm 
hope convert complex number 
symbolic equation (1+2*i)^(3+4*i) to
function equation cpowf('1+2*i','3+4*i')
This attempt save to complex4.htm, let 
complex2.htm not touched.

<a name="docA003">
Today 2013-03-16 upload complex4.htm to
it has no conversion at all. Compare with 
complex2.htm , current complex4.htm has a 
change : include Andreas Greuer page 
to complex4.htm at [a]

In test sets testSet1, 2, 3, if you click 
any one left side button, output auto 
include LiuHH answer and Greuer answer 
and difference = LiuHH.ans - Greuer.ans 

<a name="docA004">
testSet2 has a yellow box for function 
cexpi(c1) input. If input real number to 
yellow box, expect error. Because 
cexpi(c1)  treat input '2' as exp('2i')
Greuer code treat input '2' as exp('2')
Regular exponential function is cexpf(c1).
cexpi(c1) is special cexpf(c1). 
cexpi(c1) let user run e^(2i) input only 2
Why write this special function cexpi(c1)?
It is long time ago 2009-04, now 2013-03 
LiuHH do not remember why. User may want 
to avoid use cexpi(c1), use only cexpf(c1).
2013-03-16-11-40 stop

<a name="docA005">
This version of e:\bak\hp\util\QCCALC.EXE is not compatible with the version of
Windows you're running. Check your computer's system information to see whether
you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact
 the software publisher.
2013-03-11-14-47  //a203111447
I can not verify complex4.htm answer !

<a name="docA006">
Verify exp(-1)=cos(i)+i*sin(i)

Start with Euler's formula 

now let a=i=sqrt(-1)

<a name="docA007">
csinf(c1) =sin(i)=0 , 1.1752011936438013
i*sin(i)=-1.1752011936438013 , 0

ccosf(c1) =cos(i)=1.5430806348152437 , 0

cos(i)+i*sin(i)=1.5430806348152437 +(-1.1752011936438013)


confirm exp(-1)=cos(i)+i*sin(i)
<a name="docA008">
Alert Euler's formula 
if 'a' is real number, above equation 
has absolute value one. 
If let a=i=sqrt(-1) = non_real 
this equation do not have absolute 
value one. 

<a name="docA009">
given equation 
x^i = i
find unknown x

where i=sqrt(-1), analytic answer 
Proved in tutc0006.htm#prob0a18
 to       tutc0006.htm#prob0a22
Above Chinese, below English
 coming  tute0006.htm#prob0a22

<a name="docA010">
in cpowf(c1,c2,nB,nE) 
fill in 
input complex1  4.810477380965351
input complex2  i
output to 6.123233995736766e-17 , 1 
that is  0+1i 
that is  4.810477380965351^i = i

<a name="docA011">
given equation 
i^x = x
find unknown x
where i=sqrt(-1), numerical answer 

<a name="docA012">
in cpowf(c1,c2,nB,nE) 
fill in 
input complex1  i
input complex2  0.4382829367270321+0.36059247187138543*i

output to       0.4382829367270322,0.3605924718713855
same as input complex2 
Shown in tutc0006.htm#prob0b02
 to      tutc0006.htm#prob0b25
Above Chinese, below English
 coming  tute0006.htm#prob0b25

<a name="docA013">
what is the value of i^i ?
page 15 or 18/18 
i^i principal value = exp(-PI/2)

<a name="docA014"> 
cpowf(c1,c2,nB,nE) = cpowf('i','i',0) 
0.20787957635076193 , 0
2013-03-15-22-17 correct

<a name="docA015">
2013-03-16-14-31 start 
following is a list of code location 
Please open complex4.htm source file 
and look for LiuHHfName, GreuerFName
where 'FName' change for different 
function name.

<a name="docA016">
function name Location key string
caddf(c1,c2)  LiuHHcaddf , GreuerAdd 
csubf(c1,c2)  LiuHHcsubf , GreuerSub 
cmulf(c1,c2)  LiuHHcmulf , GreuerMul 
cdivf(c1,c2)  LiuHHcdivf , Greuerdiv 
conjf(c1)  LiuHHconjf
cconj(c1)  LiuHHcconj , GreuerZ3konj
cnewf(r1,r2)  LiuHHcnewf 
<a name="docA017">
cabsf(c1)  LiuHHcabsf , GreuerImReToR 
csqrt(c1)  LiuHHcsqrt , GreuerSqrt 
cmulr(c1,r2)  LiuHHcmulr 
cargf(c1)  LiuHHcargf , GreuerImReToPhi 
cpolr(c1)  LiuHHcpolr 
cxryi(c1)  LiuHHcxryi 
cnegf(c1)  LiuHHcnegf 
cgetr(c1)  LiuHHcgetr 
cgeti(c1)  LiuHHcgeti 
<a name="docA018">
Following link is proof, Chinese page. 
Later change to English page. a203161548
cexpi(c1)  LiuHHcexpi 
cexpf(c1)  LiuHHcexpf , GreuerExp 
csinf(c1)  LiuHHcsinf , GreuerSin 
ccosf(c1)  LiuHHccosf , GreuerCos 
ctanf(c1)  LiuHHctanf , GreuerTan 
csinh(c1)  LiuHHcsinh , GreuerSinh 
ccosh(c1)  LiuHHccosh , GreuerCosh 
ctanh(c1)  LiuHHctanh , GreuerTanh 
cdotf(c1,c2)  LiuHHcdotf 
<a name="docA019">
clogf(c1,nBgn,nEnd)  LiuHHclogf , GreuerLn 
cpowf(c1,c2,nB,nE)  LiuHHcpowf 
casin(c1,rtsq01,nB,nE)  LiuHHcasin 
cacos(c1,rtsq01,nB,nE)  LiuHHcacos 
catan(c1,rtsq01,nB,nE)  LiuHHcatan 
asinh(c1,rtsq01,nB,nE)  LiuHHasinh 
acosh(c1,rtsq01,nB,nE)  LiuHHacosh 
atanh(c1,rtsq01,nB,nE)  LiuHHatanh 
Above proof may contain error ! a203161611
<a name="docA020">
Next is Greuer function and LiuHH lack a203161550
cotangent() GreuerCoTan
hypercotangent() GreuerCoTanh
inverse() Greuer1/Z1
2013-03-16-15-51 stop

<a name="docA021">
2013-04-01-12-16 start 
update 2013-04-01 main point is document for 
cdotf(). cdotf(c1,c2) is complex dot function. 
If input [dot product] white box next line 
1.2+1.3i ; 2.3+2.4i ; 3.4+3.5i 
If input [dot product] red box next line 
4.2+4.3i ; 5.3-5.4i ; 6.4+6.5i 
Red box number change to complex conjugate
4.2-4.3i ; 5.3+5.4i ; 6.4-6.5i 
This change is done by program, 
user please input original complex.
<a name="docA022">
Then carry out next product and sum 
(1.2+1.3i) * (4.2-4.3i)
add //red be complex conjugate 
(2.3+2.4i) * (5.3+5.4i)
(3.4+3.5i) * (6.4-6.5i)
sum to 
54.37 + 25.74i
LiuHH box value is 
54.370000000000004 , 25.740000000000005
<a name="docA023">
If red box value is same as white box, 
answer must be real number. In 
1.2+1.3i ; 2.3+2.4i ; 3.4+3.5i 
must use ';' to separate numbers. ',' is 
not allowed. white box and red box must 
have same count of numbers.
2013-04-01-12-30 stop 

<a name="docA024">
2013-04-01-16-47 start
If input [dot product] white box next line 
3+4i  12-6i
If input [dot product] red box next line 
1+i  2-5i
both lack requires ';' . Because ' ' NOT 
separate data. LiuHH answer is 
LiuHH  33 , 9
Next two lines 
lftBox 3,-6 ; 
ritBox 1,5 ; 
tell you what number used to produce answer.
String 3+4i  12-6i red selected, become 3-6i. 
String 1+i  2-5i blue selected and change to 
complex conjugate, become 1+5i . Answer is 
3-6i * 1+5i = 33+9i WRONG and NO WARNING !
user MUST separate data with ';' 
2013-04-01-17-05 stop

<a name="docA025">
2013-04-03-14-46 start 
update 2013-04-03 change box3 start up 
example from complicated lump call to 
easy to read steps call. Same example 
as earlier (still in complex2.htm) 
After write tute0006.htm Example a20402
LiuHH decide change box3 example structure.
update 2013-04-03 build example button  
2013-04-03-14-56 stop 

<a name="docA026">
2013-04-28-18-22 start 
This is a complex number calculator
On 2013-04-28, program work correctly (hope).
Program has following sections.
Test complex functions A,B,C; Calculator D,E.
A not math related, complex +,-,*,/ etc.
B math func., many input to one answer.
C math func., one input to many answer.
D Complex/real calculator.
E symbolic calculator.
The following main point is difference between 
D and E.

<a name="docA027">
Calculator allow user input function call 
equation, for example cpowf(A,B)
Calculator allow user input symbolic  
equation, for example A^B (A to power B)
If user input A^B, program convert A^B 
to cpowf(A,B)
Calculator D do not convert A^B to cpowf(A,B)
Calculator E  will  convert A^B to cpowf(A,B)
Conversion code has restriction, which apply 
to calculator E.

<a name="docA028">
If user input function call equation, both 
D and E accept. User can use variable name 
longer than one byte.
If user input symbolic equation, only E 
accept. Section D Box4 is blank or reply 
error. User must use variable name exact 
one byte. It is conversion code restriction.

<a name="docA029">
You can input one long equation. 
Example c1 is this case. Same equation 
can be written to several steps, 
Example c2 is this case. 
var a1=csubf(Q,R);   var a2=caddf(P,a1); 
var a3=cdivf(P,Q);   var a4=cpowf(a3,R); 
var a5=cmulf(a2,a4); var b1=conjf(Q); 
var b2=csubf(P,L);   var b3=cxryi(b2); 
var b4=cdivf(b1,b3); var b5=csqrt(b4); 
var U=caddf(a5,b5); 

<a name="docA030">
If one line has '=', program not print 
its evaluation value. Example c1 has 
two lines 
var U=(P+(Q-R))*((P/Q)^R)+√($Q/(╚(P-L)))
"U=" line determine U value, but not print.
"U"  line print U value.

<a name="docA031">
In an equation, evaluation order is important.
Highest priority is power A^B
Second priority is multiplication and division
A*B, C/D.
Third priority is addition and subtraction.
A+B, C-D.
If an input equation has ^,*,/,+,- and no 
parenthesis tell user intention. Program 
still run, but group at programmer's will. 
<a name="docA032">
Example e6 is this case. Input line 
var A='1.2+1.3i',B='2.4+2.5i',C='3.6-3.8i',D='0.2-0.7i'
no parenthesis. Answer is 
<a name="docA033">
which may not be user's intention.
Please run example button e0 to e11 and c1 
to c7.
All output may contain error. Use with care. 
Please verify answer first. 
2013-04-28-19-13 stop

<a name="docA034">
2013-04-29-11-55 start
update 2013-04-29 is not final version. 
Now 2013-04-29, complex4.htm output correct 
result (hope), but document is not done. 
Liu,Hsinhan upload complex4.htm let user 
try program first. Next few days, LiuHH 
will write code document for 
function sym2fun2(arg1) which is most 
important function in complex4.htm .

<a name="docA035">
There are two run buttons //section E
run⇒  input box6, output box8.
run⇒  input box6, output box7.
Blue RUN was written on 2013-04-03-20-03
 Red RUN was written on 2013-04-28-17-32
When write blue, think input to box6, 
converted function call code to box7,
answer value to box8.
<a name="docA036">
Later use blue button, find it is better 
input to box6, output to box7 (not 8).
Then write red button. Switch box7, box8. 
After switch, answer to box7 and function 
call code to box8. But error example r1 to 
r4 no error message. 2013-04-29 decide 
use both red and blue. If click red RUN 
box7,8,9 all blank. then click blue RUN.
2013-04-29-12-23 stop

<a name="docA037">
2013-05-01-18-07 start 
update 2013-05-01 
Example c3 contribute correction at a204291446
but damage example e7 answer. Correction made 
at code time stamp a2050115 to a2050117. 
Program still debug in progress. LiuHH thought 
OK and upload, but later find error. Current 
version may still contain error. LiuHH will 
repair later. When write code document for 
function sym2fun2(arg1) it is a good chance
to straighten everything.
2013-05-01-18-11 stop 

<a name="docA038">
2013-05-01-19-22 start 
Why  ?
"8to3" mean copy box8 value to box3. 
Box6 value is symbolic equation A-B , C*D 
Box8 value is function call equation 
csubf(A,B) and cmulf(C,D) . 
Program carry out function call equation 
Box3 is main calculator. Copy box8 to box3
Box3 will give same answer.
<a name="docA039">
Current version box6 do not allow 
if(){...}else{...} structure. hope 
improve in the future. Box3 accept 
if(){...}else{...} structure but 
box3 not convert symbol to function 
2013-05-01-19-43 stop 

<a name="docA040">
2013-05-14-16-40 start 
update 2013-05-15 has major code change 
compare with update 2013-05-01.
update 2013-05-01 rely on oneline
update 2013-05-15 rely on oneLInd
If input is "ⓈR5t*ⓈR5t+ⒸR5t*ⒸR5t"
oneline is a string, when program read 
operator Ⓒ, update 2013-05-01 look 
left one byte '+' and right one byte 
'R', not get the whole picture. 
<a name="docA041">
On the other hand, 
oneLInd[] is an array, program read 
operator Ⓒ, update 2013-05-15 look 
left one section '+' and right one 
section 'R5t', get better picture, 
make correct decision.

<a name="docA042">
update 2013-05-01 require variable 
be one byte long
update 2013-05-15 allow variable be 
several bytes long.

update 2013-05-01 convert "{A*B)-[C/D>"
to "(A*B)-(C/D)"
update 2013-05-15 NOT convert from 
"{A*B)-[C/D>" to "(A*B)-(C/D)"

<a name="docA043">
Liu,Hsinhan did not test input box6 
allow if()else structure or not. To 
prepare if()else structure for input 
box6, LiuHH dropped code to convert 
input string '[', '{', '<' to '(', 
and not convert ']', '}', '>' to ')' 

<a name="docA044">
update 2013-05-01 repair one case, 
and damage another case. 
update 2013-05-15 all example click 
button has complex number output. 
That is a positive sign, program OK. 
Liu,Hsinhan still can not promiss 
all cases considered. Future will 

<a name="docA045">
update 2013-05-01 build many example 
buttons, each few equations.
update 2013-05-15 build one example 
button e12, it has many equations. If 
you run example e12, program auto turn 
off box8,9,10 debug check box, allow 
faster run. If you click [e12] then 
click debug check box to checked, be 
prepare for long time waiting.
2013-05-14-17-36 stop 

<a name="docA046">
2013-05-15-10-38 start 
update 2013-05-01 red run⇒ 
output function call equation and answer.
update 2013-05-15 red run⇒ 
output user input equation and answer.
update 2013-05-15 blue run⇒ 
still output function call equation and to Box8.
Did not change output to Box10 (closer) Because 
LiuHH think Box10 history list may be important 
to reader, Box8, logictt2.htm debug may not be 

<a name="docA047">
update 2013-05-01 output history list to Box9.
no complex4 debug box.
update 2013-05-15 output history list to Box10.
let Box9 be complex4 debug box.
Move Box10 above Box8,9.
Keep debug output box allow programmer reader 
to improve/correct code.
Program stop at error. If input box has many 
lines, remember input box last line. Run code, 
goto output box see whether last line show up.
2013-05-15-10-56 stop 

<a name="docA048">
2013-05-17-13-51 start 
update 2013-05-17 made a major correction. 
complex4.htm update 2013-05-17 and earlier 
complex2.htm have same Box3,4,5 function.
After update 2013-05-15, Liu,Hsinhan move 
to complex4.htm Box3,4,5 hope let Box3 
read symbolic equation. Test example is 
[e12] "'3+6i'/factorial(3)//a205161214;"
This line is an error in Box6. LiuHH 
debug and repaired. All modification have 
time stamp "a20516". update 2013-05-17 
will run [e12] "'3+6i'/factorial(3)" 
correctly. (update 2013-05-15 error !)
2013-05-17-13-59 stop 

<a name="docA049">
2013-05-20-16-00 start 
update 2013-05-20 made several change 
allow example e12 several equations run 
correctly, they are next six equations
Correction made at code with time stamp
from a205172011 to a205191421 
or from a20517 to a20519
2013-05-20-16-06 stop 

<a name="docA050">
2013-05-22-23-11 start 
update 2013-05-22 added real number functions
stepf(2,1) : onoff=stepf(t0,bgn0)
  variable t0=2, step at bgn0=1, 
  if t0>=bgn0, stepf(t0,bgn0)=1 else 0.
  stepf(2,1)=1, stepf(2,3)=0
gatef(2,3,4) : onoff=gatef(t0,bgn0,end0)
  variable t0=2, gate at [bgn0,end0]=[3,4]
  if bgn0<=t0<=end0, gatef(3,1,5)=1 else 0.
  門 is operator for gatef(). 門 is door in 
  Chinese. 門 is a picture char. read men. 
<a name="docA051">
factorial : factorial(5)=5*4*3*2*1
  5! is factorial(5) 
facdb : double factorial. 
  7!!=facdb(7)=105 ; 6!!=facdb(6)=48
//a205211501 add !,Γ,Ⓑ
gamma : gamma(5.6)=61.553915006289046
loggamma : loggamma(5.6)=4.119913457533526
bicof : bicof(6,2)=15=6!/2!/(6-2)!

<a name="docA052">
factorial and double factorial operator 
read input from its LEFT side value 5!. 
All other unitary operator read input 
from its right side value. example √3
Complex binary operator read input from 
its left and right side, example '3i'*8.
<a name="docA053">
Real binary operator read input from 
its right side (v1,v2) for example 
binomial coefficient Ⓑ(6,2) OK, 6Ⓑ2 NO.
Gate function gatef(v1,v2,v3) need three 
input numbers. v1 is current point value 
under exam. [v2,v3] is gate boundary. 
If v2<=v1<=v3 gatef() return 1, else 0.

<a name="docA054">
stepf() and loggamma() no operator defined.
gatef() defined operator 門 at the code line 
, ['門', 'gatef'] //a205221053test
make sure code structure allow insert one 
line (like a205221053test line) active 
operator and work correctly.

<a name="docA055">
update 2013-05-20 and earlier version 
output real number with zero imaginary.  
update 2013-05-22 output real number 
without zero imaginary. 
2013-05-22-23-41 stop

<a name="docA056">
2013-06-19-09-47 start
update 2013-05-25 is at

<a name="docA057">
2013-06-19-09-50 start
Next is update 2013-06-19. Changes are 

1: Allow varName='3i'/'-2+i'
vv //a206091210; a20609115? repair
Earlier code search for "='", if see "='" 
program assume this line is 
and skip symbol to function call conversion.
This skip let program run a little faster, 
but also damage code line like 
find repair code at "a20609115"

<a name="docA058">
2: main improvement, allow Box3 run symbolic 
Click run⇒  for symbolic equation.

do not accept symbolic equation '1+2i'^'3+4i' .
but accept function call equation

<a name="docA059">
Example button     has few 
example code for you to test run.

Example button    are debug inputs.

, , ,  
are debug buttons.
Button  display available symbol 
in this program.
Button  delete box 3,4,11,12 value.

<a name="docA060">
This program is still working in progress. 
If you find any error output, hope LiuHH 
will debug and correct in future version.
All output are as is, Liu,Hsinhan can not 
promiss correctness, user MUST verify first.
2013-06-19-10-20 stop 

<a name="docA061">
2013-06-19-14-56 start 
Code accept complex input as 
Here '1.1+2.2i' is a string, code convert 
from '1.1+2.2i' to array [1.1,2.2].
display answer  2.2,4.4  for  2.2+4.4i
<a name="docA062">
cc=aa+aa+' any string'
display error message.
Because aa is complex '1.1+2.2i'
but ' any string' is not complex. 
<a name="docA063">
When program see input has string or 
complex (fc) mixed with string (fs)
program NOT call symbolic to function 
call conversion sym2fun2(). Result is 
unexpected. Example i3 has such code 
oupStr+=x+' ; '+y+'\n'; //alert [+=]
here both x and y are complex, but 
oupStr and ' ; ' and '\n' are three 
<a name="docA064">
Example i3 code line work 
because this code line do not ask 
complex x add complex y, this code 
line ask to string complex x with 
complex y, insert ' ; ' in between 
x and y. 
<a name="docA065">
If your intention is display answer 
complex x add complex y and list it.
Use the code 
x='1+2i'; y='3+4i';
z=x+y; //complex only, no string
oupStr=z+'\n'; //oupStr & '\n' are string
oupStr //this line display answer
<a name="docA066">
In each code line complex4.htm drop string 
right to "//"
input line cc=aa+aa+'//any string'
become     cc=aa+aa+'
input line cc=aa+''
become     cc=aa+' http:
Above both cause error.
complex4.htm is a simple program, need 
user cooperate with complex4.htm style.
2013-06-19-15-17 stop 

<a name="docA067">
2013-06-20-18-06 start
update 2013-06-20 add code line 
boxd12.value=funcall; //a206201144
let box3 symbolic equation convert to 
function call equation be displayed in 
box12. Click  copy code 
to Box3, then 
will work. 

<a name="docA068">
update 2013-06-20 add code line 
f1=codestr.indexOf('='); //a206201545
Program auto change from a+=b+c to a=a+b+c 
In "a+=b+c"  '=' is third byte   f1=2
In "a=a+b+c" '=' is second byte  f1=1
If not update f1 value, example i1 error.
   because "t^i0/i0!" convert from 
   symbol eqn. to function call eqn. 
   and cut one byte off, error.
If not update f1 value, example i3 OK.
   because "x+' ; '+y+'\n'" has string 
   '\n' and NOT convert from symbol eqn. 
   to function call eqn.
2013-06-20-18-20 here

<a name="docA069">
if write js reserved words (if,do,while)
and "t^i0/i0!" symbolic equation in one 
line, result is failure. Code line 
 if(fj==0 //a205251538 
refuse 'if' and "t^i0/i0!" be one line.

<a name="docA070">
if write string ' , ' or '\n' and 
"t^i0/i0!" symbolic equation in one 
line, result is NOT convert from symbol  
   eqn. to function call eqn. Code line 
 &&fs==0 //a206171628 
stop convert from symbol eqn. to 
function call eqn.

<a name="docA071">
Always write '{' and '}' not same line 
as "t^i0/i0!" 
write '{' and '}' one line by itself.
oupStr+=x+' ; '+y+'\n';
above is correct code. //Example i3,
below is failure code. 
{  x=18*Ⓒ(z0)-3*Ⓒ(18*(z0+0.34)/2);
oupStr+=x+' ; '+y+'\n'; 

<a name="docA072">
If Box4 no answer, and no error 
(//If see this message, code has error.)
Box4 is just blank, that is because user 
forget add one variable in last line.
var ww1=Ⓒ('1+2i'); 
var ww2=ww0*ww0+ww1*ww1; 
above print answer ww2 value to Box4
below not print any thing to Box4
var ww1=Ⓒ('1+2i'); 
var ww2=ww0*ww0+ww1*ww1; 
2013-06-20-18-40 stop

<a name="docA073">
2013-06-22-14-28 start
update 2013-06-24 deleted example [j0], [j1], 
[j2]. Added  and  two example buttons.
Example [i4] use while() loop and modify 
code to run iter0++ and it0-- correctly.
Code stamp a206210918 repair [++]. 
Code stamp a206210921 repair [--]. 

<a name="docA074">
Example [i5] use do-while() loop and 
modify code allow program work with 
'+=', '-=', '*=', '/=' correctly. 
Related code stamp from a206211502 
to a206211545

<a name="docA075">
Example [i5] end ask print value of 
variable I. I was defined to be I='i'
Print value of I get next two lines 
I  //variable name 
i  //variable name I store string 'i'
which is correct. 

<a name="docA076">
Example [i5] end ask print value of 
variable i. i was defined to be 
Print value of i get next two lines 
i   //variable name 
0,1 //variable name i store array [0,1]
which is correct. 

<a name="docA077">
Why I='i' not get value array [0,1]?
Why i=1*'i';  get value array [0,1]?
Because i=1*'i'; has complex multiplication 
operation. All complex operation end with 
array expression. Code I='i' do not have 
complex operation. I value be string 'i' 
never change. 

<a name="docA078">
Example [i5] end ask print value of 
iter0*i //a2062207 drop outer '()'
The result is next line 
Outer parenthesis pair stop program 
to print iter0*i value. 
LiuHH did not modify 2009 old code. 
(long time already forget old logic)
Added code a2062207 drop outer '()'
change from
get answer.
2013-06-22-14-56 stop

<a name="docA079">
2013-06-24-10-07 start
update 2013-06-22 added 
function sliceSemi(arg1)

Example [i5] first two lines 
re-write as one line code 
iter0=-1; itMax=12; 
click  get error 

<a name="docA080">
LiuHH write function sliceSemi(arg1) to 
cut at right side of ';'. Let code line 
iter0=-1; itMax=12; 
cut to 
This cut must be selective.
<a name="docA081">
Code can not cut at following ';'
1: //comment ; a206221642
   expose " a206221642" outside of comment
   that is an error.
<a name="docA082">
2: for(z0=bgn0;z0<end0;z0+=step)
   slice above line to three short lines 
   that is correct to javascript, but 
   error to complex4.htm, because 
   complex4.htm require each line has 
   balance parenthesis pair.
<a name="docA083">
3: oupStr+=x+' ; '+y+'\n'; 
   if cut at ' ; ' , result is
oupStr+=x+' ;
   then string ' ; ' include a new line 
   byte, which is an error.

<a name="docA084">
complex4.htm has three run buttons
 locate below "Box3" see run⇒
 locate at "Box11 debug" line

<a name="docA085">
Differences are next.
 is main button. 
This button call function sliceSemi(arg1)
and call function evalSymbEq(arg1,arg2)
Send sliceSemi(arg1) result to Box11.

 call evalSymbEq(arg1,arg2) 
and skip function sliceSemi(arg1)
Click example , then click  
get answer. But if click  get error.

<a name="docA086">
do not call sliceSemi(arg1) and 
do not call evalSymbEq(arg1,arg2)
If run any symbolic equation at box3, 
Box12 output function call version.
Click  copy box12 value to box3.
<a name="docA087">
at this moment in box3 change from 
program give correct answer.
2013-06-24-10-50 stop

<a name="docA088">
2013-07-09-11-19 start
update 2013-07-09 added example buttons 
, . Please see document at
2013-07-09-11-21 stop

<a name="docA089">
2013-07-30-15-02 start
complex4.htm update 2013-07-30 is new version 
of complex6.htm function evalSymbEq( ) document 
writing. Several internal code change. 

update 2013-07-30 appearance change is next
1. re-write example  add example 
2. Click  added 
If you see this message, Box3 input code has error.
..... 2013-07-29-12-35 OR
..... 2013-07-28-22-36
<a name="docA090">
2013-07-28-22-36 alert program did not 
reach end of function evalAll( ). All 
kind of code error, unable reach end. 
2013-07-29-12-35 alert program reached 
end of function evalAll( )
Code contain symbolic operator error.
 call function evalAll( ) and 
NOT accept complex symbolic operator.
<a name="docA091">
3. added toPage button and page ans 
two links.
4. Box3 default example Example i5 and 
Example i0 allow  and  
both run correctly.
 output real number, keep //comment.
 output complex number, drop //comment.
5. added <span id=spanB> reveal string newline 
byte is '\r\n' (rn01) or '\n' (_n01) 
or '\r' (_r01) Reader do not need this 
information. LiuHH need to know. 
2013-07-30-15-57 stop

<a name="docA092">
2013-07-31-16-57 start
update 2013-07-31 change symbol 
S casin ; C cacos ; T catan 
s asinh ; c acosh ; t atanh
㊀ casin ; ㊁ cacos ; ㊂ catan 
㈠ asinh ; ㈡ acosh ; ㈢ atanh
<a name="docA093">
If user input 
w=S(3); //casin(3) 
operating system change to next line 
w=S(3); //undefined
Unicode S has internal value &#65331;
ANSI S has internal value &#115;
Program define &#65331; be operator 
for casin(). Operating system change 
&#65331; to &#115; all calculation go 
wrong. 2013-07-31-14-29 find trouble. 
At first LiuHH try use Ṡ,ṣ,Ċ,ç,Ṫ,ṭ 
as new operator for Ṡ=arc-sine and  
ṣ=arc-hyper-sine etc. But Ṡ,ṣ,Ċ,ç,Ṫ,ṭ 
conflict with European language user. 
<a name="docA094">
Finally 2013-07-31-15-25 change from 
S casin ; C cacos ; T catan 
s asinh ; c acosh ; t atanh
㊀ casin ; ㊁ cacos ; ㊂ catan 
㈠ asinh ; ㈡ acosh ; ㈢ atanh

Circled ㊀ , ㊁ , ㊂ and 
parenthesised ㈠ , ㈡ , ㈢ 
are true symbol, not used in Chinese 
Operating system will not change 
㊀,㊁,㊂,㈠,㈡,㈢ and program is stable.

一=one , 二=two, 三=three in Chinese.
Four is not four bars 四=four.
2013-07-31-17-23 stop

<a name="docA095">
2013-08-02-16-08 start
Just find out that above 
"operating system change Unicode to Ansi" 
was wrong. It is LiuHH code change 
has one code line 
2013-07-31-14-29 find trouble, that time 
LiuHH did not pay attention to "onchange="
code. 2013-08-02-16-05 LiuHH write document 
for function sym2fun2(arg1) wonder why 
Box6 do not have "operating system change"
and Box3 has "operating system change"?
Then find it is a blame to LiuHH himself.
<a name="docA096">
Now, 2013-08-02-16-15 LiuHH stay use 
㊀ casin ; ㊁ cacos ; ㊂ catan=complex arc-tangent 
㈠ asinh ; ㈡ acosh ; ㈢ atanh=complex arc-hyper-tangent
Because bar in circle ㊀,㊁,㊂ and 
bar in parenthesis ㈠,㈡,㈢ are 
very different from alphabet S,C,T, but 
Unicode operator S,C,T; ANSI alphabet S,C,T 
look alike, easy get confuse.
To see ㊀,㊁,㊂,㈠,㈡,㈢ user must use a 
computer support wider range Unicode. 
Newer computer window 7, 8 will support 
wider range Unicode (LiuHH guess).
Operator Unicode are next.
㊀=#12928; ㊁=#12929; ㊂=#12930
㈠=#12832; ㈡=#12833; ㈢=#12834
2013-08-02-16-28 stop

<a name="docA097">
2013-08-09-01-19 start 
update 2013-08-09 made several important 
changes. From 2013-08-01, Liu,Hsinhan 
write complex6.htm#docA301 document for 
function sym2fun2() which change from 
symbolic equation to function call eqn.
During sym2fun2() document writing, make 
code correction and improve efficiency.
<a name="docA098">
LiuHH intend upload updated complex4.htm 
after done sym2fun2() document. But, on 
2013-08-08-20-33 landlord give LiuHH two 
month in advance notice, landlord ask 
LiuHH move out in two month. Then the 
coming days LiuHH will be busy move out 
to another house/room. Now 2013-08-09 
update complex4.htm and future update 

<a name="docA099">
2013-08-02-15-26 find error output. If 
input next equation
no answer, function call equation is 
"))fac" is wrong, "))+fac" is right.
However, if input 
answer is correct. Because 
'*' is binary operator only 
'+' is unitary/binary operator 
Old version treat "+3!" as unitary 
operator and drop '+' cause error.
Correction at complex4.htm source code 
time stamp a208021648 to a208021705 .

Above is 2013-08-02 correction.
Below is 2013-08-03 correction.

<a name="docA100">
If input equation 
early version generate function call
The outer '()' prevent printing answer. 
update 2013-08-09 delete outer '()' get 
which has answer. Code change at complex4.htm 
source code time stamp a208031815,a208031816

Above is 2013-08-03 correction.
Below is 2013-08-04 information 

<a name="docA101">
Early version if Box3 has "aa=Ⓢ1.2", click 
 no output and user do not know what 
to do.
2013-08-04 added information to Box3
If see this message, input Box3 has error.
If Box3 input one line [aa=Ⓢ1.2] no answer!
Need second line [aa] request value of aa.
If test, do not type above square bracket.
Liu,Hsinhan 2013-08-04-11-20 //a208041120
Suggest user add second line "aa".

Above is 2013-08-04 information 
Below is 2013-08-06 correction

<a name="docA102">
2013-08-06-15-51 find that input equation
ERROR output 
left most '-' disappear !!

solve at adding code to complex4.htm 
see source code time stamp a208061830 
to time stamp a208061840
if(oneLInd[oLI][0]=='n' //a208061830
    } //a208061840

<a name="docA103">
Early error, it is 
error = no answer, 
correct = answer show up. But 
left most '-' disappear !! error is different 
from earlier error. This error has answer 
and this answer is wrong. After a208061830
correction, in complex6.htm LiuHH wrote 

<a name="docA104">
complex4.htm may output error 
answer !!
User must verify answer first !!
Liu,Hsinhan 2013-08-08-15-38 

<a name="docA105">
Above are several important correction.
LiuHH continue write sym2fun2() document 
and continue correct code error. 
Please visit 
complex4.htm complex calculator 
complex6.htm function document
frequently for updated version.
2013-08-09-02-14 stop

<a name="docA106">
2013-08-11-17-55 start 
update 2013-08-11 made two corrections.

Example [e8] equation 
 that is  (-2.345)^1.85
it is NOT  -2.345^1.85
update 2013-07-31 get correct answer 
4.311666396433531 , -2.19690375871282

<a name="docA107">
update 2013-08-09 get error answer 
4.311666396433531 , 2.19690375871282

update 2013-08-11 get correct answer 
4.311666396433531 , -2.19690375871282

Above is cpowf(-2.345,+1.85)
<a name="docA108">
Below is -2.1+cmulf('1.2+3.4i',-2.3)

update 2013-07-31 get error answer 
-0.66 , -7.82 

update 2013-08-09 get correct answer 
-4.86 , -7.82 

update 2013-08-11 get correct answer 
-4.86 , -7.82 

<a name="docA109">
update 2013-08-09 made 
from error to correct, at the same time 
update 2013-08-09 made 
from correct to error. 

update 2013-08-11 made two corrections.
they are 

<a name="docA110">
First correction. in 
function cnegf(c1)
{ //add red code 
if(typeof(c1)=='number') //a208092215
var c3=parseFloat(c1);
return -c3; //a208092216
  } //below is old code
var c2=toCplx(c1);
c2[0] = -c2[0];
c2[1] = -c2[1];
return c2;
} //9803201157

<a name="docA111">
If user equation is 
Without above red code, 
convert real negative number -2.345 
to cnegf(2.345), in function cnegf()
code change real positive 2.345 
to array [-2.345, 0] which is 
complex negative '-2.345+0i'
real -2.345 become complex '-2.345+0i'

<a name="docA112">
With above red code, convert 
real negative number -2.345 to 
cnegf(2.345) to real negative 
-2.345 . Real back to real.

From -2.345 to cnegf(2.345) 
then -2.345 ? Why walk long way 
back to same value?
Current code structure, if not 
walk above long way, later code 
change -2.345 to 
csubf(,2.345) this is an error.
csubf(0,2.345) is ok. Current 
code structure do not insert 0.

<a name="docA113">
Second correction. In 
function cargf(c1) 
add if() condition to reverse value.
phAng=-phAng; //a208111147

Assume z = x + iy and assume y=0.
The principal value of arg z, 
is given by
x > 0, y = 0: arg z = 0
x < 0, y = 0: arg z = PI (not -PI)

<a name="docA114">
If z = x + iy = -2.345 + 0i 
x=-2.345< 0, y = 0: arg z should = PI
But javascript function 
Math.atan2(0,-2.345) return +PI (OK)
Math.atan2(0,-2.345) return -PI (NO)
LiuHH write code 
<a name="docA115">
var tiny0=1.e-15; //a208111108
var phAng=Math.atan2(c1[1],c1[0]); //a208111109
if(c1[1]<tiny0&&c1[1]>-tiny0) //a208111111
w1=Math.atan2(0,c1[0]); //a208111116
phAng=-phAng; //a208111147
    } //if(Math.abs(phAng-w1)>tiny0)
  } //if(c1[1]<tiny0&&c1[1]>-tiny0) 
return phAng; //a208111119

<a name="docA116">
to change from -PI to +PI.
(assume a208111116 code line reliable)

First correction, Second correction 
either one solve cpowf(-2.345,+1.85) 
2013-08-11-19-20 stop

<a name="docA117">
2013-09-26-14-00 start 
Update 2013-09-26, output 1+2i (not 1,2), 
output 3 (not 3,0). 

2013-09-25-16-49 LiuHH test run 

<a name="docA118">
 where Math.sin(aa)  get NaN. 
if use Math.sin(|aa) get 0.989358246623382
This structure ask user code Math.sin(|aa)
'|' in '|aa' mean take absolute value of aa.
aa=[7.999999999999998 , 0] = 8+0i
aa is an array. Math.sin() expect receive 
a number, not expect receive an array.

2013-09-25-16-52 LiuHH write 
function i0c2r(arg1)
//i0c2r = if imaginary is zero, 
//then change complex to real.

<a name="docA119">
If answer complex has zero imaginary, 
function i0c2r() change array aa=[8,0]
to number aa=8. Relief user from adding 
'|' to aa.
LiuHH also modify code, let output from 
array complex [1,2] to string '1+2i'
Let user get familiar complex form 1+2i
However, both change damage draw curve 

<a name="docA120">
Next data is good for drawing
-1.518,0.0  ;-1.602,-1.612

Next data damage drawing, missing 0i
-1.570,0.467 ; -1.960,-1.436
-1.518       ; -1.602,-1.612
-1.465,0.148 ; -1.245,-1.717

Next data '+' damage drawing.
-1.570+0.467i ; -1.960+1.436i
-1.518+0i     ; -1.602+1.612i
-1.465+0.148i ; -1.245+1.717i

<a name="docA121">
Update 2013-09-26 add next two user choices.
If answer is real 1, imaginary 2 output array complex 1,2, Good for draw curve.
If answer is real 1, imaginary 0 output real number 1. Damage curve data!
above two lines are document, not control any. Real control box is below Box4.
<a name="docA122">
If complex answer is real 1, imaginary 2, 
user can choose output 1+2i, or 1,2 .
If complex answer is real 1, imaginary 0, 
user can choose output 1, or 1,0 / 1+0i .
Now output form is in user's hand. If 
create drawing data, must check box and 
see two Good for draw curve.
2013-09-26-14-39 stop

<a name="docA123">
2013-09-26-15-01 start 
In Box3 input next line 
click  Box4 get 0.3999999999999986
2^3*4/5-6 = 8*4/5-6 = 32/5-6 = 6.4-6 = 0.4 OK
click  Box4 get -1, which is wrong. 

 call complex +-*/^ do right job.
 use javascript real +-*/ and
2^3 is not defined.
2013-09-26-15-09 stop

<a name="docA124">
2013-11-02-15-26 start 
update 2013-11-02 made several correction 
which allow input equation contain ",-√" 
and "Math.sin" output correctly. 
Example  has several example equations 
they are safe in current version. Please 
goto Box6 click  fill example to Box6. 
Click RED run⇒ get answer in Box7. 
<a name="docA125">
Last equation is 
that is sin(2.34)*sin(2.34)+cos(2.34)*cos(2.34)
correct answer is one. If last equation answer 
show up, earlier equation do not have javascript 
grammar error. But earlier answer still may be 
wrong. Please verify answer.

<a name="docA126">
Following is recent work record.
2011-10-06-18-41 access
2011-10-06-18-49 save

<a name="docA127">
2013-10-15-14-50 open
page 12/12 exercise 10 has problem and answer 
p=1/3;         //cpowf=Complex POWer Function
cpowf(z,p,0,3) //z,p : z^p = '-2+2i'^(1/3)
answer is      //0,3 : 0=principal answer, 
1+i            //1,2,3 non-principal ans.

<a name="docA128">
1.0000000000000002,1,                 //principal answer
-1.3660254037844383,0.36602540378443965, //non-principal 
0.366025403784438,-1.366025403784439,    //non-principal 
1.0000000000000013,0.9999999999999989 //repeat principal 

<a name="docA129">


<a name="docA130">
'-' in next '-√(3)' cause error
see the code //csubf=Complex SUBtraction Function
]]                error || here   
There must be a number in between ( and ,.

<a name="docA131">
2013-11-02 all day modify complex4.htm 
allow following equations get answer 
1+(-Ⓢ2.1)  //repair at time stamp a21102, a211021042
1+cpowf('1-0.2i',-√2.1)  //[,-√] repair at a211021131
1+cpowf(-Ⓢ1.2,-√2.1)    //[(-Ⓢ] repair at a211021211
|(10*Math.PI/2)   //(Math.PI) need (), see a211021410
(Math.sin(2.34)*Ⓢ2.34)+(Math.cos(2.34)*Ⓒ2.34) //a211021517
If you open complex4.htm source code and 
find key string "a21102" you will find all 
change made on 2013-11-02.
Other error will be corrected if LiuHH pay 
attention to them in the future. 
Thank you for visiting
Liu,Hsinhan 2013-11-02-16-02 stop 

<a name="docA132">
2013-11-05-09-52 start 
update 2013-11-11 let cpowf(0,-1) output 
complex_infinity and let user set tiny 
2013-11-04-09-33 find that complex4.htm 
calculate cpowf(0,-1)=0 
But 0^(-1)=1/0 = infinity !!
2013-11-04 modify code, let 
Please see complex4.htm find "a21104"
Precise code line has "a211041104".

<a name="docA133">
On 2013-11-04&05 add user control box 
1.0e-6>=user tiny>1.e-16 program accept tinyuser=1e-12
If tiny=1.e-13, answer=2.e-14+3.e-14i, output 2.e-14+3.e-14i or 2.e-14
Allow user determine how small be zero.
If answer approach zero, value may vary 
in the range 1.e-6 to 1.e-17 Program 
set default tiny=1.e-13. 
If answer 2.e-14+3.e-14*i output 0+0*i
If answer 2.e-13+3.e-13*i output 2.e-13+3.e-13*i
User can change default tiny in the range 
1.0e-6>=user tiny>1.e-16

Please goto Box3 click example  then 
click RED run⇒ get answer in Box4.
2013-11-05-10-38 stop

<a name="docA134">
2013-11-11-16-00 start
On 2013-11-05 intend to update complex4.htm
But that day found many error output. 
From 2013-11-05 to 2013-11-11, Liu,Hsinhan 
re-write complex4.htm 
Today 2013-11-11 test all sample inputs. 
All get reasonable answer. There too many 
changes, LiuHH can not list here. Please 
see complex4.htm source code date stamp 
from a21104 (2013-11-04) 
  to a21111 (2013-11-11) 
After change code, earlier_OK input 
must change to 
Use ';', not use ','.

<a name="docA135">
complex4.htm add parenthesis pair to user 
input equation. If user input has proper 
parenthesis pair, then some error may be 
avoided. For example, if input 
earlier version output to 
cpowf(1-Ⓢ(  (Math)  .PI/2),1/2)
it cause error. update 2013-11-02 output to 
cpowf(1-Ⓢ(  (Math.PI)  /2),1/2)
If user input (Math.PI) or (Math.sin(2.1))
then earlier version has no problem.

<a name="docA136">
Some time repair one problem and damage 
another. Earlier than update 2013-08-09 
complex4.htm accept "bb=+2 "
start from update 2013-08-09 to 
update 2013-11-02 all output "bb=; "
Disabled some input. 

<a name="docA137">
Next input 
is OK in update 2013-11-11 but error 
in update 2013-11-02.

<a name="docA138">
update 2013-11-11 related test equation 
is in Box6 click example  then 
click RED run⇒ get answer in Box7.
Both  and  last equation use 
variable name endEqn. Let user visual 
check example do reach last equation.
If you do not see endEqn in box7, that 
indicate code error.

<a name="docA139">
Expect long journey for final stable 
version complex4.htm .
Please play this develope-in-progress
You must suspect every output and verify 
answer first. 
Because complex4.htm has big change, 
document page complex6.htm wait and see.
2013-11-11-17-00 stop

<a name="docA140">
2013-11-11-19-01 start 
Example  use array complex as input 
var c1=[2.3, -4.5]
c1 //complex number in ARRAY form.
complex4.htm freeze. 
2013-11-11-18-52 delete array complex number 
from  example.
complex4.htm accept complex in string form
aa='1.2+3.4i' //OK
bb=[1.2, 3.4] //NO
cc=(1.2+3.4i) //NO
2013-11-11-19-07 stop

<a name="docA141">
2014-03-28-17-40 start 
update 2014-03-28 change three line below 
Box3, JS command the [test box3] button 
from call newer function evalAll() , but 
newer code introduce error. Change to call 
older complex2.htm function evalAll_9909() 
Four line above Box3, JS command the 
[test box3] button still use newer function 
evalAll() it has error. Future debug. This 
change allow bioge009.htm#docA105 code work.
2014-03-28-17-49 stop

<a name="docA142">
2014-04-05-17-47 start 
update 2014-04-05 in function evalAll() delete 
error code. This delete allow normal code flow 
error code has time stamp a211111717 etc and 
a211082206. LiuHH tested, after delete error 
code, bioge009.htm#docA105 code work. If click 
button  program fill bioge009.htm#docA105 
code to Box3. Run [r0] example by click 
[test box3] , NOT click [eval box3].

<a name="docA143">
Click button  
call function evalAll() which contain code 
a207 (example a207291223, a207301602) .
a207 code added on 2013-July.
Click button  
call function evalAll_9909() which do NOT have 
code a207. evalAll_9909() written in 2009-2010.
complex4.htm function evalAll_9909() is same as
complex2.htm function evalAll().
2014-04-05-18-05 here 

<a name="docA144">
Click button  
call function evalSymbEq(inp8,'boxd04.value');
[eval box3] is very different from [test box3]
[eval box3] button accept '1+2i'^'3+4i'
[test box3] button do NOT accept '1+2i'^'3+4i'
2014-04-05-18-48 stop

<a name="docA145">
2014-05-09-16-31 start 
update 2014-05-09 made code correction at 
time stamp "a305091606 del", "a305091607 if()"
Earlier version, if input -1+2*'i' to box3
click [eval box3] box4 output 1+2i, program 
dropped '-' which is an error.

<a name="docA146">
2014-05-08-10-56 write program as the following

<a name="docA147">
At first LiuHH use  y=-1+(z0*'i'); 
output to positive real component. 
This error force LiuHH write code as 
Now made correction in complex4.htm 
Hope no trouble. But bug still may 
be somewhere. 
<a name="docA148">
complex4.htm lack of other proofread 
and lack of all cases test run. 
No promise all right. If you find input 
-1+(z0*'i') get error output, try add 
Parenthesis change to (-1+(z0*'i')) 
or re-order, change to (z0*'i')-1 
hope some way will go around the bug.
2014-05-09-16-50 stop

<a name="docA149">
2014-05-09-17-56 start
update 2014-05-09 change the start up  
output form selection 
If answer is real 1, imaginary 2 output array complex 1,2, Good for draw curve.
If answer is real 1, imaginary 0 output real number 1. Damage curve data!
to the following
If answer is real 1, imaginary 2 output array complex 1,2, Good for draw curve.
If answer is real 1, imaginary 0 output complex 1 add 0i. Good for draw curve.
let user build data array without any damage.
2014-05-09-18-02 stop

<a name="docA150">
2014-05-29-15-59 start 
update 2014-05-29 made code change at time 
stamp a30529. Main point is move conjf() to 
//a305291547 move conjf(c1) to conjf_old(c1)
//a305291549 use  cconj(c1) as conjf(c1)
in conjf_old(c3) if c3 is string complex '1+2i'
input c3 keep same '1+2i' not change to  '1-2i'
in conjf_old(c4) if c4 is array complex [1,2]
input c4 change to [1,-2] (a surprise)
different input type, different output. 
ignore conjf_old() ; 2014-05-29-15-55
<a name="docA151">
conjf_old(c4) modify input array complex.
cconj(c1) and conjf(c1) not modify input. 
Another change is add operator 'Ⓚ'
, ['$', 'conjf']   //a205141520 use '$'
, ['Ⓚ', 'cconj']  //a305291206 use 'Ⓚ'
Now '$' and 'Ⓚ' use same code (although 
different function name)
2014-05-29-16-06 stop 

<a name="docA152">
2014-09-19-18-29 start 
complex operation mix with real value function?
Box3 and Box6 in
allow user input complex equation like 
'1+2i'^'3-4i' or csinf('-2.2+0.45i') or Ⓢ'-2.2+0.45i'
All '+', '-', '*', '/' in complex4.htm convert 
to complex function call. 
  1+2  become caddf(1,2) result is complex 3+0i
2*3.14 become cmulf(2,3.14) result is complex 6.28+0i
<a name="docA153">
On the other hand, //real value function
complex4.htm allow user call javascript build-in 
functions. For example call build-in sin() as 
Math.sin(1.2) //this code line OK, answer 0.932 
However, if user call same equation as next 
Math.sin(1+0.2) //get NaN, 1+0.2 is caddf(1,0.2) 
return 1.2+0i, but Math.sin() accept only real. 
Please try next code line 
<a name="docA154">
Math.sin(1+.2+'') //get 0.932 ; complex4.htm see 
calculation has string '', NOT convert 1+.2 to 
complex function call caddf(1,0.2) .
Javascript take over Math.sin(1+.2+'') and change 
to Math.sin('1.2') then change to Math.sin(1.2)
get 0.932. '1.2' is a string, 1.2 is real number.
Math.sin(1+.2+'') work only in Box3, not in Box6.
<a name="docA155">
When user code 
complex operation mix with real value function
please add cgetr() to get real part of 1.2+0i. 
instead of  
Math.sin(Math.PI/3) //get NaN
it is safe to write 
Math.sin(cgetr(Math.PI/3)) //0.8660254037844386
In the error code "Math.sin(Math.PI/3)", real 
valued function sin() receive input [1.047, 0] 
for complex 1.047+0i. BUT real valued function 
sin() expect input number 1.047 not an array.
This caution is at user side. LiuHH cannot help.

<a name="docA156">
cgetr()=Ⓡ() is better than absolute operator |()
If answer is negative real+0i, Ⓡ() work right.

Real value function 
Math.pow(-0.86602540,0.5)=NaN Not_a_Number
answer NaN is correct. Since result is complex
2014-09-19-19-09 here (a309191909_doc)

<a name="docA157">
On 2014-09-19-17-57 add next code lines 
oneline=oneline.replace(/Math.PI/g,'(Math.PI)'); //a309191757
..... //a309191803
to group Math.PI in a parenthesis pair which 
is required in complex4.htm

<a name="docA158">
//2014-09-19-19-51 find Example i3 stop work
//Example i3, need next correction
if(fj==0 //no for,else,while etc
 &&fs==0 //no ',', no '\n' etc
 &&fInd.length==1 //just one element
 &&(fInd[0][0]=='n' //this element is number -1.2
  ||fInd[0][0]=='e')//this element is -1.2e+1
  )fj=-1 //a309211345 
//fj=-1 say not change -1.2 to cnegf(1.2)

<a name="docA159">
Example i3 has 
step=0.05; bgn0=-3.14159265; end0=3.16; 
step and end0 both get real number, but 
bgn0 get complex [-3.14159265, 0], because 
negative sign in "bgn0=-3.14159" triggered 
real to complex conversion action. then 
Example i3 for(z0=bgn0;z0<end0;z0+=step)
read z0= complex bgn0, program stop work.
Correction made at "fj=-1 //a309211345"
Frequently cure one trouble, create another.
If so, update in the future.

<a name="docA160">
what to do to avoid error?
This program 
do complex number/real number calculation. 
Error come from two sources. 
1. equation derivation error. Please see
   and comparison with Andreas Greuer code
2. Parenthesis pair grouping error. 
If equation derivation has error, user cannot 
To avoid parenthesis pair grouping error, user 
write code insist one line one complex operation. 
For example 
write code line 
get answer 0.9999999999999997,2.220446049250313e-16
which is 1+0i. Above red code line has three 
complex operation, two * and one + .
<a name="docA161">
If write one line one complex operation as next 

var s1=csinf('2+i'); var s2=s1*s1; var c1=ccosf('2+i'); var c2=c1*c1; var ans=s2+c2; ans

get same answer.
This method avoid complex4.htm parenthesis pair grouping error. 2014-09-21-16-10 <a name="docA162"> 2014-09-22-16-47 start update 2014-09-22 added COMPLEX gamma function. Before update 2014-09-22 , complex4.htm has real valued gamma function, and symbol Γ(x) link to this real valued gamma function. After update 2014-09-22 , complex4.htm has real valued/complex valued gamma function, symbol Γ(x) link to complex gamma function. ALERT change symbol Γ(x) !! Before 2014-09-22 Γ(x) is gamma_vonKen_real(x) After 2014-09-22 Γ(x) is gamma_Lanczos_cplx(z) Now 2014-09-22 complex4.htm has following gamma functions. <a name="docA163"> factorial_vonKen_real(n) gamma_vonKen_real(x) //gamma(x) before 2014-09-22 loggamma(x) gamma_Lanczos_real(x) factorial_Lanczos_real(n) gamma_Lanczos_cplx(z) factorial_Lanczos_cplx(n) gamma(z) //return gamma_Lanczos_cplx(x) factorial(n) //return factorial_vonKen_real(n) User change n to integer, change x to a real number, change z to a complex '1+2i' paste to Box3, then complex4.htm accept. <a name="docA164"> Are you a programmer? ALL FUNCTION SOURCE CODE ARE RIGHT HERE IN complex4.htm If you are a non-programmer, you can use short symbol Ⓢ('i') for csinf('i') in Box3 and Box6 ONLY. complex4.htm has code convert "Ⓢ('i')" to "csinf('i')" . If reader is a programmer, and want to convert from function gamma_Lanczos_real(x) to function gamma_Lanczos_cplx(z). In new complex function, a programmer MUST write "csinf('i')" and cannot use "Ⓢ('i')" in new complex function. Because there is no conversion! <a name="docA165"> Program source is next 2006-07-08-15-00 LiuHH access received function factorial_vonKen_real(n) function gamma_vonKen_real(x) function loggamma(x) 2014-08-30-04-19 LiuHH access received function gamma_Lanczos_real(z) function factorial_Lanczos_real(n) <a name="docA166"> From 2014-09-12-20-05 convert function gamma_Lanczos_real(z) to complex version. Change real z to complex z On 2014-09-13-10-32 get gamma('i') = (real, imag) = -0.15494982830181045,-0.4980156681183559 Is this value right? Go online check. <a name="docA167"> 2014-09-15-10-00 access get //ALERT! red digits are uncertain!
Γ(complex) value complex4.htm value
Γ(i)=(-1+i)! ~= -0.1549-0.4980i -0.15494982830181045-0.4980156681183559i
Γ(1+i)=iΓ(i) ~= 0.498-0.155i 0.49801566811835634-0.1549498283018106i
Γ(1-i)=-iΓ(-i) ~= 0.498+0.155i 0.49801566811835634+0.1549498283018106i
Γ(0.5+0.5i) ~= 0.8181639995-0.7633138287i 0.8181639995417472-0.7633138287139826i
Γ(0.5-0.5i) ~= 0.8181639995+0.7633138287i 0.8181639995417472+0.7633138287139826i
Γ(5+3i) ~= 0.0160418827-9.4332932898i 0.016041882741676616-9.433293289756033i
Γ(5-3i) ~= 0.0160418827+9.4332932898i 0.016041882741676616+9.433293289756033i
complex4.htm value correctness/accuracy are unknown. User MUST verify from other source. <a name="docA168"> If user test complex4.htm gamma function, please input the following values to Box3 and Box6 Γ('i') Γ('1+i') Γ('1-i') Γ('0.5+0.5i') Γ('0.5-0.5i') Γ('5+3i') Γ('5-3i') complex4.htm INSIST complex value be 'quoted' as a string. 2014-09-22-17-49 stop <a name="docA169"> 2014-09-22-21-33 start LiuHH upload two gamma function curves. gamma_z1.png has the following document purple input a complex unit circle start at (1+0i) go counter clockwise output red line gamma(z) where |z|=1 blue line equal value at 11 33 55 th point gamma('-1+0i') is infinity. 2014-09-14-19-28

//<a name="docA170"> //in //Box3, JS command run next code //Example a309151835 ans0=''; step0=0.05; for(t=0;t<6.3;t=t+step0) { x0=Math.cos(t) y0=Math.sin(t) sign='' if(y0>=0)sign='+' z0=''+x0+sign+y0+'i' ans0+=x0+','+y0+';'+gamma(z0)+'\n' } ans0; //a309151842 //Drop first line "ans0;" which is not data. //copy complex4.htm box4 output data paste to // //Box 11 click [Draw Box 11]

<a name="docA171"> gamma_z2.png has the following document

//2014-09-22-14-33 ans0=''; step0=0.01; for(t=0;t<3.15;t=t+step0) { x0=Math.cos(t) y0=Math.sin(t) sign='' if(y0>=0)sign='+' z0=''+x0+sign+y0+'i' gz0=gamma(z0); lgz0=clogf(gz0); //a309221413 ans0+=x0+','+y0+';'+gz0+';' +lgz0+'\n' } //for(t) ans0; //a309151842 //equal z at 80, 214

<a name="docA172"> Purple half circle is input. Complex z move along purple. Red curve is gamma(z) Blue is log(gamma(z)) Two triangles are equal z pts. Red cross -x axis, blue jump How to draw curve? see another <a name="docA173"> No one verify gamma_z1.png , gamma_z2.png Reader must be careful about the output. If curves are correct. The advantage is that reader follow above code and write your own code, draw your own curve. To save curve, press control key and press print screen key (PrtSc). Open MSPaint paste image and save to a new file. 2014-09-22-21-45 stop <a name="docA174"> 2014-09-29-16-39 update 2014-09-29 made two changes update 2014-09-29 change 1 in function cnegf(c1) add array c3 [[ var c3=[]; //a309290436 c3[0]=-c2[0]; c3[1]=-c2[1]; return i0c2r(c3); //a309290437 return //a209251806 i0c2r() ]] if not use c3, old version function cnegf(c1) will modify input c1 to negative of c1 IF c1 is an array [1.1,2.2]. old version will not modify c1 if c1 is a string '1.1+2.2i'. New version will not modify input in both case. <a name="docA175"> update 2014-09-29 change 2 in function evalSymbEq( //a205250930 inpStr0, // input string, Javascript commands outputBoxID // output location ID plus '.innerHTML' or '.value' ) //9803221250 add code assign fj=-2; to -2 [[ LeftSqB=midlstr.indexOf('['); //a309291535 RiteSqB=midlstr.indexOf(']'); if(fj==0 //no for,else,while etc &&LeftSqB>=0 //midlstr has '[' &&RiteSqB>LeftSqB) //midlstr has ']' fj=-2; //a309291547 ]] if input line is "a1=[1.1,2.2]" NOT convert "[1.1,2.2]" to function call. because it is not need to convert "[1.1,2.2]" to a complex function call. 2014-09-29-16-47 <a name="docA176"> 2014-10-07-21-07 start update 2014-10-08 added Riemann zeta function ζ('2+3i') for complex number. ζ() Equation come from next two video files 2014-03-25-18-28 2014-10-03-14-08 <a name="docA177"> [[ if Real(s)>1 ζ(s)=∑[n=1,∞]{1/n^s} = ∏[p be prime]{p^s/(p^s-1)} if 0<Real(s)<=1 ζ(s)=[1-2^(1-s)]^(-1)∑[n=1,∞]{-1n+1/n^s} if Real(s)<=0 ζ(s)=2s*PIs-1*sin(PI*s/2)*Γ(1-s)*ζ(1-s) 2014-10-01-20-02 ]] <a name="docA178"> function zeta_RobertElder(arg1) real(arg1)>0 section, code follow //2014-09-30-22-34 access function zeta_RobertElder(arg1) real(arg1)<=0 section, code follow above two files. <a name="docA179"> 2014-09-25-10-28 access find 28 Riemann zeta function zeros. In Box3 user get zero by zeta0Str[0] to zeta0Str[27] In Box3 if input czeta(zeta0Str[0]) and if use zeta max loop 10000, output czeta(zeta0Str[0]) -0.0008393606044086161,0.0019320506684319795 Since zeta0Str[0] is a root, answer should be -0.00000000000000001,0.00000000000000002 the answer -0.000839,0.001932 is very poor. <a name="docA180"> 2014-10-03-19-45 LiuHH first time get czeta('i')=[0.003300008286095363,-0.41812732925987966] is it right? or wrong? Goto google but cannot find answer. However, 2014-10-07-10-37 access click "open all" for more example [[ Evaluate for complex arguments: In[1]:= zeta[-1.5+i] Out[1]= 0.0278376-0.0527883i ]] <a name="docA181"> Next use LiuHH program find czeta('-1.5+i') 0.027837559813653774,-0.05278834216992989 2014-10-07-10-51 LiuHH program output OK !!! Please run complex4.htm for fun. Liu,Hsinhan did not attempt to improve effective digits. Reader MUST verify answer number correctness. 2014-10-07-21-35 stop [==] {++}

<a name="docB001"> 2013-04-30-13-57 start On 2013-04-10 Liu,Hsinhan had eye exam appointment with UCLA eye clinic Doctor Bartlett. One day earlier 2013-04-09 LiuHH did not write complex4.htm, let eye relax one day. On 2013-04-10, LiuHH take train from Simi Valley to LAX Union station and take Metro Silver Bus to Gardena Artesia Transit Center. Sister come pick up LiuHH and send LiuHH to UCLA. Sister gave LiuHH a 3T external hard drive (3000 GBytes capacity) in which sister stored 1000GB data, all from utube. Most are <a name="docB002"> math lecture, FamousMathProblems by N.J. Wildberger, Gresham College, MIT 18.02 Multivariable Calculus, Euler, Gauss, Hilbert, Lagrange, Kurt Godel, Laplace etc. physics, Newton, Albert Einstein, Nikola Tesla, quantum mechanics, universe, Cold Fusion, UFO, Crop circle, ancient alien etc, English movies Chinese movies etc. <a name="docB003"> from 2013-04-11 to 2013-04-18 LiuHH watch above video files. 2013-04-19 LiuHH begin write complex4.htm 2013-04-24 sister bring food to LiuHH and LiuHH give copy of UCLA cash receipt $374.50 to sister. 2013-04-29 sister fax cash receipt to UCLA at 310-301-8878, then sister called UCLA at 310-301-8860 make sure UCLA billing office receive fax. Sister ask other side give fax to Jill. See bioge007.htm 2013-04-30-14-48 stop <a name="docB004"> 2013-05-20-16-07 start 2013-05-18 sister come to LiuHH room. Sister bring food to LiuHH and bring utube physics/math video file and movies to LiuHH. 2013-05-20-16-09 stop <a name="docB005"> 2013-05-25-16-24 start This file complex4_vd1_a205251607_why_stop_here.htm is draft file version 131 (vd1) Liu,Hsinhan had trouble. ..... <a name="docB006"> omit <a name="docB007"> omit <a name="docB008"> trouble occur at (near file end) //why program stop here? a205251607 //above code all active, //following code all void. Liu,Hsinhan try to find out why program stop. If LiuHH can fix problem, LiuHH will continue write complex4.htm 2013-05-25-16-35 stop //2013-10-08-00-28 add </pre><br><pre> //2014-09-18-21-19 add <p style=...

<a name="docB009">
2014-09-21-14-10 Next document let LiuHH freeze for two years.
LiuHH believe that javascript cannot handle '1+2i'^'3-4i'
After write
LiuHH write
complex4.htm can handle '1+2i'^'3-4i' need user verify.

2013-06-19-16-38 include next document
Why not Operator Overloading in JavaScript? at noumena
Jan 27, 2009 ... A blog about the JavaScript Infovis Toolkit and other stuff. - 22k - Cached - Similar pages
<a name="docB010">
Cushion Treemaps »
Why not Operator Overloading in JavaScript?
Published by admin on January 27, 2009
in javascript
. Tags: javascript canvas ecma.
Disclaimer: Some of this post arguments are inspired by the great talk by Guy Steele: Growing a Language.
<a name="docB011">
So I was checking out the new JavaScript spec. (ECMAScript 4) lately, and I was very surprised (and disappointed) to see that Operator Overloading wasn’t even accepted as a proposal for ECMAScript 4.
I’ve noticed last year that the proposal was denied by all browser vendors, as you can see in the ECMAScript 4 progress spreadsheet created by John Resig, under the name of “Operator Overloading”.
This is heartbreaking for me… let me explain you why.
Why Operator Overloading (in general)?
Operator Overloading is a special case of polymorphism, in which operators like +, /, *, … can be overloaded by the user.
This is very useful in languages where the user can define special types (or classes), since it allows the developer to use notation that is closer to the target domain, and allows user types to look like types built into the language.
What Guy Steele said about Operator Overloading is that:
“If we grow the language in these few ways, then we will not need to grow it in a hundred other ways; the users can take on the rest of the task.”
To see why, think about these structures:
* 2D, 3D Vectors
* Matrices
* Intervals
* Complex Numbers
* Polar Coordinates
* Rational Numbers
<a name="docB012">
One thing all these structures have in common is that their sum and product operations have a different definition than the one we give to integers.
There’s also an interesting fact about these structures: a lot of people use them, but a lot of people don’t.
For example, Matrices might be used by OpenGL/Direct3D developers, but it’s not very common to use this structure for manipulating the DOM or building AJAX applications.
However, each of these structures must be considered in any programming language.
Adding them all into some standard library might be too much. However, sooner or later, some developer will want to use them.
Here’s the dilemma as exposed by Guy Steele:
“I might say “yes” to each one of these, but it is clear that I must say “no” to all of them!“.
Operator Overloading solves this problem by giving the user the power to overload built-in operations and turn a non-domain specific language into a perfect tool for a developer’s specific needs.
By using Operator Overloading a developer can define operations on any custom type and its use will blend perfectly well into the language.
<a name="docB013">
Wouldn’t be just beatifull if a and b beeing Complex Numbers, we could do this:
1. a + b * c
a + b * c
instead of this? :
1. add (a, multiply (b,c))
add (a, multiply (b,c))
Ok, so now that I made my point about the power of operator overloading, let me explain you why I think this should be more carefully considered by the new JavaScript spec.
Why Operator Overloading in JavaScript?
<a name="docB014">
To see why we should take seriously Operator Overloading in JavaScript, we first have to take a look at what happened to JavaScript in the last few years.
Only one thing happened to JavaScript in the last few years, AJAX.
The XMLHTTPRequest concept was first created by Microsoft, and wasn’t part of the web standards. They first used it in the year 2000, but a couple of years later Mozilla, Safari and Opera were also implementing it.
The standards covered that topic a lot of time after it was already implemented in all major browsers, and AJAX was already in the wild.
One strong aspect of JavaScript that was pretty important and that, IMHO, made the adoption of the “AJAX paradigm” a lot easier, is that JavaScript was already compliant with the “event-driven” programming paradigm, and the use of the XMLHTTPRequest object didn’t add anything new to this paradigm.
Just as callbacks were added to respond to DOM Element’s events, callbacks were used to handle server side answers. Although AJAX changed the way web applications were created, it did that by mantaining the event-driven programming paradigm.
Oh, another thing happened to JavaScript in the last couple of years, Canvas.
<a name="docB015">
Canvas is following the same trend the XMLHTTPRequest object followed. It has been adopted by most browsers (Opera, Gecko, Webkit) and despite Internet Explorer’s efforts to not adopt this new feature, libraries already exist to make Canvas compatible with IE (to a certain point).
A couple of nice libraries that used Canvas were released last year: John Resig published Processing JS. Some other libraries that make use of canvas were also released, one of them is the JavaScript InfoVis Toolkit (my library! :) ).
The number of Canvas related stories really grew at Ajaxian, and there were also new breakthroughs by Opera and Firefox on the implementation of Canvas 3D.
There is one caveat to this Canvas thing though, it doesn’t use extensively the event-driven paradigm. Since all these Canvas implementations are related to Cairo and also take things from OpenGL and Direct3D (this is notably the case for the Canvas’ 3D API), IMO these concepts are more related to a functional programming paradigm than anything else.
I mean, 2D/3D graphics are all about geometrical operations. And geometrical operations are mathematical functions. These concepts might be harder to grasp than the “”AJAX paradigm”", and that’s why the adoption curve won’t be as high as the AJAX one, but there’s no doubt that Canvas developers are a niche.
And do you know which objects/types/classes are related to geometrical computation, Canvas, Canvas 3D, Cairo, OpenGL and Direct3D?
* 2D, 3D Vectors
* Matrices
* Intervals
* Complex Numbers
* Polar Coordinates
<a name="docB016">
That’s exactly what I mean. The next logical step to bring a easier use for Canvas related programming should be operator overloading. This is the one feature that will be extensively used by JavaScript Canvas developers, since they have to deal with points, 2D and 3D coordinates all day.
For a last example, consider an interpolation function between two complex numbers
1. (to.$add(from.scale(-1))).$scale(delta).$add(from)
The same thing with operator overloading would be:
1. from + (to - from) * delta
from + (to - from) * delta
You would make a developer’s life happier.
<a name="docB017">
« A new Canvas Element
Cushion Treemaps »
0 Responses to “Why not Operator Overloading in JavaScript?”
Feed for this Entry
Comments are currently closed.
Hello there, I'm Nicolas Garcia Belmonte, a Computer Science Engineer from the Buenos Aires Institute of Technology, in Argentina. I live in France now.
* JavaScript Information Visualization Toolkit (JIT)
Powered by WordPress2.7 and K21.0-RC7
Entries Feed and Comments Feed
2013-06-19-16-43 done include

<a name="verify01">
2013-03-28-07-07 start 
This page 
solve complex number function problems.
You can improve this page or translate 
this page to other language (both human 
language and program language). 
If you do, Liu,Hsinhan ask one thing: 
please proofread this page and make sure 
all output are correct. If output wrong 
answer, it is worse than not publish at 
all. Within LiuHH own capability, LiuHH 
verify output as much as possible. 

<a name="verify02">
This page has four sections. 
Section A. Non-math complex manipulations.
Section B. Mathematics complex manipulations.
many phase angle to one answer functions.
Mainly trigonometric functions.
Section C. Mathematics complex manipulations.
one complex to many phase angle answer.
Mainly inverse trigonometric functions 
and log function (source of one to many)
Section D. complex number calculator. 
Box3 accept if,while javascript code.
Section A,B,C are test boxes. 
Section D is the main goal of this page.
Section E Box6 not accept if,while 
<a name="verify03">
Back to varify method. 
To varify output, LiuHH include similar 
code from
In section A,B LiuHH answer compare with 
Greuer answer. Error is defined to be 
LiuHH answer - Andreas Greuer answer 
That is taking Andreas Greuer answer as 
Section B first function cexpi(c1) input 
box is yellow color. If input real number 
to yellow box, expect error, see document 
at docA004. Section B last function cdotf(c1) 
input box is red. see document at docA021. 

<a name="verify04">
Section A,B and section C first function 
clogf() complex log compare LiuHH answer 
with Greuer answer. It has the form 
[complex log]  [1.1+1.2i] clogf(c1,nBgn,nEnd) 
LiuHH   0.4872798199990655 , 0.8288490587889791
Greuer  0.4872798199990655 , 0.8288490587889792
Differ  0 , -1.11e-16 ; ☛ error is ZERO 0+0*i ☚

<a name="verify05">
If |difference| is greater than 1.e-8, you 
will see cloud and umbrella ☁☂
Differ 0 , -0.41 ; ━► |error| > 1.e-8 ◄━ ☁☂

If |difference| is smaller/equal 1.e-8, you 
will see music notes  0 , 0  ♩ ♪ ♫ ♬

<a name="verify06">
Click [complex tangent] comparison Differ is
1.6653345369377348e-16 , 4.440892098500626e-16 ; ☛ error is ZERO 0+0*i ☚
If user is new hand, he may ignore e-16 
and conclude LiuHH.ans-Greuer.answer is 
1.665334 , 4.44089 i 
To prevent this careless mistake, code has 
say if error is smaller than 1.e-14 and 
if answer string is longer than 7 bytes 
then add string ☛ error is ZERO 0+0*i ☚
tell user 
1.6653345369377348e-16 , 4.440892098500626e-16
is actually 0+0*i

<a name="verify07">
Section C second cpowf() to end atanh() 
no Greuer answer available. Verification 
change style. 
cpowf() verification use complex log() 
operation to c1^c2 and to LiuHH answer.
That is compare log(c1^c2) with log(LH).
But this comparison is meaningless. 
Because if LiuHH calculate c1^c2 wrong, 
log(c1^c2)-log(LH) is zero, 
can not capture error calculation.
<a name="verify08">
log(c1^c2) change to c2*log(c1). 
c2*log(c1) calculation is different 
from log(LiuHHanswer) calculation. If
output correct, expect answer difference
be zero. However, calculation show that 
c2*log(c1)-log(LiuHHanswer) is very 
different from zero. After exam, find 
out that log() result real part 
|c2*log(c1)| equal |log(LiuHHanswer)| 
but log() result imaginary part, 
img[c2*log(c1)] NOT= img[log(LiuHHanswer)] 
two phase angle differ by 2PI or by 
4PI etc.
<a name="verify09">
cpowf() verification answer has 
real comparison compRE and 
imaginary comparison compIM 
If c1^c2 answer compRE be zero 
and compIM be EVEN number then 
confirmed LiuHH answer is correct. 
Even number mean even*PI, or phase 
shift integer multiple of 2PI, which 
is log operation natural result.
See tute0006.htm 980318a to 980318d
<a name="verify09a">
2013-03-29-10-19 add start 
If calculate (3.1+1.92i)^(2.3+4.5i)
click [c1 power to c2] , get a message 
5.551115123125783e-17 , -2 ☛ error is ZERO 0+0*i ☚ 
although complex (5.5511e-17 -2i) is 
not zero, but here calculation is 
5.5511e-17 , -(2%2)i 
and 2%2 residual is zero, result 
(5.5511e-17 -0i) is zero.
2013-03-29-10-22 add stop

<a name="verify10">
Section C third casin() to end atanh()
all be arc of trigonometric functions 
To verify LiuHH answer, use the reverse 
back to no-arc trigonometric functions.
For example, in section C 
input complex 2.1+1.2i 
click [arcsin(c1)] page show 
LiuHH  1.0124568396604638 , 1.5562723927676187
invFun csinf('1.0124568396604638 +1.5562723927676187i') //ans=2.1+1.2i
invVal 2.1000000000000005,1.199999999999997
<a name="verify11">
invFun provide code of no-arc functions, 
reverse LiuHH answer back to input value.
Let user paste invFun code to Box3, click 
[test box3 command, output to Box4] get 
result should be same as input 2.1+1.2i 
third line box 
invVal 2.1000000000000005,1.199999999999997
do this "paste, click, get answer" for you.
answer 2.1000000000000005,1.199999999999997 
is 2.1000... , 1.19999... is  2.1 , 1.12 
that is input 2.1+1.2i Confirmed correct.

<a name="verify12">
Until now 2013-03-28 LiuHH always find 
LiuHH answer is confirmed. 
2009 confirmed with QCCALC.EXE answer.
2013 confirmed with Andreas Greuer answer 
and confirmed with no-arc functions. Then 
☁☂ never show up, I am thirsty, designed 
section C last [test error (log)] button 
to moisture my lips.
Equation derivation, please refer to
2013-03-28-08-22 stop

<a name="verify13">
2015-02-28-18-05 start 
2015-01-19-15-25 Liu,Hsinhan access
save as Euler-Mascheroni_constant_www.ebyte.it_MathConstants.html
i! = Γ(1+i) = i*Γ(i) (see Gamma function) 
0.498 015 668 118 356 042 713 691 •••
-i 0.154 949 828 301 810 685 124 955 ••• 
2015-02-28-17-56 use
calculate get 
0.498015668118356042713691 •••   
                  -i 0.154949828301810685124955 ••• 
Compare, confirmed complex4.htm answer ok.
2015-02-28-18-08 stop 

<a name="online01">
complex number online resources
2003-07-02-21-21 received qccalc.exe
2009-03-12-20-53 open
2009-03-17-11-12 index page
2009-03-21-19-19 Freeman access complex calculator
2009-03-21-19-39 Freeman access complex calculator

<a name="online02">
2013-03-31-17-10 include next record 
they are all 

2009-05-30-16-26 LiuHH access

2009-11-01-14-50 LiuHH access

2009-11-01-16-43 LiuHH access

2009-11-01-16-50 LiuHH access

2009-11-01-16-54 LiuHH access

2009-11-01-16-57 LiuHH access

2009-11-01-16-59 LiuHH access
2013-03-31-17-22 include above record 

<a name="20130314">
2013-03-14-17-35 in complex4.htm change 
from "principle" error 
 to  "principal"

<a name="matchParenthesis">
2013-11-06-15-40 add next code for reference
i1=oneLInd[i0+2][0]; //i1 is byte location index
i2=i0+2; //i2 is oneLInd[] sequence index
else i2++; //a211021508

<a name="a210261829a07">
in complex4.htm
while(m1>0&&oneLInd[m1][1]!=m3)m1--; //a205092244
m1 is inside [m1][*], m1 is oLI index.
m3 is not inside "oneLInd[][]", m3 is 
byte location index in input equation.

<a name="a210261829a08">
Expresseion m1=oneLInd[m1][0]; is WRONG!
m1 in "[m1]" is oLI  index //OK
m1 in "m1="  is byte index //NO
one kilogram = one meter ? certainly ERROR.
2013-11-06-15-49 done add above doc 


2013-11-28-07-56 open

page 11/116
Exercise 1.11. Write the number 
z =√3 + i 
on polar form and then calculate 
z^13 on standard form.
2 , 0.5235987755982989

2013-11-28-12-08 in
'√' is an error. correct input is

//2013-11-20-00-33 access page
//2013-11-28-17-40 write code
complex_plane_dist=|(z-w); //complex plane length from z to w
unit_sphere_distance=2*complex_plane_dist*facz*facw; //unit sphere distance from z to w
complex_plane_dist; //a211281746

<a name=JSMathFunc>

2009-03-21-19-19 LiuHH access next page
2013-03-11-16-00 include Andreas Greuer code to below.
Complex calculator by Andreas Greuer
Dear Andreas Greuer, Thank you ! 2013-03-28-21-15