While playing billiards with your friends, you notice that if you ever mishit (that is, you don't hit dead straight) a ball with the cue ball, the balls split apart perpendicular to each other. This seems to happen all the time and helps you win the game. Once you get back home, you're determined to find how this exactly works and therefore search for a physical proof that these balls split of at an angle of 90.
Pool balls almost weight the same (i.e. they have the same mass). The cue is given some initial velocity u1 and aimed at another ball which is initially at rest. We suppose that the two balls split apart by subtending angles of A1 and A2 respectively with velocities v1 and v2. We can obtain three equations for the velocities - Conservation of Kinetic Energy (we assume the collision is instantaneous and elastic), the Conservation of Linear Momentum along u1 (using the cosine components of the velocities) and the Conservation of Linear Momentum perpendicular to u2 (using the sine components). We can combine these equations into one by squaring the momentum equations and adding them to get rid of the sine and cosine coefficients and subtracting them from the energy equation. This will simplify into an equation in terms of the velocities and the angle A1+ A2 (The actual angle between the balls). By solving it for A1+A2, we can proof that it is always 90.
What is the derivative of a function, and why is its value the slope of the tangent of the function?
The derivative of a function f(x) at a point ( x, f(x) ) is defined as the instantaneous rate of change of the function as x changes itself. The tangent of a curve is a (secant) line that only touches the curve at one point and its inclination is the slope of the function at that point. Since it is defined by the gain in y (or f(x) ) over the gain in x for a very small change, it is equal to the derivative of the function. To define the infinitesimal value of this change we introduce the concept of limits. By using limits and thereby creating a new point ( x+h , f(x+h) ) such that h is so small that this point is as close as possible to ( x, f(x) ), we can define the slope at the one point itself and thereby answer our question.
Create a program that will ask the user for a certain chess board 'size' (consider that the size will never exceed 20) and then ask them how many chess 'queen' pieces they wish to place on the board such that none can attack any other. The program should be able to determine whether the input the user provides is applicable and then actually print out a board showing where these queens can be positioned if possible. This program will test your skills at using functions, arrays, iterations, for loops and recursion.
This answer is a very basic outline on how to tackle this problem. We will start with a multi-dimensional array of bool values with a maximum size of 20x20. The basic concept of the array is that it represents the chess board - the 0's or false's will indicate an empty tile while a 1 or true will mean that a queen is placed there. We will create few functions that will operate on the chess board - bool ifQueen(arr[ ][ ],i,j,size) (this will check if a queen can be placed on the (i,j) tile of the array), void noQueen(arr[ ][ ],i,j,) (this will left the queen of the (i,j) tile and replace the 1 with 0 as if no queen were left there) and bool Solver(arr[ ],col,size,n). Solver will be a recursive backtracking function that will test if 'n' number of Queens can be placed on a (Size)x(Size) chessboard, and if possible, solve the problem. Solver will have two base cases, one returning true if the n equals 0 (this would mean that the recursion successfully completed till all the queens were placed) and the other returning false if the column number was greater than the size (this would mean that the function could not successfully place all the queens and repeated for all columns before it could finish placing all the queens). The recursive backtracking part of this function will involve a for loop that will run for all rows and test if a queen can be placed on the (row,col) tile using ifQueen. If it can do so, it will now recurse by calling Solver again, but this time with an incremented col and decremented n. If it cannot do so, it will continue on with the rest of the row numbers. The logic behind this recursion is that if a queen can successfully be placed on one cell, then it will try on the next column's cells till it either places all queens or exceeds the column number and fails. Both these cases are covered by the function and hence the recursion will work. If it fails, it will return false, otherwise it will return true. In our main function, we will input ( by using cin ) the number of queens and the user's side length. We will initialize a multi-dimesional of the max size and initialize all cells as zero. Now we will run an if-else selection statement by calling Solver. If Solver returns true, we will display the bool array as a chessboard with the queens placed. If Solver returns false, we can comment that the required configuration is impossible. Contact me for specifics on the coding.