Tutor profile: Aaron L.
Subject: Python Programming
Write a function that calculates and returns the factorial of a number.
The cleanest way to write this function would be to use a recursive function. This means that the function will call itself within itself depending on the scenario. The if num == 1 acts as an end case since regardless of what number is used, the final value in the factorial calculation is always to multiply by 1. If num isn't 1, we multiply the current num with num - 1 and call the factorial function on it. def factorial(num): if num == 1: #End case. if num is 1, then we just return num return num else: return num * factorial(num - 1) #We call the function again but reduce num by 1
Prove the following identity: tan(x)sin(x) + cos(x) = sec(x)
tan(x)sin(x) + cos(x) = sec(x) (sin(x)/cos(x))*sin(x) + cos(x) = sec(x) #rewrite tan(x) as sin(x)/cos(x) sin^2(x)/cos(x) + cos(x) = sec(x) #multiply the sin(x)'s together (1 - cos^2(x))/cos(x) + cos(x) = sec(x) #rewrite sin^2(x) = 1 - cos^2(x) 1/cos(x) - cos^2(x)/cos(x) + cos(x) = sec(x) #separate 1 - cos^2(x) to their own denominators sec(x) - cos(x) + cos(x) = sec(x) #rewrite 1/cos(x) = sec(x) and cos^2(x)/cos(x) = cos(x) sec(x) = sec(x) #subtract the cos(x)'s Since the left side equals the right side now, we've proven this identity.
A ball is thrown in the air and its height h in meters at time t can be represented by the following equation: h(t) = t^2 -6t + 16 Find the maximum height of the ball and when this occurs by completing the square.
In order to find the maximum height, we'll need to convert the equation into vertex form: f(x) = a(x+h)^2 + k where (-h, k) is the vertex. To complete the square, we need to first identify our b value in the quadratic equation ax^2 + bx + c. in this cause, our b = -4 1. Divide b by 2 and square it. This gives us the number we need to make a perfect square h(t) = t^2 - 6t + 16 h(t) = t^2 - 6t + 9 - 9 + 16 #-6 divided by 2 is 3. 3^2 = 9 We have to subtract 9 as well in order to keep the equation equivalent to the original equation. 2. Factor the first 3 values (t^2 - 6t + 9) together. h(t) = (t - 3)^2 -9 + 16 #t^2 - 6t + 9 in factored form is (t-3)^2 h(t) = (t - 3)^2 + 7 # - 9 + 16 = 7 Now that we have the equation in vertex form, the maximum height is the k value. This means that the maximum height of the ball is 7 meters 3 seconds after the ball is thrown into the air.
needs and Aaron will reply soon.