Created
February 1, 2016 00:51
-
-
Save benjic/fe4cced069a3a0bcb7e8 to your computer and use it in GitHub Desktop.
Solution to week 1 quiz for PHSX218 Lab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import numpy as np | |
def rule4(Q, A, dA, m, B, dB, n): | |
"""Computes the error propagation for the form c A^m * B^n""" | |
return abs(Q) * math.sqrt((m * (dA / A))**2 + (n * (dB / B))**2) | |
# Capture measurements | |
height = 22.65e-3 # meters | |
radius = 8.60e-3 / 2 # meters | |
mass = 228.6e-3 # kilograms | |
# Uncertainty for measurements devices | |
d_caliper = 0.05e-3 # meters | |
d_scale = 0.1e-3 # kilograms | |
# Compute the volume of the cylinder | |
volume = math.pi * height * (radius)**2 | |
d_volume = rule4(volume, radius, d_caliper, 2, height, d_caliper, 1) | |
# Compute the density of the cyclinder | |
density = mass * volume | |
d_density = rule4(density, mass, d_scale, 1, volume, d_volume, 1) | |
# Print the result | |
print("The density is %2.2E +/- %2.2E kg m^3" % (density, d_density)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment