<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[PractiSci Lab Notes]]></title><description><![CDATA[PractiSci Lab Notes]]></description><link>https://practisci.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 14:42:11 GMT</lastBuildDate><atom:link href="https://practisci.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Optical fibre: critical angle, numerical aperture and loss in JavaScript]]></title><description><![CDATA[An optical fibre guides light by total internal reflection: the core has a higher refractive index n₁ than the cladding n₂. Here are the key formulas in…]]></description><link>https://practisci.hashnode.dev/optical-fibre-critical-angle-numerical-aperture-and-loss-in-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/optical-fibre-critical-angle-numerical-aperture-and-loss-in-javascript</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Wed, 18 Nov 2026 05:57:40 GMT</pubDate><content:encoded><![CDATA[<p>An optical fibre guides light by total internal reflection: the core has a higher refractive index n₁ than the cladding n₂. Here are the key formulas in code. (I build <a href="https://www.practisci.in">PractiSci</a>, where optical fibre is a free virtual lab.)</p>
<h2>Critical angle</h2>
<pre><code class="language-js">const deg = (x) =&gt; (x * 180) / Math.PI;
const thetaC = (n1, n2) =&gt; deg(Math.asin(n2 / n1));
console.log(thetaC(1.5, 1.45).toFixed(1)); // 75.2
</code></pre>
<h2>Numerical aperture and acceptance angle</h2>
<pre><code class="language-js">const NA = (n1, n2) =&gt; Math.sqrt(n1 * n1 - n2 * n2);
const na = NA(1.5, 1.45);
console.log(na.toFixed(3), deg(Math.asin(na)).toFixed(1)); // 0.384, 22.6
</code></pre>
<h2>Signal loss</h2>
<p>10 mW over 50 km at 0.2 dB/km:</p>
<pre><code class="language-js">const out = (pIn, dbPerKm, km) =&gt; pIn * 10 ** (-(dbPerKm * km) / 10);
console.log(out(10, 0.2, 50)); // 1 mW
</code></pre>
<h2>FAQ</h2>
<h3>Which is denser, core or cladding?</h3>
<p>The core. Otherwise there is no total internal reflection.</p>
<h3>Acceptance angle or critical angle?</h3>
<p>Different things: the acceptance angle is measured at the end face in air; the critical angle is at the core-cladding boundary.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/12-9-optical-fibre">optical fibre lab</a> lets you change the indices. The <a href="https://www.practisci.in/topics/ray-optics">ray optics guide</a> has the theory.</p>
]]></content:encoded></item><item><title><![CDATA[Electric dipole moment, field and torque in JavaScript]]></title><description><![CDATA[An electric dipole is +q and −q separated by 2a. Its dipole moment is p = q × 2a. Here are the formulas as code. (I build PractiSci, where the dipole in a…]]></description><link>https://practisci.hashnode.dev/electric-dipole-moment-field-and-torque-in-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/electric-dipole-moment-field-and-torque-in-javascript</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Wed, 18 Nov 2026 05:56:53 GMT</pubDate><content:encoded><![CDATA[<p>An electric dipole is +q and −q separated by 2a. Its dipole moment is p = q × 2a. Here are the formulas as code. (I build <a href="https://www.practisci.in">PractiSci</a>, where the dipole in a field is a free virtual lab.)</p>
<h2>Dipole moment</h2>
<pre><code class="language-js">const p = (q, twoA) =&gt; q * twoA;
const pm = p(2e-6, 0.04);
console.log(pm); // 8e-8 C m
</code></pre>
<h2>Field on the axis and the equatorial line (r much larger than a)</h2>
<pre><code class="language-js">const k = 9e9;
const axial = (p, r) =&gt; (2 * k * p) / r ** 3;
const equatorial = (p, r) =&gt; (k * p) / r ** 3;
console.log(axial(8e-8, 0.5), equatorial(8e-8, 0.5)); // 11520, 5760 N/C
</code></pre>
<p>The axial field is twice the equatorial one, and the equatorial field points opposite to p.</p>
<h2>Torque and potential energy</h2>
<pre><code class="language-js">const torque = (p, E, deg) =&gt; p * E * Math.sin((deg * Math.PI) / 180);
const U = (p, E, deg) =&gt; -p * E * Math.cos((deg * Math.PI) / 180);
console.log(torque(8e-8, 2e5, 30)); // 0.008 N m
</code></pre>
<h2>FAQ</h2>
<h3>Is there a net force in a uniform field?</h3>
<p>No. Net force is zero; only a torque acts.</p>
<h3>How does the dipole field fall?</h3>
<p>As 1/r³, faster than a single charge's 1/r².</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/12-1-dipole-in-field">dipole in a field lab</a> lets you change charge, separation and angle. More are in the <a href="https://www.practisci.in/practicals/class-12-physics">Class 12 physics practicals</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Coulomb's law force between charges in JavaScript]]></title><description><![CDATA[Coulomb's law gives the force between two point charges: F = k q₁q₂ / r², with k = 9 × 10⁹ N m²/C². Here it is as a few lines of code. (I build PractiSci…]]></description><link>https://practisci.hashnode.dev/coulomb-s-law-force-between-charges-in-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/coulomb-s-law-force-between-charges-in-javascript</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Wed, 18 Nov 2026 05:56:07 GMT</pubDate><content:encoded><![CDATA[<p>Coulomb's law gives the force between two point charges: F = k q₁q₂ / r², with k = 9 × 10⁹ N m²/C². Here it is as a few lines of code. (I build <a href="https://www.practisci.in">PractiSci</a>, where Coulomb's law is a free virtual lab.)</p>
<h2>Force between two charges</h2>
<pre><code class="language-js">const k = 9e9;
const F = (q1, q2, r, K = 1) =&gt; (k * q1 * q2) / (K * r * r);
console.log(F(2e-6, 3e-6, 0.3).toFixed(2)); // 0.60 N, repulsive
</code></pre>
<h2>Inverse square check</h2>
<pre><code class="language-js">console.log(F(2e-6, 3e-6, 0.6).toFixed(2)); // 0.15 N, double r gives F/4
</code></pre>
<h2>Find a charge from the force</h2>
<p>Two equal charges repel with 0.9 N at 10 cm:</p>
<pre><code class="language-js">const q = Math.sqrt((0.9 * 0.1 ** 2) / k);
console.log(q); // 1e-6 C = 1 µC
</code></pre>
<h2>In a medium</h2>
<p>Divide by the dielectric constant K. For water (K ≈ 80) the force drops by a factor of 80.</p>
<pre><code class="language-js">console.log(F(2e-6, 3e-6, 0.3, 80)); // 0.0075 N
</code></pre>
<h2>FAQ</h2>
<h3>Attractive or repulsive?</h3>
<p>Like charges repel, unlike attract. Use magnitudes in the formula and decide direction from the signs.</p>
<h3>Common unit mistake?</h3>
<p>Convert µC to C and cm to m before using k.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/12-1-coulombs-law">Coulomb's law lab</a> lets you change both charges and the distance. More are in the <a href="https://www.practisci.in/practicals/class-12-physics">Class 12 physics practicals</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Lenz's law: induced emf and current direction in JavaScript]]></title><description><![CDATA[Lenz's law says an induced current flows in the direction that opposes the change in flux that causes it. The minus sign in Faraday's law is exactly that…]]></description><link>https://practisci.hashnode.dev/lenz-s-law-induced-emf-and-current-direction-in-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/lenz-s-law-induced-emf-and-current-direction-in-javascript</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Wed, 18 Nov 2026 05:55:17 GMT</pubDate><content:encoded><![CDATA[<p>Lenz's law says an induced current flows in the direction that opposes the change in flux that causes it. The minus sign in Faraday's law is exactly that. Here is the calculation in code. (I build <a href="https://www.practisci.in">PractiSci</a>, where Lenz's law is a free virtual lab.)</p>
<h2>Induced emf</h2>
<p>For N turns, e = −N dΦ/dt. For a uniform change, the magnitude is N × ΔΦ / Δt.</p>
<pre><code class="language-js">const emf = (N, dPhi, dt) =&gt; -N * dPhi / dt;
console.log(emf(200, 0.01 - 0.05, 0.2)); // 40 V (positive: flux is falling)
</code></pre>
<h2>Current and heat</h2>
<p>With coil resistance 20 Ω:</p>
<pre><code class="language-js">const I = 40 / 20, P = I * I * 20;
console.log(I, P); // 2 A, 80 W
</code></pre>
<p>That 80 W comes from the work done moving the magnet against the opposing force, which is conservation of energy.</p>
<h2>Which way does the current flow?</h2>
<pre><code class="language-js">const direction = (fluxChange) =&gt;
  fluxChange &gt; 0 ? "induced field opposes the original" : "induced field supports the original";
console.log(direction(+1)); // pushing a magnet in
</code></pre>
<p>Push a north pole towards a coil: flux increases, so the near face becomes a north pole and the current is anticlockwise seen from that side.</p>
<h2>FAQ</h2>
<h3>Why the negative sign?</h3>
<p>It encodes energy conservation. Without it, induced currents would reinforce the change and create energy from nothing.</p>
<h3>Does Lenz's law need a closed loop?</h3>
<p>The current needs one; the induced emf exists either way.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/12-6-lenz-law-magnet-coil">Lenz's law lab</a> lets you move the magnet. The <a href="https://www.practisci.in/topics/electromagnetic-induction">electromagnetic induction guide</a> has the theory.</p>
]]></content:encoded></item><item><title><![CDATA[Pascal's law and the hydraulic lift in JavaScript]]></title><description><![CDATA[Pascal's law says a pressure change applied to an enclosed liquid is passed on undiminished to every part of it. That is how a small force on a small…]]></description><link>https://practisci.hashnode.dev/pascal-s-law-and-the-hydraulic-lift-in-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/pascal-s-law-and-the-hydraulic-lift-in-javascript</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Wed, 18 Nov 2026 05:53:20 GMT</pubDate><content:encoded><![CDATA[<p>Pascal's law says a pressure change applied to an enclosed liquid is passed on undiminished to every part of it. That is how a small force on a small piston lifts a car. Here is the maths as code. (I build <a href="https://www.practisci.in">PractiSci</a>, where the hydraulic lift is a free virtual lab.)</p>
<h2>Pressure and force multiplication</h2>
<p>Pressure is P = F/A. The same pressure acts on both pistons, so F₂ = F₁ × (A₂/A₁).</p>
<pre><code class="language-js">const press = (F1, A1, A2) =&gt; ({ P: F1 / A1, F2: (F1 / A1) * A2 });
console.log(press(100, 0.002, 0.2)); // { P: 50000, F2: 10000 }
</code></pre>
<h2>Is energy free? No</h2>
<p>The large piston moves less: d₂ = d₁ × (A₁/A₂). Work in equals work out.</p>
<pre><code class="language-js">const d2 = 0.5 * (0.002 / 0.2);        // 0.005 m
console.log(100 * 0.5, 10000 * d2);    // 50 J  50 J
</code></pre>
<h2>How much force lifts a car?</h2>
<p>A 1200 kg car, large piston 50 times the area (g = 9.8):</p>
<pre><code class="language-js">console.log((1200 * 9.8) / 50); // 235.2 N
</code></pre>
<h2>FAQ</h2>
<h3>Does Pascal's law work for gases?</h3>
<p>It is for incompressible liquids. A gas compresses, so pressure is not passed on the same way.</p>
<h3>Area or diameter in the ratio?</h3>
<p>Always area. A diameter ratio of 10 means an area ratio of 100.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/11-9-pascal-hydraulic-lift">hydraulic lift lab</a> lets you change the piston areas. The <a href="https://www.practisci.in/topics/mechanical-properties-of-fluids">fluids guide</a> has the theory.</p>
]]></content:encoded></item><item><title><![CDATA[Newton's law of cooling in JavaScript: find k and predict temperature]]></title><description><![CDATA[Newton's law of cooling says a body loses heat at a rate proportional to its excess temperature over the surroundings, giving T(t) = Tₛ + (T₀ − Tₛ)…]]></description><link>https://practisci.hashnode.dev/newton-s-law-of-cooling-in-javascript-find-k-and-predict-temperature</link><guid isPermaLink="true">https://practisci.hashnode.dev/newton-s-law-of-cooling-in-javascript-find-k-and-predict-temperature</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[education]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Tue, 17 Nov 2026 12:19:20 GMT</pubDate><content:encoded><![CDATA[<p>Newton's law of cooling says a body loses heat at a rate proportional to its excess temperature over the surroundings, giving T(t) = Tₛ + (T₀ − Tₛ) e^(−kt). One measurement gives k, and then you can predict anything. (I build <a href="https://www.practisci.in">PractiSci</a>, where cooling is a free virtual lab.)</p>
<h2>How do I find the cooling constant k?</h2>
<p>A drink cools from 90 °C to 70 °C in 10 minutes in a 25 °C room.</p>
<pre><code class="language-js">const Ts = 25;
const k = Math.log((90 - Ts) / (70 - Ts)) / 10;
const T = (t) =&gt; Ts + (90 - Ts) * Math.exp(-k * t);
const timeTo = (x) =&gt; Math.log((90 - Ts) / (x - Ts)) / k;

console.log(k.toFixed(4));          // 0.0368 per min
console.log(T(20).toFixed(1));      // 56.2 °C after 20 min
console.log(timeTo(50).toFixed(1)); // 26.0 min to reach 50 °C
</code></pre>
<h2>What does the curve look like?</h2>
<p>It is an exponential decay toward room temperature: fast at first, slower later, never below Tₛ.</p>
<table>
<thead>
<tr>
<th>Time (min)</th>
<th>Temperature (°C)</th>
</tr>
</thead>
<tbody><tr>
<td>0</td>
<td>90.0</td>
</tr>
<tr>
<td>10</td>
<td>70.0</td>
</tr>
<tr>
<td>20</td>
<td>56.2</td>
</tr>
<tr>
<td>26</td>
<td>50.0</td>
</tr>
</tbody></table>
<h2>FAQ</h2>
<h3>When does the law hold?</h3>
<p>For small temperature differences (roughly under 30 °C) and when the loss is mainly convection.</p>
<h3>Does k depend on the liquid?</h3>
<p>Yes: on surface area, material and surroundings, not on the temperature itself.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/11-10-newton-cooling">Newton's law of cooling lab</a> draws the curve for you. The <a href="https://www.practisci.in/topics/thermodynamics">thermodynamics guide</a> has the theory.</p>
]]></content:encoded></item><item><title><![CDATA[Electrolysis of water and Faraday's law in JavaScript]]></title><description><![CDATA[Electrolysis of water splits it with a current: 2H₂O → 2H₂ + O₂. Faraday's first law tells how much gas a given charge releases. (I build PractiSci, where…]]></description><link>https://practisci.hashnode.dev/electrolysis-of-water-and-faraday-s-law-in-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/electrolysis-of-water-and-faraday-s-law-in-javascript</guid><category><![CDATA[chemistry]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[education]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Tue, 17 Nov 2026 12:18:33 GMT</pubDate><content:encoded><![CDATA[<p>Electrolysis of water splits it with a current: 2H₂O → 2H₂ + O₂. Faraday's first law tells how much gas a given charge releases. (I build <a href="https://www.practisci.in">PractiSci</a>, where electrolysis of water is a free virtual lab.)</p>
<h2>How much hydrogen does a current release?</h2>
<p>At the cathode 2H₂O + 2e⁻ → H₂ + 2OH⁻, so each mole of H₂ needs 2 F of charge (F = 96485 C/mol). The anode gives half as many moles of O₂ (4 e⁻ per O₂), hence the 2 : 1 volume ratio.</p>
<pre><code class="language-js">const F = 96485, Vm = 22400; // mL per mole at STP
const molH2 = (I, t) =&gt; (I * t) / (2 * F);
const timeForH2 = (mL, I) =&gt; ((mL / Vm) * 2 * F) / I;

console.log(timeForH2(224, 0.5).toFixed(0));         // 3859 s
console.log((timeForH2(224, 0.5) / 60).toFixed(1));  // 64.3 min
console.log(molH2(0.5, 3859) * Vm / 2);              // ≈ 112 mL of O2
</code></pre>
<p>So collecting 224 mL of H₂ at STP with 0.5 A takes about 64 minutes, with about 112 mL of O₂ at the other electrode.</p>
<h2>Why add a little acid?</h2>
<p>Pure water conducts very poorly. A little dilute H₂SO₄ or Na₂SO₄ supplies ions without being used up, so the net reaction is still 2H₂O → 2H₂ + O₂.</p>
<h2>FAQ</h2>
<h3>Why is the gas volume ratio 2 : 1?</h3>
<p>Two moles of H₂ form for every mole of O₂ in the overall equation.</p>
<h3>What is the minimum voltage?</h3>
<p>The theoretical decomposition voltage is about 1.23 V; real cells need more because of overpotential.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/chem-electrolysis-water">electrolysis of water lab</a> shows both gases collecting. The <a href="https://www.practisci.in/practicals/class-12-chemistry">class 12 chemistry practicals</a> page lists related labs.</p>
]]></content:encoded></item><item><title><![CDATA[The work-energy theorem with a variable force in JavaScript]]></title><description><![CDATA[The work-energy theorem says the net work done on a body equals its change in kinetic energy: W = ΔKE = ½mv² − ½mu². With a force that changes along the…]]></description><link>https://practisci.hashnode.dev/the-work-energy-theorem-with-a-variable-force-in-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/the-work-energy-theorem-with-a-variable-force-in-javascript</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[education]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Tue, 17 Nov 2026 12:17:42 GMT</pubDate><content:encoded><![CDATA[<p>The work-energy theorem says the net work done on a body equals its change in kinetic energy: W = ΔKE = ½mv² − ½mu². With a force that changes along the path, work is the area under the F–x graph, which a short loop can compute. (I build <a href="https://www.practisci.in">PractiSci</a>, where the theorem is a free virtual lab.)</p>
<h2>How do I find work done by a variable force?</h2>
<p>Integrate F(x) over the path. Take F = 10 + 5x newtons acting on a 2 kg body that starts at rest, from x = 0 to 4 m.</p>
<pre><code class="language-js">const F = (x) =&gt; 10 + 5 * x;
let W = 0; const dx = 1e-4;
for (let x = 0; x &lt; 4; x += dx) W += F(x + dx / 2) * dx;
console.log(W.toFixed(2));                       // 80.00 J
console.log(Math.sqrt((2 * W) / 2).toFixed(2));  // 8.94 m/s
</code></pre>
<p>The exact area is 10·4 + ½·5·4² = 80 J, and v = √(2W/m) = 8.94 m/s.</p>
<h2>How far does a braking car travel?</h2>
<p>A 1000 kg car at 20 m/s is stopped by a constant 5000 N force. Work removes all its kinetic energy: F·d = ½mv².</p>
<pre><code class="language-js">console.log(((0.5 * 1000 * 20 ** 2) / 5000).toFixed(1)); // 40.0 m
</code></pre>
<h2>FAQ</h2>
<h3>Does the theorem work with friction?</h3>
<p>Yes, as long as W is the net work from all forces, friction included.</p>
<h3>Is work a vector?</h3>
<p>No. It is a scalar, positive when the force has a component along the motion.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/11-5-work-energy-theorem">work-energy theorem lab</a> lets you change the force and mass. The <a href="https://www.practisci.in/topics/work-energy-power">work, energy and power guide</a> has the theory.</p>
]]></content:encoded></item><item><title><![CDATA[Eddy currents: induced emf and losses in JavaScript]]></title><description><![CDATA[Eddy currents are loops of current induced in a bulk conductor by a changing magnetic flux, and they follow Lenz's law, so they oppose the change that…]]></description><link>https://practisci.hashnode.dev/eddy-currents-induced-emf-and-losses-in-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/eddy-currents-induced-emf-and-losses-in-javascript</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[education]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Tue, 17 Nov 2026 12:16:46 GMT</pubDate><content:encoded><![CDATA[<p>Eddy currents are loops of current induced in a bulk conductor by a changing magnetic flux, and they follow Lenz's law, so they oppose the change that makes them. Here is the emf of a spinning disc and the scaling rule behind transformer laminations. (I build <a href="https://www.practisci.in">PractiSci</a>, where eddy currents are a free virtual lab.)</p>
<h2>What is the emf in a rotating disc?</h2>
<p>For a conducting disc of radius R spinning at angular speed ω in a uniform field B (perpendicular to it), the emf between centre and rim is ε = ½ B ω R².</p>
<pre><code class="language-js">const emf = (B, w, R) =&gt; 0.5 * B * w * R * R;
console.log(emf(0.5, 100, 0.1).toFixed(2)); // 0.25 V
</code></pre>
<h2>Why do laminations reduce the loss?</h2>
<p>Eddy-current power loss scales as P ∝ B² f² t², where t is the sheet thickness. Splitting the core into thin insulated sheets cuts t.</p>
<pre><code class="language-js">const loss = (B, f, t) =&gt; (B * f * t) ** 2; // relative units
const base = loss(1, 50, 1);
console.log(loss(1, 50, 0.5) / base);  // 0.25  (half thickness)
console.log(loss(1, 100, 1) / base);   // 4     (double frequency)
</code></pre>
<p>Half the thickness gives one quarter of the loss, and doubling the frequency gives four times the loss.</p>
<h2>Where are eddy currents useful?</h2>
<p>Induction cooktops, electromagnetic braking, and damping in galvanometers use them on purpose. Transformers and motors fight them with laminated cores.</p>
<h2>FAQ</h2>
<h3>Do eddy currents obey Lenz's law?</h3>
<p>Yes. They flow so that their magnetic effect opposes the change in flux, which is why a magnet falls slowly through a copper tube.</p>
<h3>Why not use a solid iron core?</h3>
<p>A solid core allows large loops, so large losses and heating.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/12-6-eddy-currents">eddy currents lab</a> lets you change the plate and the speed. The <a href="https://www.practisci.in/topics/electromagnetic-induction">electromagnetic induction guide</a> has the theory.</p>
]]></content:encoded></item><item><title><![CDATA[The electromagnetic spectrum in a few lines of JavaScript]]></title><description><![CDATA[The electromagnetic spectrum is one family of waves that all travel at c = 3 × 10⁸ m/s in vacuum, so wavelength and frequency are linked by c = fλ. A few…]]></description><link>https://practisci.hashnode.dev/the-electromagnetic-spectrum-in-a-few-lines-of-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/the-electromagnetic-spectrum-in-a-few-lines-of-javascript</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[education]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Tue, 17 Nov 2026 12:15:33 GMT</pubDate><content:encoded><![CDATA[<p>The electromagnetic spectrum is one family of waves that all travel at c = 3 × 10⁸ m/s in vacuum, so wavelength and frequency are linked by c = fλ. A few lines of JavaScript turn that into a calculator that also names the band. (I build <a href="https://www.practisci.in">PractiSci</a>, where the spectrum is a free virtual lab.)</p>
<h2>What is the relation between wavelength, frequency and energy?</h2>
<p>c = fλ and photon energy E = hf. Only the number changes between a radio wave and a gamma ray, not the physics.</p>
<pre><code class="language-js">const c = 3e8, h = 6.626e-34, e = 1.602e-19;
const wavelength = (f) =&gt; c / f;
const frequency = (l) =&gt; c / l;
const eV = (f) =&gt; (h * f) / e;

console.log(wavelength(100e6));              // 3 m  (FM radio, 100 MHz)
console.log((wavelength(2.45e9) * 100).toFixed(1)); // 12.2 cm (microwave oven)
console.log(frequency(700e-9).toExponential(3));    // 4.286e+14 Hz (red light)
console.log(eV(frequency(700e-9)).toFixed(2));      // 1.77 eV
</code></pre>
<h2>How do I tell which band a wavelength belongs to?</h2>
<pre><code class="language-js">const band = (l) =&gt;
  l &lt; 1e-11 ? 'gamma' : l &lt; 1e-8 ? 'X-ray' : l &lt; 4e-7 ? 'ultraviolet' :
  l &lt; 7e-7 ? 'visible' : l &lt; 1e-3 ? 'infrared' : l &lt; 1 ? 'microwave' : 'radio';
</code></pre>
<table>
<thead>
<tr>
<th>Wavelength</th>
<th>Band</th>
</tr>
</thead>
<tbody><tr>
<td>1 pm</td>
<td>gamma</td>
</tr>
<tr>
<td>1 nm</td>
<td>X-ray</td>
</tr>
<tr>
<td>300 nm</td>
<td>ultraviolet</td>
</tr>
<tr>
<td>550 nm</td>
<td>visible (green)</td>
</tr>
<tr>
<td>10 µm</td>
<td>infrared</td>
</tr>
<tr>
<td>12.2 cm</td>
<td>microwave</td>
</tr>
<tr>
<td>3 m</td>
<td>radio</td>
</tr>
</tbody></table>
<p>The band edges are conventional, so textbooks differ a little at the boundaries.</p>
<h2>FAQ</h2>
<h3>Do all electromagnetic waves travel at the same speed?</h3>
<p>Yes, in vacuum all of them travel at 3 × 10⁸ m/s. Only frequency and wavelength differ.</p>
<h3>Which band has the most energetic photons?</h3>
<p>Gamma rays, because E = hf grows with frequency.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/12-8-em-spectrum">electromagnetic spectrum lab</a> lets you slide across the bands. The <a href="https://www.practisci.in/topics/wave-optics">wave optics guide</a> has the theory.</p>
]]></content:encoded></item><item><title><![CDATA[The Doppler effect formula in JavaScript: a passing siren and the speed of the source]]></title><description><![CDATA[Code the Doppler effect formula in JavaScript: a passing 700 Hz siren, observer and source motion, and how to find the speed from the shift.]]></description><link>https://practisci.hashnode.dev/the-doppler-effect-formula-in-javascript-a-passing-siren-and-the-speed-of-the-source</link><guid isPermaLink="true">https://practisci.hashnode.dev/the-doppler-effect-formula-in-javascript-a-passing-siren-and-the-speed-of-the-source</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Physics]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Sat, 14 Nov 2026 11:44:52 GMT</pubDate><content:encoded><![CDATA[<p>The Doppler effect changes the pitch you hear when a source or an observer moves. The formula is f′ = f (v + v₀)/(v − vₛ), and it fits in one JavaScript function. Below I use it for a passing siren and then work backwards to find the speed of the source. (I build <a href="https://www.practisci.in">PractiSci</a>, where the Doppler effect is a free virtual lab.)</p>
<h2>What is the Doppler effect formula?</h2>
<p>For sound with speed v = 343 m/s, f′ = f (v + v₀)/(v − vₛ). Take v₀ positive when the observer moves toward the source and vₛ positive when the source moves toward the observer.</p>
<pre><code class="language-js">const v = 343;
const doppler = (f, vo, vs) =&gt; f * (v + vo) / (v - vs);

console.log(doppler(500, 0, 30).toFixed(1));   // 547.9  source approaching at 30 m/s
console.log(doppler(500, 0, -30).toFixed(1));  // 459.8  source receding
console.log(doppler(500, 20, 0).toFixed(1));   // 529.2  observer approaching at 20 m/s
console.log(doppler(500, -20, 0).toFixed(1));  // 470.8  observer receding
console.log(doppler(500, 20, 30).toFixed(1));  // 579.9  both approaching
</code></pre>
<h2>What does a passing siren sound like?</h2>
<p>A police car with a 700 Hz siren moving at 30 m/s sounds like <strong>767.1 Hz</strong> as it comes toward you and <strong>643.7 Hz</strong> as it moves away. The drop of about 123 Hz is the familiar "neeeeow" as it passes.</p>
<h2>How do I find the speed of the source?</h2>
<p>Rearrange for a source moving toward a still observer: vₛ = v (1 − f/f′).</p>
<pre><code class="language-js">const speedFromShift = (f, fobs) =&gt; v * (1 - f / fobs);
console.log(speedFromShift(700, 767.1).toFixed(1));  // 30.0 m/s
</code></pre>
<p>This is how a radar gun or a medical ultrasound Doppler turns a frequency shift into a speed.</p>
<h2>FAQ</h2>
<h3>Does the Doppler shift depend on the loudness?</h3>
<p>No. Only the relative motion changes the frequency. Loudness depends on distance and amplitude.</p>
<h3>Are the source and observer cases symmetrical?</h3>
<p>Not exactly. For sound, the medium matters, so moving the source and moving the observer give slightly different shifts.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/11-14-doppler-effect">Doppler effect lab</a> lets you move the source and the observer and hear the shift. The <a href="https://www.practisci.in/topics/oscillations-and-waves">oscillations and waves guide</a> has the theory.</p>
]]></content:encoded></item><item><title><![CDATA[Finding Planck's constant from photoelectric data with a least-squares fit]]></title><description><![CDATA[Fit stopping potential against frequency in JavaScript to get Planck's constant, the threshold frequency and the work function.]]></description><link>https://practisci.hashnode.dev/finding-planck-s-constant-from-photoelectric-data-with-a-least-squares-fit</link><guid isPermaLink="true">https://practisci.hashnode.dev/finding-planck-s-constant-from-photoelectric-data-with-a-least-squares-fit</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Physics]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Sat, 14 Nov 2026 11:43:07 GMT</pubDate><content:encoded><![CDATA[<p>The photoelectric effect gives a straight line: stopping potential V₀ = (h/e)f − φ/e. Fit a line to measured points and the slope gives Planck's constant, while the intercept gives the work function. Here is the least-squares fit in plain JavaScript. (I build <a href="https://www.practisci.in">PractiSci</a>, which has a free photoelectric lab where you can collect data like this.)</p>
<h2>What does the graph of stopping potential against frequency show?</h2>
<p>Einstein's equation is eV₀ = hf − φ. So V₀ against f is a straight line with slope h/e, and it cuts the frequency axis at the threshold frequency f₀ = φ/h. The intensity of light does not change the line.</p>
<h2>How do I fit the line in code?</h2>
<pre><code class="language-js">const e = 1.602e-19;
// [frequency in 1e14 Hz, stopping potential in V]
const data = [[6.0, 0.18], [7.0, 0.59], [8.0, 1.00], [9.0, 1.41], [10.0, 1.82]];

const n = data.length;
const f = data.map(d =&gt; d[0] * 1e14), v = data.map(d =&gt; d[1]);
const sum = a =&gt; a.reduce((x, y) =&gt; x + y, 0);
const sx = sum(f), sy = sum(v);
const sxx = sum(f.map(x =&gt; x * x)), sxy = sum(f.map((x, i) =&gt; x * v[i]));

const slope = (n * sxy - sx * sy) / (n * sxx - sx * sx);
const intercept = (sy - slope * sx) / n;

console.log('h =', (slope * e).toExponential(3));     // 6.568e-34 J s
console.log('threshold =', (-intercept / slope / 1e14).toFixed(2), 'x 1e14 Hz');  // 5.56
console.log('work function =', (-intercept).toFixed(2), 'eV');                      // 2.28
</code></pre>
<h2>What do the numbers mean?</h2>
<p>The slope is 4.10 × 10⁻¹⁵ V s, so h = slope × e = 6.57 × 10⁻³⁴ J s. The accepted value is 6.63 × 10⁻³⁴ J s, so the fit is within about 1%. The threshold frequency is 5.56 × 10¹⁴ Hz and the work function is 2.28 eV, close to sodium.</p>
<h2>FAQ</h2>
<h3>Why does brighter light not raise the stopping potential?</h3>
<p>Brighter light gives more photons, not more energy per photon. More photoelectrons come out, so the current rises, but V₀ stays the same.</p>
<h3>What happens below the threshold frequency?</h3>
<p>No photoelectrons are emitted, however intense the light.</p>
<h3>Where can I try it?</h3>
<p>In the free <a href="https://www.practisci.in/labs/12-11-photoelectric-effect">photoelectric effect lab</a> you change the metal, the frequency and the intensity and read the stopping potential. More Class 12 labs are in the <a href="https://www.practisci.in/labs">virtual labs list</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Simulating radioactive decay and carbon dating in JavaScript]]></title><description><![CDATA[Simulate 100,000 carbon-14 nuclei in JavaScript, compare with N = N0 e^(-lambda t), and turn a measured fraction into an age.]]></description><link>https://practisci.hashnode.dev/simulating-radioactive-decay-and-carbon-dating-in-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/simulating-radioactive-decay-and-carbon-dating-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Physics]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Sat, 14 Nov 2026 11:41:20 GMT</pubDate><content:encoded><![CDATA[<p>Radioactive decay is random for one atom but predictable for many, and a 20-line Monte Carlo simulation shows it. I simulate 100,000 carbon-14 nuclei, compare the count with N = N₀e^(−λt), and then turn a measured fraction into an age. (I build <a href="https://www.practisci.in">PractiSci</a>, where this runs as a free virtual lab.)</p>
<h2>What is the half-life, in code?</h2>
<p>Carbon-14 has a half-life of 5730 years, so λ = ln 2 / 5730 per year. Each nucleus has the same chance of decaying in a time step, p = 1 − e^(−λΔt), no matter how old it is.</p>
<pre><code class="language-js">const lambda = Math.LN2 / 5730;
const N0 = 100000;
let seed = 12345;
const rand = () =&gt; (seed = (seed * 1664525 + 1013904223) % 4294967296) / 4294967296;

const step = 500;                          // years per step
const p = 1 - Math.exp(-lambda * step);
let n = N0;
for (let t = 0; t &lt;= 11460; t += step) {
  let d = 0;
  for (let i = 0; i &lt; n; i++) if (rand() &lt; p) d++;
  n -= d;
}
</code></pre>
<h2>Does the simulation match the formula?</h2>
<table>
<thead>
<tr>
<th>Years</th>
<th>Simulated nuclei</th>
<th>N₀e^(−λt)</th>
</tr>
</thead>
<tbody><tr>
<td>0</td>
<td>100000</td>
<td>100000</td>
</tr>
<tr>
<td>2500</td>
<td>73955</td>
<td>73903</td>
</tr>
<tr>
<td>5000</td>
<td>54570</td>
<td>54616</td>
</tr>
<tr>
<td>7500</td>
<td>40408</td>
<td>40363</td>
</tr>
<tr>
<td>10000</td>
<td>29911</td>
<td>29829</td>
</tr>
</tbody></table>
<p>The two agree within about 0.3%. The small difference is the statistical noise you expect from random decays, and it shrinks as N₀ grows.</p>
<h2>How do I get an age from a measured fraction?</h2>
<p>Invert the law: t = −ln(N/N₀)/λ.</p>
<pre><code class="language-js">const age = (frac) =&gt; -Math.log(frac) / lambda;
console.log(age(0.5).toFixed(0), age(0.25).toFixed(0));  // 5730, 11460
</code></pre>
<p>A sample with half its carbon-14 left is 5730 years old, and with a quarter left it is 11,460 years old (two half-lives).</p>
<h2>FAQ</h2>
<h3>Can I predict when one atom will decay?</h3>
<p>No. Only the probability per unit time is fixed, which is why we speak of half-life for large samples.</p>
<h3>Is the decay constant the same as the half-life?</h3>
<p>No. λ = ln 2 / T½, so they are inversely related.</p>
<h3>Where can I try it?</h3>
<p>The free <a href="https://www.practisci.in/labs/12-13-radioactive-decay">radioactive decay lab</a> lets you choose the isotope and watch the count fall, and the <a href="https://www.practisci.in/labs/12-13-decay-chain-carbon-dating">carbon dating lab</a> turns a measured ratio into an age.</p>
]]></content:encoded></item><item><title><![CDATA[Simple pendulum period at large angles: the exact formula in JavaScript]]></title><description><![CDATA[Simple pendulum period beyond small angles: compute the exact value with the AGM in JavaScript and see the error of T = 2 pi sqrt(L/g).]]></description><link>https://practisci.hashnode.dev/simple-pendulum-period-at-large-angles-the-exact-formula-in-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/simple-pendulum-period-at-large-angles-the-exact-formula-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Physics]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Sat, 14 Nov 2026 11:39:36 GMT</pubDate><content:encoded><![CDATA[<p>A simple pendulum's period is T = 2π√(L/g) only for small swings. At larger angles the true period is longer, and you can compute it exactly with the arithmetic-geometric mean (AGM) in a few lines of JavaScript. Below I compare the textbook formula, a short series and the exact value for a 1 m pendulum. (I build <a href="https://www.practisci.in">PractiSci</a>, which has a free virtual pendulum lab.)</p>
<h2>What is the period of a simple pendulum?</h2>
<p>For small angles T₀ = 2π√(L/g). With L = 1 m and g = 9.81 m/s² that is 2.006 s. The formula assumes sin θ ≈ θ, which is only good for a few degrees.</p>
<h2>How do I get the exact period at large angles?</h2>
<p>The exact period is T = T₀ / AGM(1, cos(θ₀/2)). The AGM converges in a handful of steps:</p>
<pre><code class="language-js">const g = 9.81, L = 1.0;
const T0 = 2 * Math.PI * Math.sqrt(L / g);

function agm(a, b) {
  while (Math.abs(a - b) &gt; 1e-15) [a, b] = [(a + b) / 2, Math.sqrt(a * b)];
  return a;
}
const exact = (deg) =&gt; T0 / agm(1, Math.cos((deg * Math.PI / 180) / 2));
const series = (deg) =&gt; {
  const t = deg * Math.PI / 180;
  return T0 * (1 + t * t / 16 + 11 * t ** 4 / 3072);
};
</code></pre>
<h2>How wrong is the small-angle formula?</h2>
<table>
<thead>
<tr>
<th>Amplitude</th>
<th>Exact period (s)</th>
<th>Longer than T₀ by</th>
<th>Series (s)</th>
</tr>
</thead>
<tbody><tr>
<td>5°</td>
<td>2.0070</td>
<td>0.05%</td>
<td>2.0070</td>
</tr>
<tr>
<td>10°</td>
<td>2.0099</td>
<td>0.19%</td>
<td>2.0099</td>
</tr>
<tr>
<td>20°</td>
<td>2.0215</td>
<td>0.77%</td>
<td>2.0215</td>
</tr>
<tr>
<td>30°</td>
<td>2.0410</td>
<td>1.74%</td>
<td>2.0410</td>
</tr>
<tr>
<td>45°</td>
<td>2.0863</td>
<td>4.00%</td>
<td>2.0861</td>
</tr>
<tr>
<td>60°</td>
<td>2.1529</td>
<td>7.32%</td>
<td>2.1522</td>
</tr>
<tr>
<td>90°</td>
<td>2.3678</td>
<td>18.03%</td>
<td>2.3592</td>
</tr>
</tbody></table>
<p>Up to about 10° the error is under 0.2%, which is why the school experiment uses small swings. At 90° the period is already 18% longer.</p>
<h2>FAQ</h2>
<h3>Does the mass of the bob change the period?</h3>
<p>No. The mass cancels out of the equation of motion, so only L and g matter.</p>
<h3>Why do we measure 20 oscillations in the practical?</h3>
<p>Timing 20 swings divides the reaction-time error of your stopwatch by 20.</p>
<h3>Where can I try it?</h3>
<p>In the free <a href="https://www.practisci.in/labs/11-13-simple-pendulum">simple pendulum lab</a> you change the length and the amplitude and time the swings. The <a href="https://www.practisci.in/topics/oscillations-and-waves">oscillations topic guide</a> explains the theory.</p>
]]></content:encoded></item><item><title><![CDATA[Nernst equation and galvanic cell emf in a few lines of JavaScript]]></title><description><![CDATA[Nernst equation in JavaScript: compute a galvanic cell emf, its equilibrium constant, and see how a Daniell cell loses voltage as it runs.]]></description><link>https://practisci.hashnode.dev/nernst-equation-and-galvanic-cell-emf-in-a-few-lines-of-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/nernst-equation-and-galvanic-cell-emf-in-a-few-lines-of-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[chemistry]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Sat, 14 Nov 2026 11:23:34 GMT</pubDate><content:encoded><![CDATA[<p>The Nernst equation gives the voltage of a galvanic cell at any concentration: E = E° − (RT/nF) ln Q. In JavaScript it is one line, and it explains why a battery slowly loses voltage as it is used. Below I compute a copper-silver cell, find an equilibrium constant, and watch a Daniell-type cell fade. (I build <a href="https://www.practisci.in">PractiSci</a>, where these cells are free virtual labs.)</p>
<h2>What does the Nernst equation calculate?</h2>
<p>It calculates the cell potential E when the ion concentrations are not the standard 1 M. Here E° is the standard potential (cathode minus anode), n is the number of electrons, F = 96485 C/mol, and Q is the reaction quotient, for example [Cu²⁺]/[Ag⁺]² for the copper-silver cell.</p>
<h2>How do I code it?</h2>
<pre><code class="language-js">const F = 96485, R = 8.314, T = 298.15;

// E(cell) = E0 - (RT / nF) * ln(Q)
function cellEmf(e0, n, q) {
  return e0 - ((R * T) / (n * F)) * Math.log(q);
}

// Cu | Cu2+ (0.1 M) || Ag+ (0.01 M) | Ag
const e0 = 0.80 - 0.34;           // E0 cathode - E0 anode
const q = 0.1 / (0.01 ** 2);      // [Cu2+] / [Ag+]^2
console.log(cellEmf(e0, 2, q).toFixed(3), 'V');   // 0.371 V
</code></pre>
<p>The standard emf is 0.46 V, but with 0.1 M copper and only 0.01 M silver, Q = 1000 and the cell gives <strong>0.371 V</strong>. That matches the textbook answer you get with log₁₀ and 0.0591/n.</p>
<h2>What is the equilibrium constant of the cell?</h2>
<p>At equilibrium E = 0, so ln K = nFE°/RT:</p>
<pre><code class="language-js">function equilibriumK(e0, n) {
  return Math.exp((n * F * e0) / (R * T));
}
console.log(equilibriumK(e0, 2).toExponential(2));  // 3.56e+15
</code></pre>
<p>K is about 3.6 × 10¹⁵, so the reaction goes almost completely to the right: copper really does push silver out of solution.</p>
<h2>Why does a cell lose voltage as it runs?</h2>
<p>As the reaction proceeds, products build up and reactants fall, so Q grows and the log term pulls E down. For a Zn | Zn²⁺ || Cu²⁺ | Cu cell (E° = 1.10 V, both solutions starting at 1 M):</p>
<table>
<thead>
<tr>
<th>Fraction of Cu²⁺ used</th>
<th>E (V)</th>
</tr>
</thead>
<tbody><tr>
<td>0</td>
<td>1.100</td>
</tr>
<tr>
<td>0.5</td>
<td>1.086</td>
</tr>
<tr>
<td>0.9</td>
<td>1.062</td>
</tr>
<tr>
<td>0.99</td>
<td>1.032</td>
</tr>
<tr>
<td>0.999</td>
<td>1.002</td>
</tr>
</tbody></table>
<p>The fall is gentle for most of the life of the cell and steeper at the end, which is why a battery seems fine and then dies.</p>
<h2>FAQ</h2>
<h3>Which sign does E° of the anode get?</h3>
<p>Use E°cell = E°cathode − E°anode with both as reduction potentials. Do not flip the sign twice.</p>
<h3>Does n change E°?</h3>
<p>No. Electrode potentials are intensive, so doubling the half-reaction does not double E°. It only changes n in the Nernst term.</p>
<h3>Where can I try this without chemicals?</h3>
<p>In the free <a href="https://www.practisci.in/labs/chem-cell-zn-ag">zinc-silver galvanic cell lab</a> you connect the salt bridge, change the concentrations and watch the voltmeter follow this equation. The full theory, cell notation and three solved numericals are in the <a href="https://practisci-labs.blogspot.com/2026/11/galvanic-cell-diagram-class-12-parts.html">galvanic cell diagram post</a>, and more cells are on the <a href="https://www.practisci.in/practicals/class-12-chemistry">Class 12 chemistry practical list</a>.</p>
]]></content:encoded></item><item><title><![CDATA[How do you calculate Carnot engine efficiency? (JavaScript)]]></title><description><![CDATA[Carnot efficiency is 1 - Tc/Th in kelvin. A JavaScript function, a 500 K and 300 K example giving 40 percent, and why 100 percent is impossible.]]></description><link>https://practisci.hashnode.dev/how-do-you-calculate-carnot-engine-efficiency-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/how-do-you-calculate-carnot-engine-efficiency-javascript</guid><category><![CDATA[Physics]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Fri, 13 Nov 2026 15:32:04 GMT</pubDate><content:encoded><![CDATA[<p><strong>Short answer:</strong> the efficiency of a Carnot engine is <code>eta = 1 - Tc / Th</code>, with both temperatures in kelvin. An engine working between 500 K and 300 K can convert at most 40 percent of the heat it takes in into work, whatever the working substance.</p>
<h2>What is a Carnot engine?</h2>
<p>A Carnot engine is an ideal reversible heat engine that takes heat <code>Qh</code> from a hot reservoir at <code>Th</code>, does work <code>W</code>, and gives the rest <code>Qc</code> to a cold reservoir at <code>Tc</code>. It runs on two isothermal and two adiabatic steps. No real engine working between the same two temperatures can be more efficient.</p>
<h2>What is the formula?</h2>
<ul>
<li>Efficiency: <code>eta = W / Qh = 1 - Qc / Qh</code></li>
<li>For the Carnot cycle: <code>Qc / Qh = Tc / Th</code>, so <code>eta = 1 - Tc / Th</code></li>
</ul>
<p>The temperatures must be in kelvin: K = degrees Celsius + 273.</p>
<h2>How do you calculate it in JavaScript?</h2>
<pre><code class="language-js">const kelvin = (c) =&gt; c + 273;

export const carnotEfficiency = (hotK, coldK) =&gt; 1 - coldK / hotK;

export function carnot(hotK, coldK, heatIn) {
  const eta = carnotEfficiency(hotK, coldK);
  return { eta, work: eta * heatIn, heatRejected: heatIn * (1 - eta) };
}
</code></pre>
<table>
<thead>
<tr>
<th>Th</th>
<th>Tc</th>
<th>Efficiency</th>
<th>Work for 1000 J in</th>
<th>Heat rejected</th>
</tr>
</thead>
<tbody><tr>
<td>500 K</td>
<td>300 K</td>
<td>40%</td>
<td>400 J</td>
<td>600 J</td>
</tr>
<tr>
<td>600 K</td>
<td>300 K</td>
<td>50%</td>
<td>500 J</td>
<td>500 J</td>
</tr>
</tbody></table>
<p>Between 227 degrees Celsius and 27 degrees Celsius the temperatures are 500 K and 300 K, so the first row is <code>carnot(kelvin(227), kelvin(27), 1000)</code>.</p>
<h2>Can an engine be 100 percent efficient?</h2>
<p>Only if <code>Tc</code> were absolute zero, which is impossible. This is the second law of thermodynamics in numbers: some heat must always be rejected. A claim of 60 percent efficiency between 500 K and 300 K breaks the Carnot limit of 40 percent and cannot be true.</p>
<h2>How can you raise the efficiency?</h2>
<ul>
<li>Raise the hot temperature <code>Th</code>.</li>
<li>Lower the cold temperature <code>Tc</code>.</li>
</ul>
<p>Raising <code>Th</code> from 500 K to 600 K lifts the limit from 40 to 50 percent.</p>
<h2>Frequently asked questions</h2>
<h3>Why must temperatures be in kelvin?</h3>
<p>The ratio <code>Tc / Th</code> comes from the absolute scale. With Celsius values the ratio is meaningless.</p>
<h3>Does the working gas matter?</h3>
<p>No. The Carnot efficiency depends only on the two reservoir temperatures.</p>
<h3>Is a real engine as efficient as a Carnot engine?</h3>
<p>No. Friction, heat loss and irreversible steps make real engines less efficient.</p>
<h3>What is a refrigerator in this picture?</h3>
<p>A Carnot engine run backwards. Its coefficient of performance is <code>Tc / (Th - Tc)</code>.</p>
<h2>Try it in a virtual lab</h2>
<p>In the <a href="https://www.practisci.in/labs/11-11-carnot-engine">Carnot engine lab on PractiSci</a> you run the cycle on a p-V diagram and see the work and heat flows. The <a href="https://www.practisci.in/topics/thermodynamics">thermodynamics chapter guide</a> has the laws, processes and engine formulas for Class 11.</p>
]]></content:encoded></item><item><title><![CDATA[How do you use the lens formula 1/v - 1/u = 1/f? (JavaScript)]]></title><description><![CDATA[Lens formula 1/v - 1/u = 1/f with the sign convention, a JavaScript function, and worked cases for convex and concave lenses.]]></description><link>https://practisci.hashnode.dev/how-do-you-use-the-lens-formula-1-v-1-u-1-f-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/how-do-you-use-the-lens-formula-1-v-1-u-1-f-javascript</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Fri, 13 Nov 2026 15:29:26 GMT</pubDate><content:encoded><![CDATA[<p><strong>Short answer:</strong> for a thin lens, <code>1/v - 1/u = 1/f</code>, with the Cartesian sign convention. A convex lens of focal length +15 cm with an object 30 cm away forms a real, inverted image 30 cm on the other side, the same size as the object.</p>
<h2>What do u, v and f mean?</h2>
<ul>
<li><code>u</code> is the object distance, <code>v</code> the image distance and <code>f</code> the focal length, all measured from the optical centre.</li>
<li>Distances in the direction of the incident light are positive. For a real object, <code>u</code> is negative.</li>
<li>A convex lens has positive <code>f</code>, a concave lens negative <code>f</code>.</li>
</ul>
<p>Magnification is <code>m = v / u</code>. A negative <code>m</code> means an inverted image and <code>|m| &gt; 1</code> means it is enlarged.</p>
<h2>How do you calculate it in JavaScript?</h2>
<pre><code class="language-js">export function lens(f, u) {
  const v = 1 / (1 / f + 1 / u); // from 1/v = 1/f + 1/u
  return { v, m: v / u };
}
</code></pre>
<table>
<thead>
<tr>
<th>f (cm)</th>
<th>u (cm)</th>
<th>v (cm)</th>
<th>m</th>
<th>Image</th>
</tr>
</thead>
<tbody><tr>
<td>+15</td>
<td>-30</td>
<td>+30</td>
<td>-1</td>
<td>real, inverted, same size</td>
</tr>
<tr>
<td>+10</td>
<td>-5</td>
<td>-10</td>
<td>+2</td>
<td>virtual, upright, enlarged</td>
</tr>
<tr>
<td>-20</td>
<td>-40</td>
<td>-13.3</td>
<td>+0.33</td>
<td>virtual, upright, reduced</td>
</tr>
</tbody></table>
<p>The first row is the textbook case of an object at <code>2f</code>: the image forms at <code>2f</code> on the other side. The second row is a magnifying glass: an object inside the focal length gives a virtual image on the same side as the object. The third row is a diverging lens, which always gives a virtual, upright and reduced image.</p>
<h2>What is the power of a lens?</h2>
<p>Power is <code>P = 1/f</code> with <code>f</code> in metres, measured in dioptre. The +15 cm lens has <code>P = 1 / 0.15 = +6.67 D</code>, and the -20 cm lens has <code>P = -5 D</code>.</p>
<h2>Frequently asked questions</h2>
<h3>Why is the object distance negative?</h3>
<p>The Cartesian sign convention takes the direction of the incident light as positive, and the object lies on the side the light comes from.</p>
<h3>When does a convex lens give a virtual image?</h3>
<p>When the object is closer than the focal length. Then <code>v</code> comes out negative and the image is upright and enlarged.</p>
<h3>Does the lens formula work for mirrors?</h3>
<p>No. For mirrors the formula is <code>1/v + 1/u = 1/f</code>.</p>
<h3>Why does a concave lens never form a real image of a real object?</h3>
<p>It only spreads rays out, so they never meet on the other side.</p>
<h2>Try it in a virtual lab</h2>
<p>In the <a href="https://www.practisci.in/labs/12-9-lens-formula">lens formula lab on PractiSci</a> you move the object and the lens and watch the image position and size change. The <a href="https://www.practisci.in/topics/ray-optics">ray optics chapter guide</a> has the sign convention and all the formulas for Class 12.</p>
]]></content:encoded></item><item><title><![CDATA[How do you calculate fringe width in Young's double slit experiment? (JavaScript example)]]></title><description><![CDATA[Fringe width in Young's double slit experiment is lambda x D / d. Why it works, a JavaScript function and a worked 600 nm example giving 1.2 mm.]]></description><link>https://practisci.hashnode.dev/how-do-you-calculate-fringe-width-in-young-s-double-slit-experiment-javascript-example</link><guid isPermaLink="true">https://practisci.hashnode.dev/how-do-you-calculate-fringe-width-in-young-s-double-slit-experiment-javascript-example</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Fri, 13 Nov 2026 15:27:52 GMT</pubDate><content:encoded><![CDATA[<p><strong>Short answer:</strong> the fringe width in Young's double slit experiment is <code>beta = lambda * D / d</code>, where lambda is the wavelength, D the distance from the slits to the screen and d the gap between the slits. For 600 nm light, D = 1 m and d = 0.5 mm, the fringes are 1.2 mm wide.</p>
<h2>What is fringe width?</h2>
<p>Fringe width is the distance between two neighbouring bright fringes (or two neighbouring dark fringes) on the screen. The fringes are equally spaced, so one number describes the whole pattern.</p>
<h2>Why does the formula work?</h2>
<p>A bright fringe forms where the path difference between the two rays is a whole number of wavelengths. For small angles that path difference is <code>d * y / D</code>, where y is the position on the screen. Setting it equal to <code>n * lambda</code> gives <code>y = n * lambda * D / d</code>, so neighbouring fringes are <code>lambda * D / d</code> apart.</p>
<h2>How do you calculate it in JavaScript?</h2>
<pre><code class="language-js">// all lengths in metres
export const fringeWidth = (wavelength, screenDistance, slitGap) =&gt;
  (wavelength * screenDistance) / slitGap;
</code></pre>
<table>
<thead>
<tr>
<th>Wavelength</th>
<th>D</th>
<th>d</th>
<th>Fringe width</th>
</tr>
</thead>
<tbody><tr>
<td>600 nm</td>
<td>1.0 m</td>
<td>0.5 mm</td>
<td>1.2 mm</td>
</tr>
<tr>
<td>450 nm</td>
<td>1.2 m</td>
<td>0.3 mm</td>
<td>1.8 mm</td>
</tr>
</tbody></table>
<p>Here is the first row as a call: <code>fringeWidth(600e-9, 1, 0.5e-3)</code> returns <code>0.0012</code>, which is 1.2 mm.</p>
<h2>What happens when you change the setup?</h2>
<ul>
<li>A longer wavelength (red instead of blue) gives wider fringes.</li>
<li>A larger screen distance D gives wider fringes.</li>
<li>A larger slit gap d gives narrower fringes.</li>
<li>Putting the whole setup in water divides the wavelength by the refractive index (1.33), so the fringes become 1.33 times narrower.</li>
</ul>
<h2>Frequently asked questions</h2>
<h3>Why are the fringes equally spaced?</h3>
<p>Because for small angles the path difference grows in direct proportion to the position on the screen.</p>
<h3>What is at the centre of the pattern?</h3>
<p>A bright fringe, because the path difference there is zero and the two waves arrive in phase.</p>
<h3>Why must the sources be coherent?</h3>
<p>The two slits are lit by the same source, so their phase difference stays constant. Two separate bulbs would give a pattern that changes too fast to see.</p>
<h3>Why do the fringes disappear if you cover one slit?</h3>
<p>With one slit there is nothing to interfere with. You see a single-slit diffraction pattern instead.</p>
<h2>Try it in a virtual lab</h2>
<p>In the <a href="https://www.practisci.in/labs/12-10-youngs-double-slit">Young's double slit lab on PractiSci</a> you change the wavelength, slit gap and screen distance and watch the fringe pattern respond. The <a href="https://www.practisci.in/topics/wave-optics">wave optics chapter guide</a> collects interference, diffraction and polarisation for Class 12.</p>
]]></content:encoded></item><item><title><![CDATA[How to find equivalent resistance in series and parallel (with a JavaScript calculator)]]></title><description><![CDATA[Resistors in series add up, in parallel add as reciprocals. Formulas, a JavaScript calculator and a worked example with 10, 20 and 30 ohm resistors.]]></description><link>https://practisci.hashnode.dev/how-to-find-equivalent-resistance-in-series-and-parallel-with-a-javascript-calculator</link><guid isPermaLink="true">https://practisci.hashnode.dev/how-to-find-equivalent-resistance-in-series-and-parallel-with-a-javascript-calculator</guid><category><![CDATA[Physics]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Fri, 13 Nov 2026 15:25:35 GMT</pubDate><content:encoded><![CDATA[<p><strong>Short answer:</strong> resistors in series add up, <code>R = R1 + R2 + R3</code>, and resistors in parallel add as reciprocals, <code>1/R = 1/R1 + 1/R2 + 1/R3</code>. Three resistors of 10, 20 and 30 ohms give 60 ohms in series and about 5.45 ohms in parallel. Below is the reasoning, a small calculator and the mistakes to avoid.</p>
<h2>What is the equivalent resistance in series?</h2>
<p>In a series circuit the same current passes through every resistor, and the voltages across them add up. Since V = IR for each, the total resistance is the sum:</p>
<p><code>R = R1 + R2 + R3</code></p>
<p>The total is always larger than the largest single resistor.</p>
<h2>What is the equivalent resistance in parallel?</h2>
<p>In a parallel circuit every resistor has the same voltage across it, and the currents add up. Dividing the total current by that voltage gives the reciprocal rule:</p>
<p><code>1/R = 1/R1 + 1/R2 + 1/R3</code></p>
<p>The total is always smaller than the smallest single resistor. For two resistors there is a handy shortcut: <code>R = (R1 x R2) / (R1 + R2)</code>.</p>
<h2>How do you calculate it in JavaScript?</h2>
<pre><code class="language-js">export const series = (...r) =&gt; r.reduce((a, b) =&gt; a + b, 0);
export const parallel = (...r) =&gt; 1 / r.reduce((a, b) =&gt; a + 1 / b, 0);
</code></pre>
<table>
<thead>
<tr>
<th>Call</th>
<th>Result</th>
</tr>
</thead>
<tbody><tr>
<td><code>series(10, 20, 30)</code></td>
<td>60 ohm</td>
</tr>
<tr>
<td><code>parallel(10, 20, 30)</code></td>
<td>5.455 ohm</td>
</tr>
<tr>
<td><code>parallel(6, 3)</code></td>
<td>2 ohm</td>
</tr>
</tbody></table>
<h2>What current flows from a 12 V battery?</h2>
<p>Using Ohm's law, <code>I = V / R</code>:</p>
<table>
<thead>
<tr>
<th>Connection</th>
<th>Equivalent resistance</th>
<th>Current from 12 V</th>
</tr>
</thead>
<tbody><tr>
<td>Series</td>
<td>60 ohm</td>
<td>0.2 A</td>
</tr>
<tr>
<td>Parallel</td>
<td>5.455 ohm</td>
<td>2.2 A</td>
</tr>
</tbody></table>
<p>The same battery pushes eleven times more current through the parallel arrangement, which is why household appliances are connected in parallel.</p>
<h2>Frequently asked questions</h2>
<p><strong>Why is the parallel resistance smaller than every branch?</strong> Each extra branch gives the current one more path, so the total opposition falls.</p>
<p><strong>What happens if one resistor in a series circuit breaks?</strong> The circuit is open and the current stops everywhere.</p>
<p><strong>What happens if one branch of a parallel circuit breaks?</strong> The other branches keep working with the same voltage.</p>
<p><strong>What if the resistors are not identical?</strong> The same formulas hold. For <code>n</code> identical resistors R, series gives nR and parallel gives R/n.</p>
<h2>Practise it in a virtual lab</h2>
<p>The <a href="https://www.practisci.in/labs/12-3-resistor-combinations-colour-code">resistors in series and parallel lab on PractiSci</a> lets you read the colour code, connect the resistors and compare your calculated value with the measured one. The <a href="https://www.practisci.in/labs/12-3-ohms-law">Ohm's law lab</a> covers V = IR, and the <a href="https://www.practisci.in/topics/current-electricity">current electricity chapter guide</a> collects the Class 12 formulas.</p>
]]></content:encoded></item><item><title><![CDATA[Snell's law and total internal reflection in a few lines of JavaScript]]></title><description><![CDATA[Snell's law is one line of maths and one of the first formulas a Class 12 student meets in optics: n1 * sin(i) = n2 * sin(r). Writing it as a function is a…]]></description><link>https://practisci.hashnode.dev/snell-s-law-and-total-internal-reflection-in-a-few-lines-of-javascript</link><guid isPermaLink="true">https://practisci.hashnode.dev/snell-s-law-and-total-internal-reflection-in-a-few-lines-of-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Physics]]></category><dc:creator><![CDATA[Surendra Singh Kamboj]]></dc:creator><pubDate>Fri, 13 Nov 2026 14:47:00 GMT</pubDate><content:encoded><![CDATA[<p>Snell's law is one line of maths and one of the first formulas a Class 12 student meets in optics: <code>n1 * sin(i) = n2 * sin(r)</code>. Writing it as a function is a quick way to check numericals, and it shows the one case where the answer does not exist, which is total internal reflection.</p>
<h2>The code</h2>
<pre><code class="language-js">const toRad = (d) =&gt; (d * Math.PI) / 180;
const toDeg = (r) =&gt; (r * 180) / Math.PI;

// angle of refraction in degrees, or null when the ray is totally reflected
export function refract(n1, n2, incidentDeg) {
  const s = (n1 * Math.sin(toRad(incidentDeg))) / n2;
  return Math.abs(s) &gt; 1 ? null : toDeg(Math.asin(s));
}

// critical angle in degrees (only when going from denser to rarer)
export const criticalAngle = (n1, n2) =&gt; toDeg(Math.asin(n2 / n1));
</code></pre>
<h2>Four checks</h2>
<pre><code class="language-js">refract(1, 1.33, 60);        // 40.6  air to water bends towards the normal
refract(1.5, 1, 30);         // 48.6  glass to air bends away from the normal
refract(1.5, 1, 45);         // null  total internal reflection
criticalAngle(1.5, 1);       // 41.8  glass to air
</code></pre>
<p>The first line is the textbook question "a ray in air strikes water at 60 degrees, find the angle of refraction": sin r = 0.866 / 1.33 = 0.651, so r is about 40.6 degrees.</p>
<p>The third line returns <code>null</code> because 1.5 x sin 45 degrees = 1.06, which is more than 1, and no angle has a sine bigger than 1. The ray cannot leave the glass, so it reflects back inside. That is why the critical angle for glass is 41.8 degrees: beyond it, the ray stays in.</p>
<h2>It depends on the pair of materials</h2>
<pre><code class="language-js">criticalAngle(1.5, 1.33);    // 62.5  glass to water
</code></pre>
<p>Glass to water has a much larger critical angle than glass to air, because the two refractive indices are closer. This is also why an air bubble in glass or water shines like a mirror when you look at it from the side.</p>
<h2>Mistakes to avoid</h2>
<ul>
<li>Measuring the angles from the surface. Snell's law uses the angle from the <strong>normal</strong>.</li>
<li>Forgetting that total internal reflection needs light going from the <strong>denser</strong> to the rarer medium.</li>
<li>Mixing up the order of <code>n1</code> and <code>n2</code>.</li>
</ul>
<h2>See it instead of calculating it</h2>
<p>In the Snell's law and total internal reflection lab on <a href="https://www.practisci.in/labs/12-9-refraction-snell-tir">PractiSci</a> you change the angle and the two media and watch the ray bend, then cross the critical angle. If you want the theory first, the post on <a href="https://practisci-labs.blogspot.com/2026/11/what-is-refractive-index-class-12.html">what refractive index is</a> covers the definition and numericals, and the <a href="https://www.practisci.in/topics/ray-optics">ray optics chapter guide</a> has every formula in one place.</p>
]]></content:encoded></item></channel></rss>