You are on page 1of 16

Applied Mathematics

MAM1044/MAM1043H
Chloe Sole
SLXCHL001
October 9, 2015

Sunflowers, Vincent Van Gogh, 1888, The National Gallery

Contents
1 Sunflower
1.1 Question: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Code and Results . . . . . . . . . . . . . . . . . . . . . . . . . . .

6
6
6
7

2 Fractal
10
2.1 Question . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2 Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Code and Results . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 Charge on Capacitor
12
3.1 Question . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Code and Results . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Abstract
Question 1:
Sunflower Seeds
Sunflower seeds form in the Fibonacci sequence. To mathematically plot
the layout of a sunflower head we treat each seed as a position vector.
Then one can plot them using their distance from the center and theta,
the angle of incidence from a decided axis, where the length is defined as

n and theta dn=180 . n is the number of the seed which you are
defining and d is your angle of divergence between any two successive
seeds.

Figure 1: Sunflower seeds with an angle of divergence between any two successive
seeds being 137.51 and 137.61
As you can see from the above figure a small change in the angle of
divergence results in a completely different plot pattern.
Question 2:
Fractal
Fractals are beautiful structures, images or anything really thats
individual parts are the same as the whole just on a smaller scale. This
beautiful recursive property of fractals make them much easier to model.
Fractals occur in nature as you can see in Figure 2.

Figure 2: Ferns are an example of a visible reoccurring pattern in nature.


3

A fractal can be plotted using a set of mathematical equations and


would become more detailed with and increased number of iterations.
Given:
xk+1 = yk (1 + sin0.7xk ) 1.2absxk
yk+1 = 0.21 xk
and
x0 = y0 = 0
If one plots the above equations for k being limited to a maximum value
of 100000 then we get the fractal seen in Figure 3 below.

Question 3:
Charge and Time

Figure 3: A circuit diagram of a resistor (R1 ), capacitor (C1 ) and battery (V)
connected in series.
The capacitor in the above diagram begins to charge at time = 0. This
means that at time = 0 there is no accumulated charge on the capacitors
but as time increases the one disk of the capacitor will accumulate
electrons and become inherently negative whereas the other disk will
become increasingly positive.
The charge accumulated on the capacitors disks follows the
mathematical equation below:
Q(t) = CV (1 et/RC
Thus plotting time (x) versus charge (y) we get:

Chapter

Sunflower
1.1

Question:
The arrangement of seeds in a sunflower head follows
a fixed
mathematical pattern. The (nth ) seed is at position r = n, with
angular co-ordinate dn=180 radians, where d is the constant angle of divergence (in degrees) between any two successive seeds, i.e.
between the nth and (n + 1)th seeds. A perfect sunflower head is
generated by d = 137.51 . Write a program to plot the seeds; use
a circle for each seed. A remarkable feature of this model is that
the angle d must be exact to get proper sunflowers. Experiment
with some different values, e.g. 137.45 (spokes, from fairly far out),
137.65 (spokes all the way), 137.92 (Catherine wheels) and plot
your results.

1.2

Solution

Sunflower seeds form in the Fibonacci sequence. To mathematically plot


the
layout of a sunflower head given that the (nth ) seed is at position r = n with
angular co-ordinate dn=180 radians, where n is the number of the seed
which you are defining and d is your angle of divergence between any two
successive seeds, we can treat each seed as being a position vector written in
polar co-ordinates. Polar co-ordinates are a form of notation which allows a
position vector
p ~v = xex + y ey to be written in terms of its
magnitude= x2 + y 2 , which in this case is r, and the angle it makes with the
positive x axis. Setting the origin of our
axes to the center of the sunflower our
first seed will be at position n=1, so r = 1 = 1, and theta =
(137.51 )1=180 radians we plot the location of each seed in the head.
To solve this in terms of MATLAB there are three main algorithms that I
would use. The first algorithm is the most time efficient one being that you
create n being an element of 1 to 750 and then defining theta as being
(137.51 )n=180. Doing this theta becomes an array
of numbers as it has a
value for each value of n. Then we define r as being n. This also creates r
being an array of numbers one for each value of n.
The second algorithm is less time efficient but it does however result in the
automatic sequential coloring of the points in an ordered fashion allowing one
to see patterns within the sunflower head more easily. We start this algorithm
by instantiating a variable n to 1. Then ensuring that MATLAB knows to not
refresh the graph for each individual point we define a while loop that will run
until n is 1000. Then while in the loop we calculate the value of theta and r
according to that specific n value at that point, plot it and then increment n
by one and begin the loop once more until n reaches 1000. When n reaches
1000 the loops condition will no longer be true and therefore will not execute
the enclosed code anymore.
The last algorithm I would use to solve this problem is similar to the second
one in terms of time efficiency and they both produce the same colorful plot
due to the use of figure; hold on;. For this algorithm I used a for loop in the
place of the while loop so in basic structure it changed minorly.
6

1.3

Code

and

Results

Version 1:

Figure 1.1: Sunflower head with the golden angle of divergence of 137.51

Figure 1.2: Sunflower heads with angles of 131.51 and 138.51 and 137.61

n=1:1:700;
d=137.51;
theta = pi*n*d/180;
r = sqrt(n);
polar(theta,r,'o')

Version 2

Figure 1.3: Sunflower head with the golden angle of divergence of 137.51

Figure 1.4: Sunflower heads with angles of 90.45 and 10 and 190.45

figure; hold on;


n=1;
d=137.51;
while n<1000,
theta = pi*n*d/180;
r = sqrt(n);
polar(theta,r,'o')
n = n+1;
end

Version 3

Figure 1.5: Sunflower head with the golden angle of divergence of 137.51

Figure 1.6: Sunflower heads with angles of 90.45 and 10 and 190.45

figure; hold on;


d=137.51;
for n=1:1000,
theta = pi*n*d/180;
r = sqrt(n);
polar(theta,r,'o')
end

Chapter

Fractal
2.1

Question
A rather beautiful fractal picture can be drawn by plotting the
points (xk ; yk ) generated by the following difference equations
xk+1 = yk (1 + sin0.7xk ) 1.2absxk
yk+1 = 0.21 xk
and
x0 = y0 = 0
Write a program to draw the picture (plot individual points; do not
join them).

2.2

Solution

To solve this problem used a for loop to create an array of numbers for
coupled co-ordinates. and then plotted the entire array at the end to be most
time efficient. Another algorithm could be used that would make use of a
while loop in place of the for loop.
Potting the above equations in the question produces a fractal like plot
however if you plot these equations:
xk+1 = yk ((1 + sin0.7xk ) 1.2absxk )
yk+1 = 0.21 xk
and
x0 = y0 = 0
then you end up with a real fractal which always looks the same no matter
how far you zoom in.

2.3

Code

and
Version 1:

10

Results

x = zeros(1, 100000);
y = zeros(1, 100000);
for k = 2:100000
x(k)= y(k-1)*(1+sin(0.7*x(k-1)))-1.2*abs(x(k-1));
y(k)= 0.21-x(k-1);
end
plot(x,y,'.')

Version 2:

x = zeros(1, 100000);
y = zeros(1, 100000);
for k = 2:100000
x(k)= y(k-1)*((1+sin(0.7*x(k-1)))-1.2*abs(x(k-1)));
y(k)= 0.21-x(k-1);
end
plot(x,y,'.')

11

Chapter

Charge
3.1

on

Capacitor

Question
When a resistor (R), capacitor (C) and battery (V ) are connected
in series, a charge Q builds up on the capacitor according to the
formula Q(t) = CV (1et/RC , if there is no charge on the capacitor
at time t = 0. The problem is to monitor the charge on the capacitor
every 0:1 seconds in order to detect when it reaches a level of 8 units
of charge, given that V = 9;R = 4 and C = 1. Write a program which
displays the time and charge every 0:1 seconds until the charge first
exceeds 8 units (i.e. the last charge displayed must exceed 8). Once
you have done this, rewrite the program to display the charge only
while it is strictly less than 8 units.

3.2

Solution

For the first part of the question I used a while loop to repeat code that
calculates the value for q incrementing the value for time by 0.1 each loop. At
the point at which q either becomes 8 or exceeds 8 the while loop will end. We
then just insert a copy of the code that we are repeating so that it executes it
once more after the loop. Thus producing the results showing q until the first
value that exceeds 8.
The second part is exactly the same just without the copy of the repeated
code outside of the while loop so it just eliminates the one q value that makes
the while loop invalid thus the results produced will be strictly less than 8.

3.3

Code

and
First part of the question:

At time t=0 Q(t)=0


At time t=1.000000e-01 Q(t)=2.222108e-01
At time t=2.000000e-01 Q(t)=4.389352e-01

12

Results

At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At

time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time

t=3.000000e-01
t=4.000000e-01
t=5.000000e-01
t=6.000000e-01
t=7.000000e-01
t=8.000000e-01
t=9.000000e-01
t=1.000000e+00
t=1.100000e+00
t=1.200000e+00
t=1.300000e+00
t=1.400000e+00
t=1.500000e+00
t=1.600000e+00
t=1.700000e+00
t=1.800000e+00
t=1.900000e+00
t=2.000000e+00
t=2.100000e+00
t=2.200000e+00
t=2.300000e+00
t=2.400000e+00
t=2.500000e+00
t=2.600000e+00
t=2.700000e+00
t=2.800000e+00
t=2.900000e+00
t=3.000000e+00
t=3.100000e+00
t=3.200000e+00
t=3.300000e+00
t=3.400000e+00
t=3.500000e+00
t=3.600000e+00
t=3.700000e+00
t=3.800000e+00
t=3.900000e+00
t=4.000000e+00
t=4.100000e+00
t=4.200000e+00
t=4.300000e+00
t=4.400000e+00
t=4.500000e+00
t=4.600000e+00
t=4.700000e+00
t=4.800000e+00
t=4.900000e+00
t=5.000000e+00
t=5.100000e+00
t=5.200000e+00
t=5.300000e+00
t=5.400000e+00
t=5.500000e+00
t=5.600000e+00
t=5.700000e+00
t=5.800000e+00
t=5.900000e+00
t=6.000000e+00
t=6.100000e+00
t=6.200000e+00
t=6.300000e+00
t=6.400000e+00
t=6.500000e+00
t=6.600000e+00
t=6.700000e+00
t=6.800000e+00
t=6.900000e+00
t=7.000000e+00
t=7.100000e+00

Q(t)=6.503086e-01
Q(t)=8.564632e-01
Q(t)=1.057528e+00
Q(t)=1.253628e+00
Q(t)=1.444887e+00
Q(t)=1.631423e+00
Q(t)=1.813354e+00
Q(t)=1.990793e+00
Q(t)=2.163851e+00
Q(t)=2.332636e+00
Q(t)=2.497254e+00
Q(t)=2.657807e+00
Q(t)=2.814396e+00
Q(t)=2.967120e+00
Q(t)=3.116072e+00
Q(t)=3.261347e+00
Q(t)=3.403034e+00
Q(t)=3.541224e+00
Q(t)=3.676002e+00
Q(t)=3.807452e+00
Q(t)=3.935656e+00
Q(t)=4.060695e+00
Q(t)=4.182647e+00
Q(t)=4.301588e+00
Q(t)=4.417592e+00
Q(t)=4.530732e+00
Q(t)=4.641079e+00
Q(t)=4.748701e+00
Q(t)=4.853666e+00
Q(t)=4.956039e+00
Q(t)=5.055885e+00
Q(t)=5.153266e+00
Q(t)=5.248242e+00
Q(t)=5.340873e+00
Q(t)=5.431217e+00
Q(t)=5.519331e+00
Q(t)=5.605269e+00
Q(t)=5.689085e+00
Q(t)=5.770832e+00
Q(t)=5.850560e+00
Q(t)=5.928320e+00
Q(t)=6.004160e+00
Q(t)=6.078128e+00
Q(t)=6.150269e+00
Q(t)=6.220629e+00
Q(t)=6.289252e+00
Q(t)=6.356181e+00
Q(t)=6.421457e+00
Q(t)=6.485121e+00
Q(t)=6.547214e+00
Q(t)=6.607773e+00
Q(t)=6.666838e+00
Q(t)=6.724444e+00
Q(t)=6.780627e+00
Q(t)=6.835424e+00
Q(t)=6.888867e+00
Q(t)=6.940991e+00
Q(t)=6.991829e+00
Q(t)=7.041410e+00
Q(t)=7.089768e+00
Q(t)=7.136932e+00
Q(t)=7.182931e+00
Q(t)=7.227795e+00
Q(t)=7.271551e+00
Q(t)=7.314226e+00
Q(t)=7.355848e+00
Q(t)=7.396443e+00
Q(t)=7.436035e+00
Q(t)=7.474649e+00

13

At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At

time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time

t=7.200000e+00
t=7.300000e+00
t=7.400000e+00
t=7.500000e+00
t=7.600000e+00
t=7.700000e+00
t=7.800000e+00
t=7.900000e+00
t=8.000000e+00
t=8.100000e+00
t=8.200000e+00
t=8.300000e+00
t=8.400000e+00
t=8.500000e+00
t=8.600000e+00
t=8.700000e+00
t=8.800000e+00

Q(t)=7.512310e+00
Q(t)=7.549041e+00
Q(t)=7.584866e+00
Q(t)=7.619805e+00
Q(t)=7.653882e+00
Q(t)=7.687118e+00
Q(t)=7.719533e+00
Q(t)=7.751148e+00
Q(t)=7.781982e+00
Q(t)=7.812055e+00
Q(t)=7.841386e+00
Q(t)=7.869992e+00
Q(t)=7.897892e+00
Q(t)=7.925103e+00
Q(t)=7.951643e+00
Q(t)=7.977527e+00
Q(t)=8.002772e+00

v = 9;
t = 0;
c = 1;
r = 4;
figure; hold on;
q =c*v*(1-exp(-t/r*c));
title('Graph showing the change in Charge (C) over Time (sec):');
xlabel('Time (sec)');
ylabel('Charge (C)');
while q<8,
plot(t,q,'.');
fprintf('At time t=%d Q(t)=%d \n',t,q);
t=t+0.1;
q =c*v*(1-exp(-t/r*c));
end
fprintf('At time t=%d Q(t)=%d \n',t,q);
plot(t,q,'.');

Second part of the Question

14

At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At

time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time

t=0 Q(t)=0
t=1.000000e-01
t=2.000000e-01
t=3.000000e-01
t=4.000000e-01
t=5.000000e-01
t=6.000000e-01
t=7.000000e-01
t=8.000000e-01
t=9.000000e-01
t=1.000000e+00
t=1.100000e+00
t=1.200000e+00
t=1.300000e+00
t=1.400000e+00
t=1.500000e+00
t=1.600000e+00
t=1.700000e+00
t=1.800000e+00
t=1.900000e+00
t=2.000000e+00
t=2.100000e+00
t=2.200000e+00
t=2.300000e+00
t=2.400000e+00
t=2.500000e+00
t=2.600000e+00
t=2.700000e+00
t=2.800000e+00
t=2.900000e+00
t=3.000000e+00
t=3.100000e+00
t=3.200000e+00
t=3.300000e+00
t=3.400000e+00
t=3.500000e+00
t=3.600000e+00
t=3.700000e+00
t=3.800000e+00
t=3.900000e+00
t=4.000000e+00
t=4.100000e+00
t=4.200000e+00
t=4.300000e+00
t=4.400000e+00
t=4.500000e+00
t=4.600000e+00
t=4.700000e+00
t=4.800000e+00
t=4.900000e+00
t=5.000000e+00
t=5.100000e+00
t=5.200000e+00
t=5.300000e+00
t=5.400000e+00
t=5.500000e+00
t=5.600000e+00
t=5.700000e+00
t=5.800000e+00
t=5.900000e+00
t=6.000000e+00
t=6.100000e+00
t=6.200000e+00
t=6.300000e+00
t=6.400000e+00
t=6.500000e+00
t=6.600000e+00
t=6.700000e+00
t=6.800000e+00

Q(t)=2.222108e-01
Q(t)=4.389352e-01
Q(t)=6.503086e-01
Q(t)=8.564632e-01
Q(t)=1.057528e+00
Q(t)=1.253628e+00
Q(t)=1.444887e+00
Q(t)=1.631423e+00
Q(t)=1.813354e+00
Q(t)=1.990793e+00
Q(t)=2.163851e+00
Q(t)=2.332636e+00
Q(t)=2.497254e+00
Q(t)=2.657807e+00
Q(t)=2.814396e+00
Q(t)=2.967120e+00
Q(t)=3.116072e+00
Q(t)=3.261347e+00
Q(t)=3.403034e+00
Q(t)=3.541224e+00
Q(t)=3.676002e+00
Q(t)=3.807452e+00
Q(t)=3.935656e+00
Q(t)=4.060695e+00
Q(t)=4.182647e+00
Q(t)=4.301588e+00
Q(t)=4.417592e+00
Q(t)=4.530732e+00
Q(t)=4.641079e+00
Q(t)=4.748701e+00
Q(t)=4.853666e+00
Q(t)=4.956039e+00
Q(t)=5.055885e+00
Q(t)=5.153266e+00
Q(t)=5.248242e+00
Q(t)=5.340873e+00
Q(t)=5.431217e+00
Q(t)=5.519331e+00
Q(t)=5.605269e+00
Q(t)=5.689085e+00
Q(t)=5.770832e+00
Q(t)=5.850560e+00
Q(t)=5.928320e+00
Q(t)=6.004160e+00
Q(t)=6.078128e+00
Q(t)=6.150269e+00
Q(t)=6.220629e+00
Q(t)=6.289252e+00
Q(t)=6.356181e+00
Q(t)=6.421457e+00
Q(t)=6.485121e+00
Q(t)=6.547214e+00
Q(t)=6.607773e+00
Q(t)=6.666838e+00
Q(t)=6.724444e+00
Q(t)=6.780627e+00
Q(t)=6.835424e+00
Q(t)=6.888867e+00
Q(t)=6.940991e+00
Q(t)=6.991829e+00
Q(t)=7.041410e+00
Q(t)=7.089768e+00
Q(t)=7.136932e+00
Q(t)=7.182931e+00
Q(t)=7.227795e+00
Q(t)=7.271551e+00
Q(t)=7.314226e+00
Q(t)=7.355848e+00

15

At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At
At

time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time
time

t=6.900000e+00
t=7.000000e+00
t=7.100000e+00
t=7.200000e+00
t=7.300000e+00
t=7.400000e+00
t=7.500000e+00
t=7.600000e+00
t=7.700000e+00
t=7.800000e+00
t=7.900000e+00
t=8.000000e+00
t=8.100000e+00
t=8.200000e+00
t=8.300000e+00
t=8.400000e+00
t=8.500000e+00
t=8.600000e+00
t=8.700000e+00

Q(t)=7.396443e+00
Q(t)=7.436035e+00
Q(t)=7.474649e+00
Q(t)=7.512310e+00
Q(t)=7.549041e+00
Q(t)=7.584866e+00
Q(t)=7.619805e+00
Q(t)=7.653882e+00
Q(t)=7.687118e+00
Q(t)=7.719533e+00
Q(t)=7.751148e+00
Q(t)=7.781982e+00
Q(t)=7.812055e+00
Q(t)=7.841386e+00
Q(t)=7.869992e+00
Q(t)=7.897892e+00
Q(t)=7.925103e+00
Q(t)=7.951643e+00
Q(t)=7.977527e+00

v = 9;
t = 0;
c = 1;
r = 4;
figure; hold on;
q =c*v*(1-exp(-t/r*c));
title('Graph showing the change in Charge (C) over Time (sec):');
xlabel('Time (sec)');
ylabel('Charge (C)');
while q<8,
plot(t,q,'.');
fprintf('At time t=%d Q(t)=%d \n',t,q);
t=t+0.1;
q =c*v*(1-exp(-t/r*c));
end

16