Calculus 1 Lab With Python
Calculus 1 Lab With Python
Question No. 01
Calculate the following:
√
3
80 5
1. 8+ +e
2.6
1
2. 23+45 3
+ln ( 589.006 )
16 ×0.7
# First Part
ans1 = math.sqrt(8+80/2.6)+math.exp(3/5)
print("The solution is", ans1)
# Second Part
ans2 = (23+45**(1/3))/(16*0.7)+math.log(589.006)
print("The solution is", ans2)
Question No. 02
Define the variable x=4.6 and y=1.7 , then calculate the following:
√ x + y +2 x 2 − x y 2
1. 2
(x− y)
2. √ x 2+ y 2. In print statement, state whether or not your answer is equal to x + y (which
you can check in your hear or by hand).
x = 4.6
y = 1.7
# First Part
ans3 = math.sqrt(x+y)/(x-y)**2 + 2*x**2 - x*y**2
print("The solution is", ans3)
# Second Part
ans4 = math.sqrt(x**2+y**2)
ans5 = x+y
print("The solution to sqrt(x^2+y^2) which is ", ans4, "is not equal
to", ans5)
Question No. 03
Let a and b be the vectors ⟨ 9.1 ,14.47 ⟩ and ⟨ −5.55 , 9.62 ⟩. (NOTE: for all calculations in this
problem, use the definitions from class rather than trying to look up built-in functions).
1. Compute |a ) and |b ).
2. Use the Law of Cosines to find the cosine of the angle C between the vectors: \
begin{align} \cos(C) & = \frac{|a|^2+|b|^2-c^2}{2|a| |b|} \end{align} where c is the
distance between the points corresponding to a and b above.
3. Use the dot product formula to find the cosine of the angle C between the vectors
and show it is equal to the answer for (b). \begin{align} \cos(C) & = \frac{a\cdot b}{|
a| |b|} \end{align}
# Vectors a and b
a = [9.1, 14.47]
b = [-5.55, 9.62]
# First Part
magnitude_a = math.sqrt(sum(x**2 for x in a))
print("The magnitude of vector a is", magnitude_a)
# Second Part
Cosine_Angle = (magnitude_a**2+magnitude_b**2-
(dist(a,b))**2)/(2*magnitude_a*magnitude_b)
print("The Cosine angle C between a and b is", Cosine_Angle)