Scientific Programming and Mathematical Modelling
Question 1: Python Function (12 marks)
a) Write a program in Python to calculate the surface area of a cuboid. Collect width, height and depth of the cuboid as input. (2 mark)
b) Write a program that will work out the distance travelled if the user enters in the speed and the time. (2 mark)
c) Write a program to calculate the area of a circle from the radius entered by the user. (2 mark)
d) Write a program to calculate the future value (FV) of a loan using compound interest. (3 mark)
𝐹𝑉 = 𝑃𝑉(1 + 𝑟)𝒏
PV = present value
r = interest rate (as a decimal value) n = number of periods
e) Display 0 if a number entered by the user is even, and 1 if it is odd. (3 mark)
Question 2: Sketching and analyzing graph (13 marks)
You will need to use Jupyter notebook for this question. The code below draws a line from position (0,0) to (6,250)
import matplotlib.pyplot as plt import numpy as np
xpoints = np.array([0, 6]) ypoints = np.array([0, 250])
plt.plot(xpoints, ypoints) plt.show()
a) The code above creates a positive linear slope. Change the code so that the positive linear slope becomes a negative linear slope using the same range of axis. (3 mark)
b) Create code which will produce the graph below. Hint: you may need to use this line in your code:
plt.plot(xpoints, ypoints, ‘o’) (2 mark)
c) Create the line graph with multiple points shown above. (2 mark)
d) Why do the majority of Data Scientists use NumPy array instead of Lists in Python? (3 marks)
e) The following is an example of unstructured data. How would you be able to structure this data? (3 marks)
Question 3: The practice of mathematical modelling (12 marks)
Answer the following questions regarding the basic of Mathematical Modelling. It is also useful to illustrate your answer using a diagram or a chart.
a. In your own words, provide a definition of Mathematical modelling and explain three components which contributes to a good mathematical model. Think of one or more real-world scenario in which mathematical modelling can be used to provide insights, solutions, and predictions. (2 marks)
b. Explain the importance of assumptions in building a mathematical model. Use one or two examples to further clarify your answers. (2 marks)
c. Explain three possible limitations of using mathematical model as a data scientist. Use some real-world example(s) to illustrate your answers. (3 marks)
d. Suppose that one of your hobbies is to collect ants and put them in a jar. One day after coming to mathematical modelling seminar, you are interested in modelling the growth of your ant’s colony population.
i. Explain using the 1st stage of mathematical modelling how you would define the objective of your model, the assumptions regarding your ants’ population, the level of simplifications, and your model function or formula. (hint: suppose P = population and t=time (day), what is the function for your ants population growth in terms of time ) (3 marks)
ii. What technique of mathematics is used to model the scenario above? Suggest some ways for you to validate your model in (i) (2 mark)
Question 4: Functions and structured data (13 marks)
The questions below test your understanding on using functions and structured data in modelling real-world problems.
e. In the context of mathematical modelling, explain the relations and differences between an expression, an equation, and a function. Use a real-world example, structured data, or a cartesian graph to illustrate the suitability of using a function in modelling. (3 marks)
f. Observe the structured data provided below.
Summarize the structured data above and determine whether you can model a function of height in terms of age (Height (Age)). Explain the relationship between height and exam score and analyse if you can model a function of exam score in terms of height (Exam score (Height)). (3 marks)
g. A University had 1200 undergraduate students enrolled in 2003 and 1500 students in 2006. If the student population P; grows as a linear function of time t, where t is the number of years after 2003 (Hence t = 0 at 2003).
i. Find a linear function that relates the student population P to the time t. Starts with defining your objective (what the independent and dependent variable is) and any assumptions necessary for your model. (2 marks)
ii. With your linear function, predict the number of students enrolled in the University in 2010. (1 mark)
h. As an analyst at Amazon, your first task is to analyse the sales of Amazon Kindle throughout the year. Your data concludes that when the retail price of a kindle is $50, the number of sales is 4,500 unit per month. After analysing it further, you find out that if the price is raised by $1, the sales drop by 5 unit. So at $51, the number of sales become 4,495.
i. Find a linear function that relates the number of sales to the price of a kindle. Determine the dependent and independent variable and write down your function. (2 marks)
ii. Extend your function so that it relates the monthly revenue to the price. Note that Revenue(price) = number of sales (price) * price. In addition, find the optimal price of a kindle so that it maximises the revenue. (2 mark)