-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEULER'S EQUATION
More file actions
144 lines (105 loc) · 4.25 KB
/
EULER'S EQUATION
File metadata and controls
144 lines (105 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# LINEAR ALGEBRAIC MANIPULATION OF IMAGES IN R:
points = c(1+1i, 1.1+1.1i, 1.2+1.2i, 1.3+1.3i, 1.4+1.4i, 1.5+1.5i,
1.6+1.6i, 1.7+1.7i, 1.8+1.8i, 1.9+1.9i, 2+2i,
1.1+1i, 1.1+0.9i, 1.1+0.8i, 1.1+0.7i, 1.1+0.6i, 1.1+0.5i,
1.1+0.4i, 1.1+0.3i, 1.1+0.2i, 1.1+0.1i, 1.1+0i,
1.2+0i,1.3+0i,1.3+0i,1.4+0i,1.5+0i, 1.6+0i, 1.7+0i,
1.8+0i,1.9+0i,2+0i,
1.7+0.1i, 1.7+0.2i,1.7+0.31i,1.7+0.4i, 1.7+0.5i,
1.8+0.5i)
points2 = c(2.1+1.9i, 2.2+1.8i, 2.3+1.7i, 2.4+1.6i, 2.5+1.5i,
2.6+1.4i, 2.7+1.3i, 2.8+1.2i, 2.9+1.1i, 3.0+1.0i,
2.9+1i,2.9+0.9i,2.9+0.8i,2.9+0.7i,2.9+0.6i,2.9+0.5i,
2.9+0.4i,2.9+0.3i,2.9+0.2i,2.9+0.1i,2.9+0i,
2.8+0i,2.7+0i,2.6+0i,2.5+0i,2.4+0i,2.3+0.0i,2.2+0.0i,
2.1+0i,2.0+0i,1.9+0i,
2.2+0.1i,2.2+0.2i,2.2+0.3i,2.2+0.4i,2.2+0.5i,
2.1+0.5i,2.0+0.5i)
# Horizontal and vertical flips:
plot(points, xlim = c(-4.5,4.5), ylim = c(-4.5,4.5), pch = 19,
col = "tan1",
ylab="Imaginary axis", xlab="Real axis",
main="Horizontal and vertical flip")
points(points2, pch=19, col="tan3")
abline(h=0, v=0)
points(- Re(points) + (1i * Im(points)),
pch=19, col="tan1")
points(- Re(points2) + (1i * Im(points2)),
pch=19, col="tan3")
points(Re(points) + (-1i * Im(points)),
pch=19, col="tan1")
points(Re(points2) + (-1i * Im(points2)),
pch=19, col="tan3")
# Tranlating and scaling:
# Replotting the initial points first...
plot(points, xlim = c(-4.5,4.5), ylim = c(-4.5,4.5), pch = 19,
col = "tan1",
ylab="Imaginary axis", xlab="Real axis",
main="Translating and scaling")
points(points2, pch=19, col="tan3")
abline(h=0, v=0)
# We add -4 + 2.5i to every point, which will move the picture
# to the left 4 points and up 2.5:
points((-4 + 2.5i) + c(points, points2), pch=19, col=5)
# Now we enlarge the image 2x at the same time that we move it down
# and to the left:
points(2 * ((-2.8 + -1i) + c(points, points2)), pch=19, col=4)
# Inverting:
# We start off replotting:
plot(points, xlim = c(-4.5,4.5), ylim = c(-4.5,4.5), pch = 19, col = 10,
ylab="Imaginary axis", xlab="Real axis",
main="90 degree rotation and inverting")
points(points2, pch=19, col=4)
abline(h=0, v=0)
# We multiply all points by -1, meaning Re. and Im. parts alike:
points(-1 * points, pch = 19, col = 10)
points(-1 * points2, pch = 19, col = 4)
# 90 degree rotation:
# Multiplying by i will turn the Re. part into the Im., and the
# Im. part into Re.:
points(1i * points, pch = 19, col = 10)
points(1i * points2, pch = 19, col = 4)
# We can now rotate at smaller increments:
# Plotting first the initial object:
combo <- c(points,points2)
plot(combo, xlim = c(-5,5), ylim = c(-5,5), pch = 19, col = 2,
main="Rotations", xlab= "Real Ax", ylab="Im. Ax.")
abline(h=0, v=0)
# The rotation formula that follows partitions the 2pi circumference
# in 200 parts, and then rotates the image at different increments
# in these partitions. Also, it enlarges the image 1.5x:
for (n in seq(20, 180, 40)){
rot_points <- 1.5 * exp(n * 1i * (2*pi / 200)) * combo
points(rot_points, pch = 19, col="steelblue4")
}
# Stops: Fractions of the circle: 2pi / n
# Euler's equation: e^i*x = cos (x) + i sin (x)
f <- function(stops){counts <- 1:stops; exp(counts * 1i * (2*pi / stops))}
stops = 20
plot(f(stops), pch = 20, col='tan4', main = "Euler's Identity",
ylab = "Imaginary axis", xlab = "Real axis")
stops = 1000
plot(f(stops), pch = 19, col = 'tan4', cex = 0.3,
main = "Euler's Identity",
ylab = "Imaginary axis", xlab = "Real axis")
fun <- function(stops){
counts <- 1:stops
(0.1 * counts) * exp(counts * 1i * (2*pi / stops))
}
plot(f(stops), pch = 19, col = 'tan4', cex = 0.1,
xlim=c(-10,10), ylim=c(-10,10),
main = "Euler's Identity",
ylab = "Imaginary axis", xlab = "Real axis", type = 'n')
for(i in seq(50, 100, 5)){
points(fun(i), pch = 20, col = i)
}
fun <- function(stops){
counts <- 1:stops
(1 - (0.05 * stops)) * exp(counts * 1i * (2*pi / stops))
}
plot(f(stops), pch = 19, col = 'tan4', cex = 0.1,
main = "Euler's Identity",
ylab = "Imaginary axis", xlab = "Real axis", type = 'n')
for(i in 20:40){
points(fun(i), pch = 19, cex = 0.5, col = i)
}