From 398ebf51ea1c703725d5425939986ceb1e4825bd Mon Sep 17 00:00:00 2001 From: Chandan Relekar Date: Sun, 22 Nov 2026 02:20:25 +0100 Subject: [PATCH] First round of corrections --- hopfield_networks/simulation.html | 2 +- linear_transformations/simulation.html | 2 +- projectile_motion/simulation.html | 8 ++-- quantum_logic/simulation.html | 4 +- sorting_algos/cocktail_shaker_sort.js | 52 ++++++++++++++++---------- sorting_algos/simulation.html | 18 +++++---- special_relativity/simulation.html | 6 +-- trig_functions/simulation.html | 8 ++-- 8 files changed, 57 insertions(+), 43 deletions(-) diff --git a/hopfield_networks/simulation.html b/hopfield_networks/simulation.html index 255a0881..c42f726f 100644 --- a/hopfield_networks/simulation.html +++ b/hopfield_networks/simulation.html @@ -81,7 +81,7 @@

Hopfield Networks


Number of patterns memorized: 0

- Memory capacity (theoretical): 0.14 N2 = approx. 170 patterns

+ Memory capacity (theoretical): 0.14 N = approx. 6 patterns


diff --git a/linear_transformations/simulation.html b/linear_transformations/simulation.html index 4efe7945..f33b5c7e 100644 --- a/linear_transformations/simulation.html +++ b/linear_transformations/simulation.html @@ -112,7 +112,7 @@

Description

matrix, \(M = \begin{bmatrix} a & b \\ c & d \end{bmatrix} \), its inverse is given by:

- \[ M^{-1} = \frac{1}{|M|} \begin{bmatrix} d & -c \\ -b & a \end{bmatrix} \] + \[ M^{-1} = \frac{1}{|M|} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix} \]

Clicking on the following button will lead to calculation of inverse of the current matrix and its application.

diff --git a/projectile_motion/simulation.html b/projectile_motion/simulation.html index 4059d551..9054466b 100644 --- a/projectile_motion/simulation.html +++ b/projectile_motion/simulation.html @@ -101,8 +101,8 @@

Description

Time of ascent, descent and flight: - \[ t_f = \frac{2u}{g} \] - \[ t_a = t_d = \frac{u}{g} \] + \[ t_f = \frac{2u}{g} \sin \theta \] + \[ t_a = t_d = \frac{u}{g} \sin \theta \]
  1. 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} \).
  2. @@ -111,10 +111,10 @@

    Description

Maximum height: - \[ H_{max} = \frac{u^2 \sin \theta}{2g} \] + \[ H_{max} = \frac{u^2 \sin^2 \theta}{2g} \]
  1. 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} \)
  2. + y-direction, we get maximum height \( H = \frac{u^2 \sin^2 \theta}{2g} \)
  3. 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
diff --git a/quantum_logic/simulation.html b/quantum_logic/simulation.html index 9a5b8527..b0b23d43 100644 --- a/quantum_logic/simulation.html +++ b/quantum_logic/simulation.html @@ -116,10 +116,10 @@

Quantum Logic Gates

Description

- 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.

  • diff --git a/special_relativity/simulation.html b/special_relativity/simulation.html index b20e54bf..0c467311 100644 --- a/special_relativity/simulation.html +++ b/special_relativity/simulation.html @@ -100,8 +100,8 @@

    Description

    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

    1. 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.
    2. + 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>
    3. This simulation is compatible with SI units
    4. 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
    5. The Cosine of -θ is always positive since the projection on the X-axis is always along the positive X-direction
    6. -
    7. Hence, cos(-θ) = cos(θ): Cosine is even odd function
    8. +
    9. Hence, cos(-θ) = cos(θ): Cosine is even function
    10. 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