Using the fact that \(v_y\) is zero at the highest point, and using \(v = u - gt\) in the y-direction,
we obtain time of ascent \(= \frac{u \sin \theta}{g} \).
Using the fact that \(v_y\) is zero at the highest point, and using \( v^2 = u^2 - 2gy \) in the
- y-direction, we get maximum height \( H = \frac{u^2 sin^2 \theta}{2g} \)
+ y-direction, we get maximum height \( H = \frac{u^2 \sin^2 \theta}{2g} \)
For a given initial velocity \(u\), maximum possible height is achieved when angle of projection is 90
degrees, as is evident from the above formula
- Every qubit \( | \psi \gt \) resides on a point on a Block sphere. It can be represented by two
+ Every qubit \( | \psi \gt \) resides on a point on a Bloch sphere. It can be represented by two
numbers \( (a, b)\) such that:
\[ | \psi \gt = a | 0 \gt + b | 1 \gt \]
- Here, \( | 0 \gt \) and \( b | 1 \gt \) are known as the basis states. The probability that a qubit is measured in
+ Here, \( | 0 \gt \) and \( | 1 \gt \) are known as the basis states. The probability that a qubit is measured in
the \( | 0 \gt \) state is given by \( a^2 \). The probability that a qubit is measured in the \( | 1 \gt \) state
is given by \( b^2 \). Following the postulates of probability, we require that:
\[ a^2 + b^2 = 1 \]
diff --git a/sorting_algos/cocktail_shaker_sort.js b/sorting_algos/cocktail_shaker_sort.js
index 2e97eeac..9cbbdb59 100644
--- a/sorting_algos/cocktail_shaker_sort.js
+++ b/sorting_algos/cocktail_shaker_sort.js
@@ -8,33 +8,43 @@ let state_c;
function updateCocktail() {
if(left_sorted_index_c < right_sorted_index_c) {
if(state_c == "max") {
- if(scanning_index_c <= right_sorted_index_c) {
- if(array[scanning_index_c] > num_interest_c) {
- num_interest_c = array[scanning_index_c];
- num_position_c = scanning_index_c;
+ // Forward pass: bubble the largest unsorted value to the right
+ if(scanning_index_c < right_sorted_index_c) {
+ num_position_c = scanning_index_c + 1; // other element of the compared pair
+
+ if(array[scanning_index_c] > array[scanning_index_c + 1]) {
+ swap(scanning_index_c, scanning_index_c + 1);
+ swapped_c = true;
+ swaps++;
}
scanning_index_c++;
- array_access++;
+ comparisons++;
+ array_access += 2;
}
else {
- swap(num_position_c, right_sorted_index_c);
+ // Largest value is now in its final place
right_sorted_index_c--;
+ // No swaps during this pass -> array is sorted
+ if(!swapped_c) {
+ left_sorted_index_c = right_sorted_index_c;
+ }
+ swapped_c = false;
+
state_c = "min";
scanning_index_c = right_sorted_index_c;
-
- num_interest_c = num_numbers;
-
- swaps++;
}
- comparisons++;
}
else if(state_c == "min") {
- if(scanning_index_c >= left_sorted_index_c) {
- if(array[scanning_index_c] < num_interest_c) {
- num_interest_c = array[scanning_index_c];
- num_position_c = scanning_index_c;
+ // Backward pass: bubble the smallest unsorted value to the left
+ if(scanning_index_c > left_sorted_index_c) {
+ num_position_c = scanning_index_c - 1; // other element of the compared pair
+
+ if(array[scanning_index_c - 1] > array[scanning_index_c]) {
+ swap(scanning_index_c - 1, scanning_index_c);
+ swapped_c = true;
+ swaps++;
}
scanning_index_c--;
@@ -42,15 +52,17 @@ function updateCocktail() {
array_access += 2;
}
else {
- swap(num_position_c, left_sorted_index_c);
+ // Smallest value is now in its final place
left_sorted_index_c++;
+ // No swaps during this pass -> array is sorted
+ if(!swapped_c) {
+ left_sorted_index_c = right_sorted_index_c;
+ }
+ swapped_c = false;
+
state_c = "max";
scanning_index_c = left_sorted_index_c;
-
- num_interest_c = 0;
-
- swaps++;
}
}
iterations++;
diff --git a/sorting_algos/simulation.html b/sorting_algos/simulation.html
index f1d8053a..9731ef0b 100644
--- a/sorting_algos/simulation.html
+++ b/sorting_algos/simulation.html
@@ -7,7 +7,8 @@
-
+
@@ -140,14 +141,15 @@
Description
- Cocktail Shaker sort: A variation of selection sort that scans for the maximum element while going forward,
+ Cocktail Shaker sort: A two-way variation of bubble sort that moves the maximum element while going forward,
and the minimum element while going backwards. It is useful for electromechanical machines that use a physical
data reader to scan and sort through values sorted in a tape.
Heap sort: A slightly complex sorting algorithm that uses a data structure called heaps. First algorithm on
- this list to have a time complexity of O(n log n), although it comes with a space complexity of O(n), and the only
+ this list to have a time complexity of O(n log n), although it comes with an additional space complexity of O(1),
+ and the only
algorithm on this list to require explicit space. It is extremely good at keeping frequently updated lists sorted
dynamically, an advantage conferred by the data structure that it is built on. For information on the heap data
structure, please refer Description
- Quick sort: As the name implies, it has the fastest time complexity of O(n log n) despite not requiring any
- explicit memory. It randomly choses an element as a pivot, and transports all elements lower than the pivot to the
- left, and the elements greater than the pivot to the right of the pivot. The same operation is repeated on the
- portion of the list to the left and right of the pivot, recursively. Despite it's charasmatic name, it is
- difficult to implement, and certain choices of pivots can be disastrous on it's runtime.
+ Quick sort: As the name implies, it has the fastest average time complexity of O(n log n) despite not
+ requiring any explicit memory. It randomly choses an element as a pivot, and transports all elements lower than
+ the pivot to the left, and the elements greater than the pivot to the right of the pivot. The same operation is
+ repeated on the portion of the list to the left and right of the pivot, recursively. Despite it's charasmatic
+ name, it is difficult to implement, and certain choices of pivots can be disastrous on it's runtime.
observer aboard the satellite measured the same object's length to be 'l' as calculated above. Observe that
l0 > l. This phenomenon is known as length contraction.
Relativistic Doppler Effect
- \[ f = f_0 \left( \frac{c-v}{c+v} \right) \]
-
If the satellite transmits waves of frequency 'f0'', then a stationary receiver on the Earth will
+ \[ f = f_0 \sqrt{\frac{c-v}{c+v}} \]
+
If the satellite transmits waves of frequency 'f0', then a stationary receiver on the Earth will
measure the same waves to have a frequency of 'f' as calculated above. This phenomenon is known as relativistic
doppler effect.
@@ -113,7 +113,7 @@
Description
Speaking in a strict sense, a satellit orbiting the Earth won't exactly show these effects in the same manner.
The orbiting satellite analogy has been provided to get a brief idea of speed. Instead, consider a spaceship going
- away from Earth at the same speed.
+ away from Earth at the same speed. However, satellites do gain time (for example,the GPS satellites gain around 38 microseconds per day) which has to be corrected for accurate positioning./li>
This simulation is compatible with SI units
Gamma (γ) is defined as:
\[ \gamma = \frac{1}{1 - \frac{v^2}{c^2}} \]
diff --git a/trig_functions/simulation.html b/trig_functions/simulation.html
index a6459a7c..c80bcd93 100644
--- a/trig_functions/simulation.html
+++ b/trig_functions/simulation.html
@@ -167,7 +167,7 @@
Deductions
X-direction
The Cosine of -θ is always positive since the projection on the X-axis is always along the positive
X-direction
-
Hence, cos(-θ) = cos(θ): Cosine is even odd function
+
Hence, cos(-θ) = cos(θ): Cosine is even function
The same also holds good for an angle θ having magnitude between 90 and 180 degrees: Cos(θ) and
cos(-θ) are both negative
@@ -206,7 +206,7 @@
The Circle Grazers: Tangent and Cotangent
- Relationship between Tangent and Cotangentt:
+ Relationship between Tangent and Cotangent:
The length of the same tangent, but from the point P to its
point of intersection with the Y-axis is equal to the Cotangent of θ
@@ -226,7 +226,7 @@
Deductions
The Inner Perpetrators: Secant and Cosecant
- Etymology: The word "secant" is derived from the French verb "secanter" which means "to cut"
+ Etymology: The word "secant" is derived from the Latin word "secare" which means "to cut"
Visualization: Consider the same unit cirle with the same line segment OP and the tangent drawn to the
circle at point P. The length between the Origin and the point where the tangent intersects the X-axis is equal to
@@ -275,7 +275,7 @@
Deductions
The Secant of 0 degrees is 1, since the point P coincides with the X-axis
The Cosecant of 0 degrees is infinite, since the tangent never meets the Y-axis
The Secant of 90 degrees is infinite, since the tangent never meets the X-axis
-
The Cosecant of 0 degrees is 1, since the point P coincides with the Y-axis
+
The Cosecant of 90 degrees is 1, since the point P coincides with the Y-axis
The same logic holds good for 180 degrees and 270 degrees