Complex variable functions with
non-principle solution
ABCD
update 2009-11-04
This file is written under MSIE 6.0
Document
Compare
complex number online reference
01
02
03
04
05
This file is personal home work. Output
may contain error. Please verify first.
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 principle value.
One-to-many function output to Box1. Non-principle
value answer no confirmation. You need to verify
first. 9803220737
Proof +1=-1.
if know the mathematics rule leak hole, then one can "proof"
Below is complex function for add/subtract/multiply/division
etc. non-math operation.
;
1
0 =
delete function name, make room for output box
9804130942
Above is complex function for add/subtract/multiply/division etc. non-math operation.
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.
dot product, complex separated by
comma or
';' or
blank
dot product use 〈u, v_conj〉, 〈u_conj, v〉 answer conjugate to each other.
cexpf('3i') = cexpi(3) no need to use "i", no need to use quote. 9805181224
cexpf('1+3i')=cexpi('1+3i') ; cexpf(2)=cexpi('2+0i')
Above function all not output to box1 below.
Below function all do output to box1 below.
Below is one-to-many functions, use +2*n*PI
n is arbitrary integer.
9803151835
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 principle 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()
one-to-many function has +2*n*PI its n range
Box1, answer
Box2, equation doc.
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
http://blog.thejit.org/2009/01/27/why-not-operator-overloading-in-javascript/
This page explain why-not-operator-overloading-in-javascript
Box3 default value is [sin(1+2i)^2+cos(1+2i)^2]
Box4 should get answer: 1+0i
9801022039
Java Script Bible
[[
884 Part IV ✦ JavaScript Core Language Reference
Table 28-1: JavaScript Math Properties
Property Value Description
Math.E 2.718281828459045091 Euler’s constant
Math.LN2 0.6931471805599452862 Natural log of 2
Math.LN10 2.302585092994045901 Natural log of 10
Math.LOG2E 1.442695040888963387 Log base-2 of E
Math.LOG10E 0.4342944819032518167 Log base-10 of E
Math.PI 3.141592653589793116 π
Math.SQRT1_2 0.7071067811865475727 Square root of 0.5
Math.SQRT2 1.414213562373095145 Square root of 2
Because these property expressions return their constant values, you use them in your regular
arithmetic expressions. For example, to obtain the circumference of a circle whose diameter
is in variable d, employ this statement:
circumference = d * Math.PI;
Perhaps the most common mistakes scripters make with these properties are failing to capitalize
the Math object name and observing the case-sensitivity of property names.
Methods
Methods make up the balance of JavaScript Math object powers. With the exception of the
Math.random() method, all Math object methods take one or more values as parameters.
Typical trigonometric methods operate on the single values passed as parameters; others
determine which of the numbers passed along are the highest or lowest of the group. The
Math.random() method takes no parameters but returns a randomized, floating-point value
between 0 and 1 (note that the method does not work on Windows or Macintosh versions of
Navigator 2). Table 28-2 lists all the Math object methods with their syntax and descriptions
of the values they return.
Table 28-2: Math Object Methods
Method Syntax Returns
Math.abs(val) Absolute value of val
Math.acos(val) Arc cosine (in radians) of val
Math.asin(val) Arc sine (in radians) of val
Math.atan(val) Arc tangent (in radians) of val
Math.atan2(val1, val2) Angle of polar coordinates x and y
Math.ceil(val) Next integer greater than or equal to val
Math.cos(val) Cosine of val
Math.exp(val) Euler’s constant to the power of val
Math.floor(val) Next integer less than or equal to val
Math.log(val) Natural logarithm (base e) of val
Math
885 Chapter 28 ✦ The Math, Number, and Boolean Objects
Method Syntax Returns
Math.max(val1, val2) The greater of val1 or val2
Math.min(val1, val2) The lesser of val1 or val2
Math.pow(val1, val2) Val1 to the val2 power
Math.random() Random number between 0 and 1
Math.round(val) N+1 when val >= n.5; otherwise N
Math.sin(val) Sine (in radians) of val
Math.sqrt(val) Square root of val
Math.tan(val) Tangent (in radians) of val
HTML is not exactly a graphic artist’s dream environment, so using trig functions to obtain a
series of values for HTML-generated charting is not a hot JavaScript prospect. Only with the
advent of positionable elements have scripters been able to apply their knowledge of using
these functions to define fancy trajectories for flying elements. For scripters who are not
trained in programming, math is often a major stumbling block. But as you’ve seen so far, you
can accomplish a great deal with JavaScript by using simple arithmetic and a little bit of
logic—leaving the heavy-duty math for those who love it.
Creating random numbers
The Math.random() method returns a floating-point value between 0 and 1. If you design a
script to act like a card game, you need random integers between 1 and 52; for dice, the range
is 1 to 6 per die. To generate a random integer between zero and any top value, use the following
formula:
Math.floor(Math.random() * n)
Here, n is the top number. To generate random numbers between a different range, use this
formula:
Math.floor(Math.random() * (n – m + 1)) + m
Here, m is the lowest possible integer value of the range and n equals the top number of the
range. For the dice game, the formula for each die is
newDieValue = Math.floor(Math.random() * 6) + 1;
Math object shortcut
In Chapter 31, you see details about a JavaScript construction that enables you to simplify
the way you address multiple Math object properties and methods in statements. The trick is
to use the with statement.
In a nutshell, the with statement tells JavaScript that the next group of statements (inside the
braces) refers to a particular object. In the case of the Math object, the basic construction
looks like this:
with (Math) {
//statements
}
Math
886 Part IV ✦ JavaScript Core Language Reference
For all intervening statements, you can omit the specific references to the Math object.
Compare the long reference way of calculating the area of a circle (with a radius of six units)
result = Math.pow(6,2) * Math.PI;
to the shortcut reference way:
with (Math) {
result = pow(6,2) * PI;
}
Though the latter occupies more lines of code, the object references are shorter and more
natural when reading the code. For a longer series of calculations involving Math object properties
and methods, the with construction saves keystrokes and reduces the likelihood of a
case-sensitive mistake with the object name in a reference. You can also include other fullobject
references within the with construction; JavaScript attempts to attach the object
name only to those references lacking an object name. On the downside, the with construction
is not particularly efficient in JavaScript because it must perform a lot of internal tracking
in order to work.
]]
hyperbolic cosine use
0.5*(exp(x)+exp(-x))
hyperbolic sine use
0.5*(exp(x)-exp(-x))
9507211232
2009-04-28-11-24
This file complex2.htm has Gamma function
y(t)=gamma(t)
and has step function
y(t) =
-3.097*stepf(t,-2)*(1-stepf(t,2))*sin(t)+stepf(t,2)*(1-stepf(t,5))*exp(-(t-PI))*sin(t-PI)+stepf(t,5)*(1-stepf(t,8))*(t*t*t/108.75-1)
factorial function
y(n)=factorial(n)
step function
onoff=stepf(t0,bgn0)
if t0<bgn0 return value 0
if t0>=bgn0 return value 1
y(t) = -3.097*stepf(t,-2)*(1-stepf(t,2))*sin(t)+stepf(t,2)*(1-stepf(t,5))*exp(-(t-PI))*sin(t-PI)+stepf(t,5)*(1-stepf(t,8))*(t*t*t/108.75-1)
gate function
onoff=gatef(t0,bgn0,end0)
if t0<bgn0 return value 0
if t0>end0 return value 0
else bgn0<=t0<=end0 return value 1
binomial coefficient
value0=bicof(6,2) //do not use binof(6,2)
ISBN 0-12-059820-5 page 307, line-4
(m) m!
( )= ──────
(n) n!*(m-n)!
above is equation defined if m>=n
below is numerical example
(6) 6!
( )= ────── =15
(2) 2!*(6-2)!
double factorial coefficient
value0=facdb(5)
ISBN 0-12-059820-5 page 545, equation 10.33c
odd integer 7!!=1*3*5*7=105
even integer 6!!=2*4*6=48
2009-04-28-12-03 stop
2009-05-20-13-51 done include JSMathFunc to complex2.htm
<a name="doc01">
This file is personal home work. Output
may contain error. Please verify first.
2009-03-20-13-30 start
This file is complex function. Started at
writing complex polynomial root program
http://freeman2.com/polyroot.htm
used laguer.c from Numerical-Recipes
At first convert header file complex.h
functions from C language to Javascript
<a name="doc02">
During this work, think: why not add more
complex functions? For example
cpowf(c1,c2) complex power function,
rise complex1 to power complex2.
(similar to rise 2 to power 3, 2*2*2)
csinf(c1) complex sine function. etc.
During writing, learn these function
definition and how to derive the result.
Complex function solution has two flavors
One is one_input-to-many_output,
for example
clogf(c1) complex log function
cpowf(c1,c2) complex power function
casin(c1,c2) complex arcsin function
cacos(c1,c2) complex arccos function
etc.
Second flavor is is many_input-to-one_output,
for example
cexpf(c1) complex exponential function.
<a name="doc03">
The key point is that complex function
solution use sine, cosine functions.
trigonometric functions are periodic, that is
for example
sin(PI/4)
sin(PI/4+2*PI)
sin(PI/4+8*PI)
above three expression has three different
input, but identical output. This is
many-to-one example.
Period is 2*PI , for any integer n, add
or subtract 2*n*PI not change trigonometric
function value.
<a name="doc04">
Take exponential for imaginary i*t
Euler formula tell us that
exp(i*t)=cos(t)+i*sin(t)
input t or t+2*n*PI (arbitrary n)
get same answer.
Exponential function is many-to-one function.
Log is reverse of exponential, then
Log function is one-to-many function.
<a name="doc05">
if in 2*n*PI , n=0 answer is called principle
if in 2*n*PI , n!=0 answer is non-principle
During programming, LiuHH (author) hope to
get non-principle solutions. and code with
this property. But if non-principle solutions
correct? It is hard to find non-principle
solutions online, and LiuHH not found one
non-principle solution page. SO
<a name="doc06">
This file complex2.htm has special point,
it supply complex non-principle solutions,
(if answer is right)
This file complex2.htm also has bad point,
it supply complex non-principle solutions,
(if answer is wrong)
<a name="doc07">
LiuHH use qccalc.exe for principle solution
reference.
[[
Steve Moshier's command interpreter V1.3
Functions:
h help hex cmplx re im arg abs conj acos asin atan cos cot exp floor
fac gamma lgamma confhyp erf erfw log pow sin sqrt tan polylog bits
digits dm tm em take save system exit
Variables:
a b c d e f g h j k l m n o p q r s t u v w x y z pi i
Operators:
- , = + - * / ( )
* acos(2.1+1.2*i)
acos(2.1+1.2*i)
5.5833948713443407144728712072799464209407513017838366981793494799469577E-1
-1.5562723927676192854254478768311785590221010493518827169491682385186516E0i
]]
<a name="doc08">
Until writing time (2009-03-20) still not find
non-principle solutions reference.
This file is personal home work. Output
may contain error. Please verify first.
At first upload (2009-03-20) this file is still
not done yet. Still need add new functions.
LiuHH program and learn at same time. Correct
error command whenever find bug.
Thank you for visiting Freeman's site.
Freeman 2009-03-20
2009-03-20-14-05
<a name="doc09">
Steve Moshier's command interpreter V1.3
complex version:qccalc.exe ,
real version:qcalc.exe
2003-07-02-21-21 start download
ftp://ftp.simtel.net/pub/simtelnet/msdos/c/cephes28.zip
You are user #30 of 500 simultaneous users allowed.
2003-07-02-21-37 done download
07/02/2003 09:38 PM 1,906,887 cephes28.zip
06/04/2000 07:20 PM 159,264 QCALC.EXE
06/04/2000 07:20 PM 120,950 QCCALC.EXE
2009-03-21-15-58 record
<a name="doc10">
2009-03-21-16-02
Freeman's web page
http://freeman2.com/complex2.htm
calculate complex function, principle value
compared with qccalc.exe
Reader can download qccalc.exe at
http://freeman2.us/qccalc.zip
139,391 qccalc.zip
complex version: qccalc.exe
real version: qcalc.exe
<a name="doc11">
qccalc.zip has following files
07/04/1996 01:32 PM 1,117 QHEAD.H
07/03/1999 03:53 PM 34,399 QCCALC.C
12/31/1999 02:04 PM 38,489 QCALC.C
06/04/2000 07:20 PM 159,264 QCALC.EXE
06/04/2000 07:20 PM 120,950 QCCALC.EXE
03/21/2009 05:25 PM 2,116 readme_980321.txt
03/21/2009 05:25 PM 1,367 readme_20090321.txt
7 File(s) 357,702 bytes
2009-03-21-16-12
<a name="doc12">
2009-03-22-13-18 start
2009-03-22 change one-line-input-box to
many-line-input-box [Box3, input JS command]
Click [test box3 command] button, program call
evalAll(boxd13.value,'boxd14.value')
First parameter boxd13.value is Javascript command
Second parameter 'boxd14.value' is output
location ID number, in which ['] is a must
boxd13.value no ['], read box3 value
'boxd14.value' has ['] then it is 'boxd14.value'
string itself passed to evalAll().
<a name="doc13">
boxd14 is box4 ID number ".value" indicate
text output. Other choice is 'spanID02.innerHTML'
".innerHTML" indicate HTML language string.
evalAll() can not judge it is text or HTML
string. ".value" and ".innerHTML" must be
supplied by programmer.
Location ID "boxd14" and "spanID02" can be
changed, but ".value" and ".innerHTML" must
be assigned correctly.
evalAll() is whole text evaluator (older
version eyefoot2.htm is line evaluator)
evalAll() allow use [var ww0;]
(old version disallow)
Programming is improved from experience.
Freeman
2009-03-22-13-32
This file is personal home work. Output
may contain error. Please verify first.
<a name="doc14">
2009-03-22-21-41 start
Initial purpose of writing this file
complex2.htm is to provide complex function
definitions for programmer. Page arrangement
is test buttons. If it is possible to change
to general public use complex calculator?
LiuHH think this question for a while.
It is easy to write complex functions. But
it is not easy to write human-equation to
computer-equation convertor.
<a name="doc15">
For example, quadratic equation
human-equation is
[-b+sqrt(b*b-4*a*c)]/(2*a)
[-b-sqrt(b*b-4*a*c)]/(2*a)
computer-equation is
a='1+i'
b='2-i'
c='1.2-0.5i'
cdivf(caddf(cnegf(b),csqrt(csubf(cmulf(b,b),cmulf(4,cmulf(a,c))))),cmulf(2,a))
cdivf(csubf(cnegf(b),csqrt(csubf(cmulf(b,b),cmulf(4,cmulf(a,c))))),cmulf(2,a))
Please copy above five lines and paste to Box3
and click [test box3 command] button. Output to
box4 or to span on page.
If change a,b,c definition to
a=1; b=5; c=6; then get real answer -2, -3
[problem is 1*x*x+5*x+6=0 ; (x+2)*(x+3)=0 ]
<a name="doc16">
If a,b,c contain imaginary i must use ['], example
a='1+i' here '1+i' is string
Computer not accept complex number
but computer accept string.
<a name="doc17">
How to convert human-equation to computer-
equation? At writing time (2009-03-22) LiuHH
do not know. If there is no convertor function
then LiuHH can not claim that this program is
a complex calculator for general public.
On 2009-03-21 LiuHH enter Internet to find
other's complex calculator
2009-03-21-19-19 saved
http://www.greuer.de/JavaScriptComplexCalc.html
and
2009-03-21-19-39 download
http://www.twopaths.com/Calculator/CALCZ.EXE
But no help, greuer.de page no need to convert
from human-equation to computer-equation. User
fill-in numbers in input boxes and get answer.
twopaths.com's CALCZ.EXE is a DOS prompt program
no source code. I do not know how CALCZ.EXE
convert.
<a name="doc18">
Before I write a conversion function, I can say
that this file is for programmer test complex
functions. If general public want to use this
file, then he must use computer equations.
<a name="doc19">
For current version, following error/correct
must be followed.
define a='1+2*i'
define b='3+4*i'
error a+b , correct caddf(a,b)
error a-b , correct csubf(a,b)
error a*b , correct cmulf(a,b)
error a/b , correct cdivf(a,b)
(1+2*i) is wrong, '1+2*i' is right.
<a name="doc20">
Today (2009-03-22) change one line input box to
many line input box3. Change [test box3 command]
button to a small calculator function.
eyefoot2.htm
http://freeman2.com/eyefoot2.htm
has old version. Here complex2.htm has new
version. It has same function as old version
<a name="doc21">
New version is whole text evaluator.
Old version is one-line evaluator.
New version allow [var ww0;] (no '=')
Old version disallow [var ww0;] (no '=')
New version handle complex function.
Old version not handle complex function.
Hope improve in the future.
Freeman
2009-03-22-22-28
This file is personal home work. Output
may contain error. Please verify first.
<a name="doc22">
Note: small calculator use eval()
The author of Javascript Bible criticize eval()
and suggest not to use eval() , small calculator
is a low efficient program. To LiuHH, no matter
how low its efficient is, LiuHH use small-size
calculation, it runs faster than blink my eye.
So LiuHH still love to use small calculator.
2009-03-22-22-35
<a name="doc23">
2009-03-23-14-01 this file complex2.htm
is whole text evaluator, not like
http://freeman2.com/eyefoot2.htm
which is line evaluator.
complex2.htm allow for loop expand to multiple
lines. (eyefoot2.htm require for loop in one line)
But complex2.htm still has limit when write
for loop. That is for() loop body begin '{'
and body end '}' can not occupy one line by
itself.
<a name="doc24">
Below is error example
for(z0=0;z0<end0;z0++)
{ //this line error, this line no '=' and '{' is not a variable
z0=z0+2; //this line has '=' program not print output.
} //this line error, no '=' and '{' is not a variable
z0 //this line OK, since variable z0 has value
<a name="doc25">
Below is correct example
for(z0=0;z0<end0;z0++)
{ z0=z0+2; } // one line has a '=' not read value.
z0
complex2.htm see one line do not have '='
left to '//', then treat left side symbol
as variable and print its value. If it is
'{' or '}' can not read value and cause
error.
2009-03-23-14-14 stop
<a name="doc26">
2009-03-23-15-27 start
In Box3, use variable to define complex number
for example w1="1.2+3.4i" or w1='1.2+3.4i'
both OK, to use w1, one example:
cexpf(clogf(w1,-1))
You can skip variable w1, use complex number
in function directly. In this case
clogf(clogf('2-i')) use ['] OK
clogf(clogf("2-i")) use ["] NO
either ["] or [\"] both conflict with program
structure.
In some case (not here)
[\'] is a replacement for ['] and
[\"] is a replacement for ["] .
2009-03-23-15-35 stop
<a name="doc27">
2009-03-23-17-39 start
Small calculator in next page
http://freeman2.com/eyefoot2.htm
Its example 2 can not be used here complex2.htm
Because example 2 need box5 and box6, both are
not present in complex2.htm.
2009-03-23-17-42 stop
2009-04-12-08-51 note, later added box5, but
not add box6, so eyefoot2.htm example 2 still
can not run in complex2.htm.
eyefoot2.htm box5 is input box
eyefoot2.htm box6 is output box
2009-04-12-08-53 translation here
This file is personal home work. Output
may contain error. Please verify first.
<a name="doc28">
2009-03-24-23-33 start
On 2009-03-24 added hyperbolic tangent function
ctanh(c1)
and in function toCplx(c1) added
[[
//9803241937 use parseFloat(), avoid error
//return number right, return string wrong.
c1[0]=parseFloat(c1[0]);
c1[1]=parseFloat(c1[1]);
]]
added 9803241957 debug output.
added 9803242228 note for parameter usage.
2009-03-24-23-37 stop
added 9803250038 example 6 [9803250854 record]
<a name="doc29">
2009-04-05-16-13 start
start from 2009-03-25
to 2009-04-05
change work to another file, input
China's Gloria Avenue --
Three People's Principle
http://freeman2.com/choos3pp.htm
Target at mainland Chinese,
call for discard communism, and
choose Three People's Principle.
2009-04-12-09-07 translation stop
2009-04-12-10-16 translation start
=====
This file is personal home work. Output
may contain error. Please verify first.
<a name="doc30">
correction make in Chinese version.
<a name="doc31">
2009-04-05-16-46 start
The following display three program in/output
calcz.exe
a=(1,2)
sin(1,2) or
sin(a) both OK
3.165778513216168146740734617191905538379110767891468932289327464304888083804952588449006805651288124E+0
1.959601041421605897070352049989358278436320160184559658801901499163094256502495572330007661333090133E+0
complex2.htm
csinf('1+2i')
3.165778513216168,1.9596010414216063
qccalc.exe
sin(1+2*i)
3.1657785132161681467407346171919055383791107678914689322893274643048881E0
+1.9596010414216058970703520499893582784363201601845596588019014991630943E0i
2009-04-05-16-50 stop
<a name="doc32">
2009-04-05-18-39 start
calcz.exe
complex2.htm
qccalc.exe
each supply what complex functions?
Following is a list.
<a name="doc33">
calcz.exe supply next functions
ABS, ACOS, ASIN, ATAN, CONJG,
COS, COSH, EXP, IMAG, INT, LOG,
LOG10, NINT, REAL, SIN, SINH,
SQRT, TAN, TANH, =, +, -, *,
/, **
where "**" is power function used in Fortran.
for example 2*2*2
hand writing is 23
Fortran code is 2**3
Basic code is 2^3
C language code is pow(2,3)
Javascript code is pow(2,3)
complex2.htm code is cpowf(2,3)
calcz.exe use Fortran command.
=====
<a name="doc34">
complex2.htm supply next functions
non-mathematics complex functions
caddf(c1,c2) //cannot use c1+c2
csubf(c1,c2) //cannot use c1-c2
cmulf(c1,c2) //cannot use c1*c2
cdivf(c1,c2) //cannot use c1/c2
conjf(c1) //input 1+2i output conjugate 1-2i
cnewf(r1,r2) //use (r1,r2) to build new complex
cabsf(c1) //input 1+2i output sqrt(1*1+2*2)=2.23606797749979
csqrt(c1) //input 1+2i output sqrt(1+2i)
cmulr(c1,r2) //complex c1 multiply real r2
cargf(c1) //input 1+2i output phase angle atan2(2,1)=1.1071487177940904
cpolr(c1) //input 1+2i output polar 2.23606797749979*exp(1.1071487177940904*i)
cxryi(c1) //input polar, output Cartesian
cnegf(c1) //input 1+2i output negative -1-2i
cgetr(c1) //input 1+2i output real part 1
cgeti(c1) //input 1+2i output imag part 2
<a name="doc35">
Complex function, many-to-one
cexpf(c1) //exp(c2)=cpowf(2.718281828459045,c2)
csinf(c1) //sin(complex)
ccosf(c1) //cos(complex)
ctanf(c1) //tan(complex)
csinh(c1) //sinh(complex)
ccosh(c1) //cosh(complex)
ctanh(c1) //tanh(complex)
<a name="doc36">
Complex function, one-to-many
clogf(c1,nBgn,nEnd) //complex log function
cpowf(c1,c2,nB,nE) //complex1 rise to power complex2
casin(c1,rtsq01,nB,nE) //complex arcsine
cacos(c1,rtsq01,nB,nE) //complex arccosine
catan(c1,rtsq01,nB,nE) //complex arctangent
asinh(c1,rtsq01,nB,nE) //complex arcsin hyperbolic
acosh(c1,rtsq01,nB,nE) //complex arccos hyperbolic
atanh(c1,rtsq01,nB,nE) //complex arctan hyperbolic
usage of rtsq01,nB,nE please click here
complex2.htm use Javascript language.
=====
<a name="doc37">
qccalc.exe supply next functions
Steve Moshier's command interpreter V1.3
functions
h help hex cmplx re im arg abs conj
acos asin atan cos cot exp floor
fac gamma lgamma confhyp erf erfw
log pow sin sqrt tan polylog bits
digits dm tm em take save system exit
variables
a b c d e f g h j k l m n o p q r
s t u v w x y z pi i
operators
- , = + - * / ()
qccalc.exe use C language.
2009-04-05-18-52 stop
<a name="doc38">
2009-04-06-12-43 start
Below test composite equation
[-b+sqrt(b*b-4*a*c)]/(2*a)
[-b-sqrt(b*b-4*a*c)]/(2*a)
complex2.htm cannot use a+b, a-b, a*b, a/b
a='1+i'
b='2-i'
c='1.2-0.5i'
cdivf(caddf(cnegf(b),csqrt(csubf(cmulf(b,b),cmulf(4,cmulf(a,c))))),cmulf(2,a))
-0.49871379606640475,-0.2049128506590332
cdivf(csubf(cnegf(b),csqrt(csubf(cmulf(b,b),cmulf(4,cmulf(a,c))))),cmulf(2,a))
-0.0012862039335952424,1.7049128506590332
<a name="doc39">
2009-04-06-12-47
qccalc.exe
a=1+i
b=2-i
c=1.2-0.5*i
(-b+sqrt(b*b-4*a*c))/(2*a)
-4.9871379606640473563866570556370684738722387763883059254327549755186368E-1
-2.0491285065903326325340726687903612040517774044027596304795823691430737E-1i
(-b-sqrt(b*b-4*a*c))/(2*a)
-1.2862039335952643613342944362931526127761223611694074567245024481363180E-3
+1.7049128506590332632534072668790361204051777404402759630479582369143074E0i
<a name="doc40">
2009-04-06-12-50
calcz.exe
a=(1,1)
b=(2,-1)
c=(1.2,-0.5)
(-b+sqrt(b*b-4*a*c))/(2*a)
-4.987137960664047356386657055637068473872238776388305925432754975518636820186780956831424960377189052E-1
-2.049128506590332632534072668790361204051777404402759630479582369143073745090780190279191497584299845E-1
(-b-sqrt(b*b-4*a*c))/(2*a)
-1.286203933595264361334294436293152612776122361169407456724502448136317981321904316857503962281094768E-3
1.704912850659033263253407266879036120405177740440275963047958236914307374509078019027919149758429985E+0
<a name="doc41">
2009-04-06-12-54
qccalc.exe and calcz.exe accept human equation
[-b+sqrt(b*b-4*a*c)]/(2*a)
[-b-sqrt(b*b-4*a*c)]/(2*a)
But complex2.htm cannot.
All three get same answer, but
complex2.htm has only 15 digit precision
qccalc.exe has 70 digit precision
calcz.exe has 100 digit precision
complex2.htm offer principle and non-principle answers
qccalc.exe offer principle answer
calcz.exe offer principle answer
2*n*PI in which if n=0 the answer is principle
if n NOT= 0 answer is non-principle.
N must be integer, positive or negative both OK.
2009-04-06-13-25
<a name="doc42">
qccalc.zip
http://freeman2.us/qccalc.zip
CALCZ.EXE
http://www.twopaths.com/Calculator/CALCZ.EXE
This file is personal home work. Output
may contain error. Please verify first.
<a name="doc43">
2009-04-08-10-11 start
one-to-many complex function are the following
clogf(), clogfMan()
cpowf(), cpowfMan()
casin(), casinMan()
cacos(), cacosMan()
catan(), catanMan()
asinh(), asinhMan()
acosh(), acoshMan()
atanh(), atanhMan()
Left column are all calculation functions
Right column are all manager functions,
manager handle input/output
All calculation functions can be reused by
other programmer.
All manager functions other programmer may not
need, because other programmer may use different
input/output interface.
When call calculation function without nBgn,nEnd
calculation function default return principle
answer, that is nBgn=nEnd=0
Manager function default return 19 answers
for nBgn=-9;nEnd=9
<a name="doc44">
Calculation function use default nBgn=nEnd=0
that is LiuHH's main intention, code is
if((nBgn+'')=='undefined'
|| isNaN(nBgn)
)
var nBgn=0;
<a name="doc45">
Manager function default return 19 answers
code is
var nBgn=-9;
var nEnd=+9;
Manager function has no influence to other
programmer.
2009-04-08-10-24 stop
<a name="doc46">
2009-04-08-14-57 start
complex variable functions generally mean
arbitrary math functions.
complex variable functions in complex2.htm
mean trigonometric/log/exp math functions.
For example,
define
z=x+i*y; i=[0,1]=sqrt(-1)
w(z)=u(z)+i*v(z)
u(z)=x*x*x-3*x*y*y
v(z)=3*x*x*y-y*y*y
then
w(z)=(x*x*x-3*x*y*y)+i*(3*x*x*y-y*y*y)
is complex variable functions taught in
class room. But this w(z) is not
trigonometric/log/exp math functions
complex2.htm can not solve for w(z).
2009-04-08-15-09 stop
<a name="doc47">
2009-04-08-15-23 start
Imaginary unit 'i' has two definitions
definition one i=[0,1] , better, ordered pair
definition two i=sqrt(-1) worse, popular def.
Because
definition one require second number be +1
definition one not allow second number be -1
definition two i=sqrt(-1) and -i=sqrt(-1)
mix up, both i*i=-1 and (-i)*(-i)=-1
Based on definition two, some one 'proof'
+1=-1
2009-04-08-15-28 stop
<a name="doc48">
2009-04-08-22-49 start
sqrt(+1)/sqrt(-1) = sqrt(+1)/sqrt(-1)
right side let sqrt be common to numerator
and denominator, get
sqrt(+1)/sqrt(-1) = sqrt[(+1)/(-1)] here error
then
1/i = sqrt[-1] = i
1 = i*i = -1 error
Please use definition one
Please discard definition two
2009-03-12-22-47 access next page
http://mathforum.org/library/drmath/view/64564.html
2009-04-08-22-52 stop
<a name="doc49">
notes for Chinese version, why update 2009-04-12
<a name="doc50">
2009-04-12-14-45 start
some problem need to do it by two steps
for example
2009-03-17-11-05 received page
http://math.asu.edu/~kuiper/462files/Complex.pdf
exercise (b)
Find (1 + i)^(i^0.5)
complex power function give multiple solutions.
first power (i^0.5) give two solutions
(i^0.5)=
0.7071067811865476+0.7071067811865475i
or
-0.7071067811865475-0.7071067811865476i
above step one
below step two
second power (1 + i)^(i^0.5) give infinity many solutions
principle
(1+i)^(0.7071067811865476+0.7071067811865475i)=
Below is answer for n=0, n=0 is principle value answer.
0.5106227289869875+0.5262040275982908i
non-principle
(1+i)^(-0.7071067811865475-0.7071067811865476i)=
Below is answer for n=0, n=0 is principle value answer.
0.949772688683169-0.9787543438957987i
2009-04-12-14-52 stop
<a name="doc51">
2009-04-13-11-26 start
[update 2009-04-13] is to add control button
This page has
[Inp box size] and [Out box size] two buttons.
Allow change box size. But [function name] take
extra space. Now add
1 0 = delete function name, make room for output box 9804130942
allow user delete function name, assign longer
box size.
During programming, LiuHH always consider user's
convenient as important factor. For example,
one-to-many function has +2*n*PI its n range [-9 +9]
If programmer put two boxes, one for start n value,
one for end n value. This arrangement is easier
for programmer, but user must input data to two
boxes. LiuHH prefer spend more time to write
function read2Npi(arg01)
to get two n values from one box.
[update 2009-04-13] add
<meta name="author"
content="Liu, HsinHan">
2009-04-13-11-36 stop
2009-04-13-15-49 five replacement to
trigonometric functions
<a name="doc52">
2009-04-13-18-33 add Gamma function
and step function,
let small calculator (Box3) be more powerful.
2009-04-13-18-40
ISBN 978-0-521-54677-5 page 165 last line say
Γ(2λ)*Γ(1-2λ)
=
_Π__
sin(2Πλ)
right side of above equation refer back to
page 158 equation 10.8
t=∞
∫
t=0
_1_
(1+y)
*
_dy_
(y)2λ
=
_Π__
sin(2Πλ)
------- (p158 eq.10.8)
require 0<λ<0.5
(Following default box width are 520, 280)
If change text size, need change box width
see outer frame
0
1
;
see inner frame
0
1
When read to page 165 , get the idea,
I should add Gamma function definition in complex2.htm
then I can verify page 165 last line equation.
2009-04-13-19-00 stop
<a name="doc53">
2009-04-13-19-14 start
paste next three lines to Box3, then click
[test box3 command], output to box4.
[[
lambda=0.2; //require 0<lambda<0.5
gamma(2*lambda)*gamma(1-2*lambda) //two equation, same answer.
PI/sin(2*PI*lambda) //all real, it is ok to use [*] 9805181618
]]
2009-04-13-19-17 stop
<a name="doc54">
2009-05-18-13-46 start
[update 2009-05-18] add binomial coefficient
value0=bicof(6,2)
add double factorial coefficient
value0=facdb(5)
Please click Java Script Math Functions<a name="doc55">
[update 2009-05-18] add cexpi(c1)
Let exp(aa*i) be written as cexpi(aa)
instead of cexpf(aa+'i')
[update 2009-05-18] add examples 7, 8, 9,10,11
Assume k is integer variable and i = sqrt(-1)
Assume j, m are integer constants.
<a name="doc56">
Example 7, 8 verify exp(2*PI*i*j*k/m)
k=0, k=1 ... k=m-1 total m terms, its sum is zero.
Example 7 use complex function to get answer.
Example 8 use real function to get answer.
For example j=7, m=5, (j/m=7/5=1.4 is not an integer)
k=0,1,2,3,4
exp(0*7*(2*PI/5)*i)
+exp(1*7*(2*PI/5)*i)
+exp(2*7*(2*PI/5)*i)
+exp(3*7*(2*PI/5)*i)
+exp(4*7*(2*PI/5)*i)
=0
When j/m=7/5=1.4 is not integer
One cycle 360 degree, equal divide to five (m)
smaller angles. k run from zero to four, a full
cycle. Create five complex vectors. These five
vectors form a equal_angle-equal_length pentagon.
If add five vectors. They form a close polygon.
That is net sum is zero.
<a name="doc57">
For example, j=10, m=5, (j/m=10/5=2 is integer)
k=0,1,2,3,4
exp(0*10*(2*PI/5)*i)
+exp(1*10*(2*PI/5)*i)
+exp(2*10*(2*PI/5)*i)
+exp(3*10*(2*PI/5)*i)
+exp(4*10*(2*PI/5)*i)
=5 (= m)
Above j/m=10/5=2 is an integer.
One cycle 360 degree, five(m) equal division.
k start from zero to four, go over one cyle.
Create five vectors. Each vector start from
(0,0). Each vector end at (1,0). Because
k*10*(2*PI/5) = k*(10/5)*(2*PI)
= k*2*(2*PI) = k*4*PI
exp(k*4*PI*i)=cos(0)+i*sin(0)=1+i*0=1
No matter how k change k*4*PI is always integer
multiple of 720 degree. Result vector stay on
x axis. k go around one cycle, create five vectors.
Five (1,0) add together get number 5 (m).
This is an easy problem like an elementary school
problem.
2009-05-18-14-21 here
<a name="doc58">
Example 9 double factorial coefficient
value0=facdb(5)
ISBN 0-12-059820-5 page 545, equation 10.33c
odd number 7!!=1*3*5*7=105
even number 6!!=2*4*6=48
Example 10 binomial coefficient
value0=bicof(6,2) //do not use binof(6,2)
ISBN 0-12-059820-5 page 307, line-4
(m) m!
( )= ---------
(n) n!*(m-n)!
<a name="doc59">
When write example 7, LiuHH think what to do
if use variable for a complex number input?
If use cexpf('2+3i') no problem, but
assume aa is a variable for real number
assume bb is a variable for imag. number
complex number variable expression is aa+bb*i
Can not use cexpf('aa+bb*i') because aa,bb not
change to number.
Can not use cexpf(aa+bb+'i') because short [+'+']
Can not use cexpf(aa+"+"+bb+"i") because ["]
comflict with program.
MUST use cexpf(aa+'+'+bb+'i') 9805181306
Example 11 test complex number variable expression.
2009-05-18-14-27 stop
<a name="doc60">
2009-05-18-15-56 start
[update 2009-05-18] add
step function stepf(t0,bgn0)
stepf(t,3) if t<3 get 0
stepf(t,3) if t>=3 get 1
(1-stepf(t,3)) if t<3 get 1
(1-stepf(t,3)) if t>=3 get 0
[update 2009-05-18] add
gate function gatef(t0,bgn0,end0)
gatef(t,3.2,5.6) if t<3.2 get 0
gatef(t,3.2,5.6) if t>5.6 get 0
gatef(t,3.2,5.6) if 3.2<=t<=5.6 get 1
2009-05-18-15-59 stop
<a name="doc61">
"doc61" is document in Chinese, explain what
change made between 2009-05-18 and 2009-05-20.
2009-05-20-13-30 start update complex2.htm
2009-05-20-16-15 done update
[update 2009-05-18] is date for Chinese version
complex1.htm
2009-05-20 update English version by copy and
translate from Chinese page.
<a name="doc62">
2009-11-02-16-30 start
update 2009-11-02 do two points.
First, add complex dot product function.
Please see source file, find time stamp
from 9811021100 to 9811021230
<a name="doc63">
<a name="doc64">
update 2009-11-02 second point,
in box3 use command
[[
for(z0=bgn0;z0 < end0;z0+=step)
{
x=18*cos(z0)-3*cos(18*(z0+0.34)/2);
y=18*sin(z0)-3*sin(18*(z0+0.34)/2);
oupStr+=x+", "+y+"\n";
}
]]
was error before, because isolated '{'
and '}' was not allowed. Now add code
(see source file, find time stamp from
9811021025 to 9811021046)
to detect isolated '{' and '}'. Program
stay away from these no variable lines.
<a name="doc65">
second point improvement let other user
(other than author LiuHH) write code
more comfortable.
[ Before must write
" { dummy=0; " or
" dummy=0; } "
for myself use, it is ok. But send to
Internet, for public use, it is better
add few more line code to relief from
the dummy code.
]
2009-11-02-17-03 stop
<a name="doc66">
2009-11-04-12-51
update 2009-11-04 add code to convert
input box3 value from Unicode to ANSI
code. User may copy equation from on-
line html file or pdf file. There is
possibility that copied equation has
Unicode in it, but complex2.htm read
only ANSI code. Avoid surprise error
output, LiuHH add code at two points
First add alert if read Unicode.
Please see source file at "9811031913"
Second add
function uniToAnsi2(inp0) // 9811041202
auto correct box3 value. Please see
source file at "uniToAnsi2(" and
document at "9811041142"
2009-11-04-12-57 stop
<a name="doc67">
2009-11-04-19-36 start
Improvement made at doc64 allow
[[
for(z0=bgn0;z0 < end0;z0+=step)
{
x=18*cos(z0)-3*cos(18*(z0+0.34)/2);
y=18*sin(z0)-3*sin(18*(z0+0.34)/2);
oupStr+=x+", "+y+"\n";
} // this line no alphabet
]]
be error-free.
Method is to read each line and detect
if there is alphabet in that line?
If a line has no alphabet, like above
[[
} // this line no alphabet
]]
then not to print its output, because
no alphabet, then no variable,
no variable then no need output.
Today, 2009-11-04 found program stop
calculate a line like
1+2
because no alphabet !
Now change variable hasAlpha to alphaDigi
to monitor both alphabet and digit.
After correction, program run normally.
2009-11-04-19-44 stop
This file complex variable functions
Created on 2009-02-24
Chinese version first upload 2009-03-20
Chinese done version upload 2009-04-06
English version start translation on 2009-04-09-17-14
English version done translation on 2009-04-12-11-20