A Force F is exerted at an angle theta on a box of mass m as it travels a distance x at a constant velocity. What is the work done by force F on the box?
We know that Work is a Force done over a distance, but since the force F is exerted at an angle upwards, we need to calculate the horizontal component of the force (the component pulling the box along the direction of its velocity). We can do this by multiplying the force by the cosine of the angle as F*cos(theta). Now that we have the force exerted, we can finally multiply it by the distance x making the final answer F*x*cos(theta).
public int mystery5(int x, int y) { if (x < 0) { return -mystery5(-x, y); } else if (y < 0) { return -mystery5(x, -y); } else if (x == 0 && y == 0) { return 0; } else { return 100 * mystery5(x / 10, y / 10) + 10 * (x % 10) + y % 10; } } When looking at this function, how can you determine the output quickly?
The first two if statements seem to remove any negative number inputted, but keep the negative sign in the final answer (example. if mystery5(-5, 5) were inputted, we would know that the final answer would be negative) The third if statement is the end case, you can see that once all the calculations are run and you have depleted both of your parameters, the function has run its course. The fourth if statement is where the most work comes in, the second segment ( 10 * (x % 10) + y % 10) seems to take the number in the ones place for x and y and concatenate them (example. if x = 6 and y = 3, you would get 63). The first segment is the recursive part of the statement (100 * mystery5(x / 10, y / 10)) it ensures that once we're done with the ones place of each number we cut it off so we can work on the tens, hundreds, and so on as long as there are numbers left. With all this in mind, this function seems to mix the numbers, mystery(565, 323) would return 536253 where mystery(-47, 9) would return -4079 as y in that instance has no number in the "tens place".
Differentiate f(x) = sin(5x^3)
Since we have an outside and inside function, (as the outer function sin() encompasses the inside function of 5x^3) we must use chain rule to solve this problem. We start by computing the derivative of the outside function (sin->cos) and we multiply that by the derivative of the inside function. All of this together would be cos(5x^3) * 15x^2 or 15x^2*cos(5x^3). A general rule of thumb is you keep working through adding segments (where cos(5x^3) was the first segment and 15x^2 was the second) until your segments have no more functions within them.