Applmath Assignment #1 - Shayan Rakhshan

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Question 1

Confirmed with Python:


# question 1

counter = 1 # a variable to keep track of t


pt = 1 # a variable to keep track of pt

for number in range(10): # a for loop was used because of recursive


pattern
print("at t = ")
print(counter)
print(", pt = ")
counter = counter + 1
pt = pt*2 + 1 # recursive formula
print(pt)

Output:

Question 2
Confirmed with Python:

Final line is the code-compatible form^

# question 2

import numpy
from sympy import *

t = Symbol('t') # defining variable for time


u = Function('u')(t) # defining function u(t)

de = Eq(((1 - sin(t)**2)*u.diff(t)) + u, 1) # creating differential


equation
display(de)

gen_soln = dsolve(de, u) # solving differential equation


display(gen_soln)

unique_soln = dsolve(de, u, ics={u.subs(t, numpy.pi/4):5}) # solving


unique equation using initial condition
display(unique_soln)

Output:
Question 3
Question 4
(A)
I predict that the greater the maximum length is, the greater the maximum weight will be as well. This
makes sense both logically and mathematically. Logically, the greater the size of the cat, the more space it
has to grow flesh and bone, thus, allowing for an increased total weight potential. Mathematically, the
length can be related to surface area, and the volume can be related to mass (considering all large cats
have similar average body density); now, using the shape of a cube as a model for large cats, the mass
(volume) will grow allometrically in relation to the length (surface area), as it is a third degree function
whereas length (surface area) is a second degree function.

(B)

# Question 4 Scatter Plot

import numpy
import matplotlib.pyplot as plt

max_w = numpy.array([387.8, 313, 158, 125.2, 96, 75, 75, 38, 26, 23]) #
array of max weight values
max_l = numpy.array([4.17, 3.64, 2.8, 2.8, 2.75, 2.5, 2.5, 1.5, 1.9, 1.9])
# array of max length values

plt.plot(max_l, max_w, '.', color = "black") # creating the scatter plot


plt.xlabel("Max Length", fontsize = 14)
plt.ylabel("Max Weight", fontsize = 14)

x = numpy.array([1, 2, 3, 4]) # creating x values


y = 115*x - 150 # creating line of best fit equation
plt.plot(x, y, '-', color = "red")
plt.show()
# Question 4 Semilog Plot

import numpy
import matplotlib.pyplot as plt

max_w = numpy.array([387.8, 313, 158, 125.2, 96, 75, 75, 38, 26, 23]) #
array of max weight values
max_l = numpy.array([4.17, 3.64, 2.8, 2.8, 2.75, 2.5, 2.5, 1.5, 1.9, 1.9])
# array of max length values

plt.plot(max_l, numpy.log(max_w), '.', color = "black") # creating the


semilog plot
plt.xlabel("Max Length", fontsize = 14)
plt.ylabel("Log[Max Weight]", fontsize = 14)

x = numpy.array([1, 2, 3, 4]) # creating x values


y = 0.95*x + 2 # creating line of best fit equation
plt.plot(x, y, '-', color = "red")
plt.show()
# Question 4 Log-Log Plot

import numpy
import matplotlib.pyplot as plt

max_w = numpy.array([387.8, 313, 158, 125.2, 96, 75, 75, 38, 26, 23]) #
array of max weight values
max_l = numpy.array([4.17, 3.64, 2.8, 2.8, 2.75, 2.5, 2.5, 1.5, 1.9, 1.9])
# array of max length values

plt.plot(numpy.log(max_l), numpy.log(max_w), '.', color = "black") #


creating the scatter plot
plt.xlabel("Log[Max Length]", fontsize = 14)
plt.ylabel("Log[Max Weight]", fontsize = 14)

x = numpy.array([0.25, 1, 1.75]) # creating x values


y = 3.15*x + 1.5 # creating line of best fit equation
plt.plot(x, y, '-', color = "red")
plt.show()
Conclusion: The log-log graph is the most accurate as the data points appear to match the line of best fit
the most accurately with the least deviation.

(C)
(D)
My prediction was correct; max weight increases allometrically in relation to max length. The reason it
turned out to be correct is because my prediction of allometry was correct, as well as being correct in
choosing a cube as a model for the shape of large cats.

(E)
Although there are no blatant outliers, there seems to be a somewhat extreme data point towards the lower
end of length, embodied by the Eurasian Lynx. One explanation is that the Eurasian Lynx is adapted to a
colder climate than the rest of the large cats, so, over time, it has developed a heat insulation system
consisting of storing more fat. This can be proven by observing images of the Eurasian Lynx in
comparison to other large cats; for their length, they happen to be much wider. As a result, they are able to
store more weight with the same length, so they do not fit as accurately within our created model as other,
leaner large cats do.

You might also like