Complex Operations

Adam Rumpf, 3/20/2017

Introduction

This program consists of a single Manipulate environment that displays vectors in the complex plane. The blue and red vectors represent inputs, and can be clicked and dragged, while the purple vector represents the output of a chosen mathematical operation or function.

The following operations and functions are included:

Addition (x+y)

Multiplication (x·y)

Sine

Cosine

Tangent

Reciprocal ((x^(-1)))

Square ((x^2))

Exponential ((e^x))

Gamma (Γ(x))

Riemann Zeta (ζ(x))

Geometric Series ((∑_(n=0)^∞)(x^n)) (uses analytic continuation outside of unit disk)

General exponentiation and logarithm have been excluded because they are multivalued for complex numbers.

Code

Initialization

(* plotting limits *)
lim=5;

(* convert real ordered pair to complex number *)
r2c[x_]:=x[[1]]+I x[[2]]

(* convert complex number to real ordered pair *)
c2r[x_]:={Re[x],Im[x]}

(* defining number-coded functions of two complex numbers *)
f[1,x_,y_]:=x+y(* addition *)
f[2,x_,y_]:=x*y(* multiplication *)
f[3,x_,y_]:=Sin[x](* sine *)
f[4,x_,y_]:=Cos[x](* cosine *)
f[5,x_,y_]:=Tan[x](* tangent *)
f[6,x_,y_]:=If[Abs[x]>0,(x^(-1)),0](* reciprocal *)
f[7,x_,y_]:=(x^2)(* square *)
f[8,x_,y_]:=Exp[x](* exponential *)
f[9,x_,y_]:=Gamma[x](* gamma *)
f[10,x_,y_]:=If[x≠1,Zeta[x],0](* Riemann zeta *)
f[11,x_,y_]:=If[x≠1,(1/(1-x)),0](* geometric series *)

(* number of arguments corresponding to each function number *)
args[1]=2;
args[2]=2;
args[3]=1;
args[4]=1;
args[5]=1;
args[6]=1;
args[7]=1;
args[8]=1;
args[9]=1;
args[10]=1;
args[11]=1;

(* background shading for each function number *)
bg[1]={};
bg[2]={};
bg[3]={};
bg[4]={};
bg[5]={};
bg[6]={};
bg[7]={};
bg[8]={};
bg[9]={};
bg[10]={Opacity[0.5],LightBlue,Rectangle[{1,-lim},{lim,lim}],LightRed,Rectangle[{-lim,-lim},{0,lim}],LightYellow,Rectangle[{0,-lim},{1,lim}],Opacity[1.0]};
bg[11]={Opacity[0.5],LightOrange,Disk[],Opacity[1.0]};

(* stores previous y-coordinates *)
prevy={-0.5,2};

Demonstration

Manipulate[Module[{z},
z=c2r[f[mode,r2c[x],r2c[y]]];
If[args[mode]==2,
If[Max[y]<10lim,
prevy=y,
y=prevy;
];
y=prevy,
y={10lim,10lim};
];
Show[Graphics[Join[bg[mode],{PointSize[Large],Blue,Point[x],Arrow[{{0,0},x}]},If[args[mode]==2,{Red,Point[y],Arrow[{{0,0},y}]},{}],{Purple,Point[z],Arrow[{{0,0},z}]}]],PlotRange->{{-lim,lim},{-lim,lim}},Axes->True,AxesLabel->{"Re","Im"}]
],{{mode,1,"operation/function"},{1->"x+y",2->"x·y",3->"sin(x)",4->"cos(x)",5->"tan(x)",6->"(x^(-1))",7->"(x^2)",8->"(E^x)",9->"Γ(x)",10->"ζ(x)",11->"(∑_(n = 0)^∞)(x^n)"}},{{x,{2,0.5}},Locator},{{y,{-0.5,2}},Locator}]