<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ashley Chen</title>
    <description>The latest articles on DEV Community by Ashley Chen (@miri-calc).</description>
    <link>https://dev.to/miri-calc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4238050%2F9ab338ea-ead7-4bdb-adae-05293739cf9b.png</url>
      <title>DEV Community: Ashley Chen</title>
      <link>https://dev.to/miri-calc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/miri-calc"/>
    <language>en</language>
    <item>
      <title>Grams to Particles: Building a Mole Pipeline That Survives Large Numbers</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Mon, 23 Nov 2026 06:59:40 +0000</pubDate>
      <link>https://dev.to/miri-calc/grams-to-particles-building-a-mole-pipeline-that-survives-large-numbers-4nje</link>
      <guid>https://dev.to/miri-calc/grams-to-particles-building-a-mole-pipeline-that-survives-large-numbers-4nje</guid>
      <description>&lt;p&gt;Counting molecules by weighing them is a two-step conversion with a scale problem attached. The chemistry is straightforward — mass divided by molar mass gives moles, and moles times Avogadro's constant gives particles. The engineering difficulty is numerical: particle counts overflow intuition, floating point has fixed relative precision, and a molar mass assembled from rounded atomic weights shifts the last digits of every result.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pipeline
&lt;/h2&gt;

&lt;p&gt;The 2019 SI definition fixes Avogadro's constant exactly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NA = 6.02214076e23 particles per mole   (exact, no uncertainty)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two conversions connect the scales:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;moles     = mass (g) / molar mass (g/mol)
particles = moles * NA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Molar mass is a sum of standard atomic weights from the periodic table. For NaCl: 22.98976928 (Na) + 35.45 (Cl) = 58.43976928 g/mol. Those weights are interval quantities in reality; the conventional values are what calculators use, so two tools can differ in the third decimal of the molar mass and disagree in the final particle count.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;NA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;6.02214076e23&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;             &lt;span class="c1"&gt;// exact&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nc"&gt;M_NaCl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;22.98976928&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;35.45&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// g/mol&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;particlesFromGrams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;massGrams&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;molarMass&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;massGrams&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;molarMass&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RangeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'invalid inputs'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;moles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;massGrams&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;molarMass&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;moles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;particles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;moles&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;NA&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The guard is worth keeping: a zero molar mass produces Infinity, and a negative mass silently produces a negative particle count.&lt;/p&gt;

&lt;h2&gt;
  
  
  Worked example
&lt;/h2&gt;

&lt;p&gt;Take 5.0 g of NaCl.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;M(NaCl)   = 22.98976928 + 35.45 = 58.43976928 g/mol
moles     = 5.0 / 58.43976928 ≈ 0.08555817 mol
particles = 0.08555817 * 6.02214076e23
          ≈ 5.152e22 formula units
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a precision reference, 18.015 g of water with M = 2(1.008) + 15.999 = 18.015 g/mol is exactly 1.000 mol by construction, or 6.02214076e23 molecules to the precision shown. The round trip is exact in floating point because 5.0 / M * M returns 5.0 here, but that is not a guarantee for arbitrary inputs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Boundary conditions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Magnitude: a double-precision near 5e22 has a spacing (ULP) of about 8.4e6. Single-particle resolution is impossible at that scale; print 3–4 significant figures, not all sixteen digits.&lt;/li&gt;
&lt;li&gt;Rounding atomic weights early changes the answer. Using Cl = 35.453 instead of 35.45 shifts the result to about 5.152e22 still at three significant figures, but the underlying mole count differs in the fifth decimal.&lt;/li&gt;
&lt;li&gt;Solids such as NaCl consist of formula units, not discrete molecules. Gases, liquids, and molecular solids need the appropriate particle label.&lt;/li&gt;
&lt;li&gt;Hydrates, isotopes, and impurities change the effective molar mass. The pipeline assumes a pure substance with the stated composition.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;1e23&lt;/code&gt; literals exceed 32-bit integer range. Use doubles or bigint-based decimal libraries when exact digit handling matters.&lt;/li&gt;
&lt;li&gt;Avogadro's constant is exact by definition; the uncertainty lives in the measured mass and the atomic weights, not in NA.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a conversion that handles the magnitude and formatting for you, see the &lt;a href="https://www.miryori.org/tools/avogadro" rel="noopener noreferrer"&gt;Avogadro calculator&lt;/a&gt;. The &lt;a href="https://www.miryori.org/guides/avogadro-guide" rel="noopener noreferrer"&gt;Avogadro guide&lt;/a&gt; explains molar mass, formula units, and where the rounding actually enters.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>chemistry</category>
      <category>math</category>
      <category>calculator</category>
    </item>
    <item>
      <title>Two-Point Activation Energy: Log-Transform First, Mind the Units</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Mon, 23 Nov 2026 06:58:44 +0000</pubDate>
      <link>https://dev.to/miri-calc/two-point-activation-energy-log-transform-first-mind-the-units-26m6</link>
      <guid>https://dev.to/miri-calc/two-point-activation-energy-log-transform-first-mind-the-units-26m6</guid>
      <description>&lt;p&gt;Fitting an activation energy from two rate measurements is a common engineering task and a reliable source of silent bugs. The algebra is short, but two decisions dominate the result: taking the natural log before subtracting, and keeping the gas constant and the activation energy in compatible energy units. A third problem arrives after the arithmetic — the number is only as trustworthy as the temperature range behind it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deriving the two-point form
&lt;/h2&gt;

&lt;p&gt;The Arrhenius equation relates a rate constant to temperature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k = A * exp(-Ea / (R * T))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;T is absolute temperature in kelvin, R is the gas constant, and Ea is activation energy per mole. Taking &lt;code&gt;ln&lt;/code&gt; of both sides makes it linear in &lt;code&gt;1/T&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ln(k) = ln(A) - (Ea / R) * (1/T)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Write that at two temperatures and subtract, eliminating the unknown pre-exponential factor A:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ln(k2/k1) = -(Ea/R) * (1/T2 - 1/T1)
          = (Ea/R) * (1/T1 - 1/T2)

Ea = R * ln(k2/k1) / (1/T1 - 1/T2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sign check is useful in code: if k rises with temperature (k2 &amp;gt; k1 at T2 &amp;gt; T1), then both &lt;code&gt;ln(k2/k1)&lt;/code&gt; and &lt;code&gt;1/T1 - 1/T2&lt;/code&gt; are positive, so Ea is positive. A negative result means the temperatures were swapped or the rate ratio was inverted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;R&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;8.31446261815324&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;            &lt;span class="c1"&gt;// J/(mol*K)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;twoPointEa&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;T1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;T2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="no"&gt;R&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k2&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;k1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;T1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;T2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// J/mol&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Worked example
&lt;/h2&gt;

&lt;p&gt;Suppose a rate doubles from 300 K to 310 K: k1 = 0.010 s⁻¹, k2 = 0.020 s⁻¹.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ln(k2/k1)      = ln(2) ≈ 0.693147
1/300 - 1/310  = 0.00333333 - 0.00322581 ≈ 0.000107527 K⁻¹
Ea             = 8.31446 * 0.693147 / 0.000107527
               ≈ 53597 J/mol = 53.60 kJ/mol
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using R = 0.00831446 kJ/(mol·K) with the same inputs gives 53.60 kJ/mol directly. What breaks is mixing them: dividing by 1000 only at the end is fine, but replacing R with 0.008314 and then reporting the result in J/mol produces a number 1000 times too small.&lt;/p&gt;

&lt;p&gt;Extrapolation is the other hazard. Extending the fitted Ea from 310 K to 320 K predicts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k(320)/k(300) = exp(-(Ea/R) * (1/320 - 1/300)) ≈ 3.83
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is a large claim from two measurements ten kelvin apart, and it assumes a single constant Ea over the whole interval.&lt;/p&gt;

&lt;h2&gt;
  
  
  Boundary conditions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Temperatures must be kelvin. Substituting Celsius in the reciprocal terms is a common and often plausible-looking error.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ln&lt;/code&gt;, not &lt;code&gt;log10&lt;/code&gt;. If you use base-10 logs, multiply by &lt;code&gt;ln(10)&lt;/code&gt; ≈ 2.302585.&lt;/li&gt;
&lt;li&gt;R is per mole. If Ea is expressed per molecule, use the Boltzmann constant instead.&lt;/li&gt;
&lt;li&gt;k1 == k2 makes the log zero and implies Ea = 0; T1 == T2 divides by zero. Validate both.&lt;/li&gt;
&lt;li&gt;Two points cannot detect curvature. A changing mechanism, phase transition, catalyst deactivation, or diffusion limit means Ea is not constant over the range.&lt;/li&gt;
&lt;li&gt;The derived Ea is an effective parameter valid only over the measured interval, not a universal material constant.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a calculation that shows the units alongside the result, try the &lt;a href="https://www.miryori.org/tools/arrhenius-equation" rel="noopener noreferrer"&gt;Arrhenius equation calculator&lt;/a&gt;. The &lt;a href="https://www.miryori.org/guides/arrhenius-equation-guide" rel="noopener noreferrer"&gt;Arrhenius equation guide&lt;/a&gt; covers the linearization and where two-point estimates stop being reliable.&lt;/p&gt;

</description>
      <category>python</category>
      <category>chemistry</category>
      <category>math</category>
      <category>calculator</category>
    </item>
    <item>
      <title>Anion Gap With and Without Potassium: Why Two Calculators Disagree</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Mon, 23 Nov 2026 06:58:35 +0000</pubDate>
      <link>https://dev.to/miri-calc/anion-gap-with-and-without-potassium-why-two-calculators-disagree-4c45</link>
      <guid>https://dev.to/miri-calc/anion-gap-with-and-without-potassium-why-two-calculators-disagree-4c45</guid>
      <description>&lt;p&gt;The anion gap is a one-line calculation from a basic metabolic panel, yet two competent implementations can return answers 4 mEq/L apart for the same patient. The cause is usually not arithmetic. It is a silent convention choice: whether potassium sits on the cation side of the expression. If you are wiring this into software, the convention has to be explicit, because the reference range only makes sense alongside it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The two expressions
&lt;/h2&gt;

&lt;p&gt;The conventional definition sums the measured cations that are not sodium and subtracts the measured anions that are not chloride or bicarbonate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AG (without K) = Na+ - (Cl- + HCO3-)
AG (with K)    = (Na+ + K+) - (Cl- + HCO3-)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All terms are in mEq/L; for these singly charged ions that is numerically the same as mmol/L. Adding potassium raises the result by exactly the serum potassium concentration. A library that documents only "anion gap = Na - Cl - HCO3" has already picked one convention, and a downstream rule such as "elevated above 12" inherits that choice without saying so.&lt;/p&gt;

&lt;p&gt;A small implementation makes the branch impossible to miss:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;anionGap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;na&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hco3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;includeK&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;cations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;includeK&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;na&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;na&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cations&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cl&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;hco3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// albumin correction, conventionally applied to the K-free gap:&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;corrected&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gap&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;gap&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;2.5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;4.0&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;albumin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The albumin term matters because albumin is the largest unmeasured anion. A low albumin lowers the "normal" gap; adding 2.5 mEq/L for every 1 g/dL below 4 g/dL is a common correction, but it is a convention too, not a law.&lt;/p&gt;

&lt;h2&gt;
  
  
  Worked example
&lt;/h2&gt;

&lt;p&gt;Take Na+ 140, Cl- 104, HCO3- 24, K+ 4.0 mEq/L, albumin 3.0 g/dL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;without K: 140 - (104 + 24) = 140 - 128 = 12 mEq/L
with K:    (140 + 4.0) - 128 = 144 - 128 = 16 mEq/L
albumin-corrected (K-free): 12 + 2.5 * (4.0 - 3.0) = 14.5 mEq/L
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three defensible numbers from one panel: 12, 16, and 14.5. The 4 mEq/L spread is precisely the potassium, and the corrected value sits halfway because the albumin is 1 g/dL low. Any interface that displays a single "normal / high" badge must state which of these it used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Boundary conditions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Reference intervals are method- and laboratory-specific. A range quoted for the K-free formula is not transferable to the K-inclusive one; hard-code neither without a source.&lt;/li&gt;
&lt;li&gt;The albumin correction assumes the 2.5 coefficient and a 4 g/dL reference. Severe hypokalemia, hyperkalemia, or paraproteinemia break the simple unmeasured-anion picture.&lt;/li&gt;
&lt;li&gt;Unmeasured anions (lactate, ketones, salicylate, sulfate) and unmeasured cations (calcium, magnesium) move the gap; a normal value does not exclude a mixed disorder.&lt;/li&gt;
&lt;li&gt;Round at the end. Inputs are reported to integer or one-decimal precision, so extra digits in the output imply accuracy the panel does not have.&lt;/li&gt;
&lt;li&gt;This is a screening calculation, not a diagnosis. Clinical interpretation depends on history, acid-base status, and the rest of the panel.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a transparent implementation that exposes the potassium convention and the albumin correction separately, see the &lt;a href="https://www.miryori.org/tools/anion-gap" rel="noopener noreferrer"&gt;anion gap calculator&lt;/a&gt;. The accompanying &lt;a href="https://www.miryori.org/guides/anion-gap-guide" rel="noopener noreferrer"&gt;anion gap guide&lt;/a&gt; walks through how reference ranges change with the formula convention.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;YMYL note: This is educational content about a laboratory calculation, not medical advice. Interpretation of electrolyte results requires a qualified clinician.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>health</category>
      <category>chemistry</category>
      <category>calculator</category>
    </item>
    <item>
      <title>Inflation Adjustment in Code: Use Annual Averages, Not December-to-December</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Sat, 21 Nov 2026 17:37:15 +0000</pubDate>
      <link>https://dev.to/miri-calc/inflation-adjustment-in-code-use-annual-averages-not-december-to-december-45l</link>
      <guid>https://dev.to/miri-calc/inflation-adjustment-in-code-use-annual-averages-not-december-to-december-45l</guid>
      <description>&lt;p&gt;The sentence "$100 in 2000 is worth $X today" hides a choice that changes the answer: which two CPI observations you divide. Pick December 2000 and December 2024, or the 2000 and 2024 annual averages, and you get two defensible but different numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The formula
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;amount_today&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;amount_then&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CPI_today&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;CPI_then&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CPI here is an index, not a currency amount, so the ratio is dimensionless. The U.S. Bureau of Labor Statistics publishes both monthly values and annual averages for CPI-U; the series and the averaging convention must be the same on both sides.&lt;/p&gt;

&lt;h2&gt;
  
  
  Worked example with annual averages
&lt;/h2&gt;

&lt;p&gt;BLS annual-average CPI-U: 2000 = 172.2, 2024 = 313.689.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;factor = 313.689 / 172.2 ≈ 1.82177
$100 in 2000 -&amp;gt; 100 * 1.82177 ≈ $182.18 in 2024 dollars
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reverse direction is a different division, not the same operation with the sign flipped:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$100 in 2024 -&amp;gt; 100 * 172.2 / 313.689 ≈ $54.89 in 2000 dollars
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;adjust&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cpiThen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cpiNow&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cpiThen&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cpiNow&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RangeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'CPI must be positive'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;cpiNow&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;cpiThen&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Three edge cases that matter
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Mismatched series.&lt;/strong&gt; CPI-U and CPI-W are different populations; core CPI excludes food and energy. Mixing them produces a number that looks precise and means nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mismatched frequency.&lt;/strong&gt; A monthly index divided by an annual average introduces seasonality. Either use both annual averages or both same-month observations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A personal basket is not CPI-U.&lt;/strong&gt; Your own expenses have different weights. An index ratio answers "same basket of average urban consumers", not "what I actually spent".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Rounding is worth handling too: keep full precision through the division and round only the displayed currency value. Rounding the CPI ratio to two decimals before multiplying shifts a $100 comparison by cents to dollars depending on the span.&lt;/p&gt;

&lt;p&gt;You can check other year pairs and see the factor explicitly in the &lt;a href="https://www.miryori.org/tools/inflation-calculator" rel="noopener noreferrer"&gt;inflation calculator&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://candied-catamaran-1e7.notion.site/Inflation-How-a-Percentage-Becomes-a-Price-4187ee28dd578107a6bdccee046d8cdf" rel="noopener noreferrer"&gt;Inflation: how a percentage becomes a price&lt;/a&gt; — the same ratio explained from the purchasing-power side.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.todoexpertos.com/preguntas/8n5dcoxt3foi5p6b/por-que-la-inflacion-genera-incertidumbre-en-la-economia-de-un-pais" rel="noopener noreferrer"&gt;Why inflation creates uncertainty in an economy&lt;/a&gt; — a worked Spanish-language example with a $100 comparison.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;YMYL note: CPI-based conversions are informational estimates for a national average basket, not financial or tax advice. Use official tables for filings or contractual indexation.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>finance</category>
      <category>python</category>
      <category>math</category>
      <category>calculator</category>
    </item>
    <item>
      <title>Generation Boundaries in Code: Why 1996 and 1997 Fall on Opposite Sides</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Sat, 21 Nov 2026 17:36:04 +0000</pubDate>
      <link>https://dev.to/miri-calc/generation-boundaries-in-code-why-1996-and-1997-fall-on-opposite-sides-ajo</link>
      <guid>https://dev.to/miri-calc/generation-boundaries-in-code-why-1996-and-1997-fall-on-opposite-sides-ajo</guid>
      <description>&lt;p&gt;"Millennial" sounds like a fuzzy label, but any program that assigns one has to make it a hard interval. The moment you encode it, two questions appear: which authority defines the cutoffs, and what happens at a birthday exactly on the boundary.&lt;/p&gt;

&lt;h2&gt;
  
  
  One definition, expressed as cutoffs
&lt;/h2&gt;

&lt;p&gt;The Pew Research Center's widely used ranges put Millennials at 1981–1996 and Gen Z at 1997–2012. The rest of the ladder: Gen X 1965–1980, Boomers 1946–1964, the Silent generation 1928–1945. A table of half-open intervals &lt;code&gt;[start, end)&lt;/code&gt; removes the ambiguity at the joins:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;COHORTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1928&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1946&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Silent'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1946&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1965&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Baby Boomer'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1965&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1981&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Gen X'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1981&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1997&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Millennial'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1997&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2013&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Gen Z'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;cohort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;COHORTS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;year&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;year&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'outside defined range'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;1996 -&amp;gt; Millennial&lt;/code&gt;, &lt;code&gt;1997 -&amp;gt; Gen Z&lt;/code&gt;. With an inclusive upper bound (&lt;code&gt;year &amp;lt;= 1997&lt;/code&gt;) both would be Millennial — which is why the end year is stored as the &lt;em&gt;next&lt;/em&gt; cohort's start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Worked example: the edge years
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Birth year&lt;/th&gt;
&lt;th&gt;Interval matched&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1980&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[1965, 1981)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Gen X&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1981&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[1981, 1997)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Millennial&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1996&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[1981, 1997)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Millennial&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1997&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[1997, 2013)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Gen Z&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice that 1980 and 1996 are the last year of their cohorts, not the first year of the next one. That is a deliberate consequence of the half-open convention, not a bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  The part that isn't arithmetic
&lt;/h2&gt;

&lt;p&gt;There is no ISO standard for generation boundaries. Pew's ranges differ from the U.S. Census Bureau's and from Strauss–Howe's generational theory. A program that presents one mapping as &lt;em&gt;the&lt;/em&gt; answer is making an editorial choice, so expose the source with the result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;cohortWithSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;cohort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Pew Research Center (2023)'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your data is a full date rather than a year, decide explicitly whether someone born 31 December 1996 and someone born 1 January 1997 belong to different cohorts. Most published cutoffs are year-based, so the honest implementation truncates to the calendar year and says so.&lt;/p&gt;

&lt;p&gt;For trying other birth years and seeing the boundary behaviour directly, see the &lt;a href="https://www.miryori.org/tools/generation-calculator" rel="noopener noreferrer"&gt;generation calculator&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://miryori-tools.blogspot.com/2026/11/which-generation-are-you-ranges-and-why.html" rel="noopener noreferrer"&gt;Which generation are you? Ranges and why the boundaries move&lt;/a&gt; — a fuller discussion of why different schemes disagree.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://zenodo.org/records/24170628" rel="noopener noreferrer"&gt;Generation boundaries as a lookup problem: a worked numerical walkthrough&lt;/a&gt; — the same interval logic with additional edge cases.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>data</category>
      <category>demographics</category>
      <category>calculator</category>
    </item>
    <item>
      <title>Body Fat From Three Tape Measurements: The Navy Formula and Its Unit Trap</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Sat, 21 Nov 2026 17:35:57 +0000</pubDate>
      <link>https://dev.to/miri-calc/body-fat-from-three-tape-measurements-the-navy-formula-and-its-unit-trap-2g0m</link>
      <guid>https://dev.to/miri-calc/body-fat-from-three-tape-measurements-the-navy-formula-and-its-unit-trap-2g0m</guid>
      <description>&lt;p&gt;A tape measure cannot see inside you. The U.S. Navy circumference method is popular because it needs only three numbers for men (height, neck, waist) and four for women (add hips), but the formula is easy to get wrong in exactly the way that produces a plausible-looking answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The equations
&lt;/h2&gt;

&lt;p&gt;For men, with all measurements in &lt;strong&gt;inches&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BF% = 495 / (1.0324 - 0.19077 * log10(waist - neck) + 0.15456 * log10(height)) - 450
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For women:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BF% = 495 / (1.29579 - 0.35004 * log10(waist + hip - neck) + 0.22100 * log10(height)) - 450
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details matter more than the constants: &lt;code&gt;log10&lt;/code&gt;, not &lt;code&gt;ln&lt;/code&gt;, and the subtraction &lt;code&gt;waist - neck&lt;/code&gt; happens before the log, not after.&lt;/p&gt;

&lt;h2&gt;
  
  
  Worked example
&lt;/h2&gt;

&lt;p&gt;Male, height 70 in, neck 15 in, waist 36 in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;log10(36 - 15) = log10(21) ≈ 1.32222
log10(70)      ≈ 1.84510
denominator    = 1.0324 - 0.19077 * 1.32222 + 0.15456 * 1.84510
               ≈ 1.0324 - 0.25219 + 0.28519 = 1.06540
BF%            = 495 / 1.06540 - 450 ≈ 14.6%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The unit trap
&lt;/h2&gt;

&lt;p&gt;The coefficients were fitted in inches. If you paste centimetres into the same expression, &lt;code&gt;log10(91.44 - 38.1)&lt;/code&gt; is much larger and the result drifts badly — often into negative or absurd percentages. Convert first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;inch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cm&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cm&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;2.54&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;navyBodyFatMen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;heightCm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;neckCm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;waistCm&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;inch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heightCm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;inch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;neckCm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;inch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;waistCm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RangeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'waist must exceed neck; height &amp;gt; 0'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0324&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;0.19077&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.15456&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;495&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;450&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same person measured in centimetres (178 / 38.1 / 91.44) returns approximately 14.6% after conversion — any other answer means one of the inputs was left in the wrong unit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Boundary conditions worth testing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;waist &amp;lt;= neck&lt;/code&gt; (or &lt;code&gt;waist + hip &amp;lt;= neck&lt;/code&gt; for women): &lt;code&gt;log10&lt;/code&gt; of a non-positive number. Validate before computing.&lt;/li&gt;
&lt;li&gt;Tape location: the waist is measured at the narrowest point for men and at the widest point for women in the Navy protocol. Swapping them changes the input rather than the code.&lt;/li&gt;
&lt;li&gt;Rounding: round only the final percentage. Rounding the logs early shifts the answer by a few tenths of a point.&lt;/li&gt;
&lt;li&gt;This is an estimate from circumferences, not a body-composition measurement. Hydration, recent meals and tape tension all move the result.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a quick check with unit conversion and input validation built in, see the &lt;a href="https://www.miryori.org/tools/body-fat-calculator" rel="noopener noreferrer"&gt;body fat calculator&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://zenodo.org/records/24170627" rel="noopener noreferrer"&gt;Body-fat percentages: what the Navy circumference formula actually estimates&lt;/a&gt; — a longer numerical walkthrough of the same calculation.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;YMYL note: Body-fat estimates are informational only and are not medical advice. Circumference methods have meaningful error versus reference methods; consult a qualified clinician for health decisions.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>math</category>
      <category>health</category>
      <category>javascript</category>
      <category>calculator</category>
    </item>
    <item>
      <title>Amortização de empréstimo imobiliário em código: Cálculo exato no sistema francês (Tabela Price)</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Thu, 19 Nov 2026 05:29:53 +0000</pubDate>
      <link>https://dev.to/miri-calc/amortizacao-de-emprestimo-imobiliario-em-codigo-calculo-exato-no-sistema-frances-tabela-price-3ibe</link>
      <guid>https://dev.to/miri-calc/amortizacao-de-emprestimo-imobiliario-em-codigo-calculo-exato-no-sistema-frances-tabela-price-3ibe</guid>
      <description>&lt;p&gt;O cálculo das prestações de um empréstimo imobiliário pelo sistema francês de amortização (conhecido no Brasil como Tabela Price) baseia-se em parcelas periódicas constantes. Embora a prestação total $P$ permaneça fixa ao longo do contrato, a proporção entre juros e amortização do saldo devedor altera-se a cada mês.&lt;/p&gt;

&lt;h3&gt;
  
  
  A fórmula matemática da prestação constante
&lt;/h3&gt;

&lt;p&gt;Dado um capital inicial $PV$ (valor do empréstimo), uma taxa de juros periódica $i$ (por mês) e $n$ parcelas mensais, a prestação $P$ é dada por:&lt;/p&gt;

&lt;p&gt;$$P = PV \cdot \frac{i \cdot (1 + i)^n}{(1 + i)^n - 1}$$&lt;/p&gt;

&lt;p&gt;A cada período $k$ ($1 \le k \le n$):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Os juros do mês valem $J_k = S_{k-1} \cdot i$, onde $S_{k-1}$ é o saldo devedor remanescente.&lt;/li&gt;
&lt;li&gt;A amortização do principal vale $A_k = P - J_k$.&lt;/li&gt;
&lt;li&gt;O novo saldo devedor torna-se $S_k = S_{k-1} - A_k$.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Algoritmo de geração da tabela de amortização em Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;generate_price_schedule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pv&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;annual_rate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;monthly_rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;annual_rate&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;12.0&lt;/span&gt;
    &lt;span class="c1"&gt;# Fórmula da prestação constante&lt;/span&gt;
    &lt;span class="n"&gt;factor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;monthly_rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;months&lt;/span&gt;
    &lt;span class="n"&gt;payment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pv&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;monthly_rate&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;factor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;factor&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pv&lt;/span&gt;
    &lt;span class="n"&gt;schedule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;months&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;interest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;monthly_rate&lt;/span&gt;
        &lt;span class="n"&gt;amortization&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;payment&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;interest&lt;/span&gt;
        &lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;amortization&lt;/span&gt;
        &lt;span class="c1"&gt;# Evita saldo negativo residual por ponto flutuante no último mês&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;amortization&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt;
            &lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;

        &lt;span class="n"&gt;schedule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="s1"&gt;'month'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'payment'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'interest'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;interest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'amortization'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amortization&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'balance'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;schedule&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Casos de borda frequentes
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Ajuste na última parcela&lt;/strong&gt;: Devido ao arredondamento monetário de 2 casas decimais em cada mês, a soma das amortizações pode ter uma diferença de centavos em relação ao capital inicial. O código deve ajustar a última amortização para zerar o saldo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Taxa nominal vs. taxa efetiva contratual&lt;/strong&gt;: Certifique-se de verificar se a taxa informada no contrato é a taxa nominal dividida por 12 ($i = r/12$) ou a taxa efetiva equivalente ($i = (1+r)^{1/12} - 1$).&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Verificação interativa
&lt;/h3&gt;

&lt;p&gt;Para simular o cronograma completo de parcelas e visualizar a evolução do saldo devedor, você pode usar esta &lt;a href="https://www.miryori.org/pt/tools/amortization-calculator" rel="noopener noreferrer"&gt;calculadora de amortização de empréstimo&lt;/a&gt;, que gera a tabela detalhada mês a mês.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;Nota: Esta explicação é estritamente informativa e educacional, não constituindo consultoria financeira profissional.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>portuguese</category>
      <category>programming</category>
      <category>math</category>
      <category>finance</category>
    </item>
    <item>
      <title>APY vs APR en código: Por qué el interés nominal engaña en la rentabilidad real</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Thu, 19 Nov 2026 05:29:18 +0000</pubDate>
      <link>https://dev.to/miri-calc/apy-vs-apr-en-codigo-por-que-el-interes-nominal-engana-en-la-rentabilidad-real-29i1</link>
      <guid>https://dev.to/miri-calc/apy-vs-apr-en-codigo-por-que-el-interes-nominal-engana-en-la-rentabilidad-real-29i1</guid>
      <description>&lt;p&gt;Al desarrollar aplicaciones financieras o calculadoras de rendimiento, uno de los errores conceptuales más frecuentes es tratar la Tasa Anual Equivalente ($APY$) y el Tipo de Interés Nominal ($APR$) como equivalentes. Si un producto financiero ofrece un $5\%$ nominal con capitalización mensual, la rentabilidad real obtenida al cabo de un año es superior al $5\%$.&lt;/p&gt;

&lt;h3&gt;
  
  
  La relación matemática entre APR y APY
&lt;/h3&gt;

&lt;p&gt;Si $r$ representa la tasa nominal anual ($APR$) y $m$ el número de períodos de capitalización al año (por ejemplo, $m = 12$ para mensual, $m = 365$ para diario), la tasa efectiva anual ($APY$) se define como:&lt;/p&gt;

&lt;p&gt;$$\text{APY} = \left(1 + \frac{r}{m}\right)^m - 1$$&lt;/p&gt;

&lt;p&gt;Cuando la capitalización es continua ($m \to \infty$), el límite matemático nos da:&lt;/p&gt;

&lt;p&gt;$$\text{APY}_{\text{continuo}} = e^r - 1$$&lt;/p&gt;

&lt;h3&gt;
  
  
  Comparación de frecuencias para un APR del 6% ($r = 0{,}06$)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Frecuencia ($m$)&lt;/th&gt;
&lt;th&gt;Fórmula&lt;/th&gt;
&lt;th&gt;APY resultante&lt;/th&gt;
&lt;th&gt;Capital final para $10.000\text{ €}$&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Anual ($m = 1$)&lt;/td&gt;
&lt;td&gt;$(1 + 0{,}06)^1 - 1$&lt;/td&gt;
&lt;td&gt;$6{,}0000\%$&lt;/td&gt;
&lt;td&gt;$10.600{,}00\text{ €}$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trimestral ($m = 4$)&lt;/td&gt;
&lt;td&gt;$(1 + 0{,}015)^4 - 1$&lt;/td&gt;
&lt;td&gt;$6{,}1364\%$&lt;/td&gt;
&lt;td&gt;$10.613{,}64\text{ €}$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mensual ($m = 12$)&lt;/td&gt;
&lt;td&gt;$(1 + 0{,}005)^{12} - 1$&lt;/td&gt;
&lt;td&gt;$6{,}1678\%$&lt;/td&gt;
&lt;td&gt;$10.616{,}78\text{ €}$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Diaria ($m = 365$)&lt;/td&gt;
&lt;td&gt;$(1 + 0{,}06/365)^{365} - 1$&lt;/td&gt;
&lt;td&gt;$6{,}1831\%$&lt;/td&gt;
&lt;td&gt;$10.618{,}31\text{ €}$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Continua ($m \to \infty$)&lt;/td&gt;
&lt;td&gt;$e^{0{,}06} - 1$&lt;/td&gt;
&lt;td&gt;$6{,}1837\%$&lt;/td&gt;
&lt;td&gt;$10.618{,}37\text{ €}$&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Implementación limpia en Python y JavaScript
&lt;/h3&gt;

&lt;p&gt;Para evitar imprecisiones cuando el rendimiento es muy pequeño, en lugar de la potencia estándar se puede utilizar la función &lt;code&gt;expm1&lt;/code&gt; o la precisión flotante adecuada:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;apr_to_apy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;apr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;compounding_frequency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;compounding_frequency&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"La frecuencia debe ser mayor o igual a 0."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;compounding_frequency&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Capitalización continua&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;expm1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;apr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;period_rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;apr&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;compounding_frequency&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;period_rate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;compounding_frequency&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Verificación y simulación
&lt;/h3&gt;

&lt;p&gt;Para comprobar diferentes frecuencias de capitalización y convertir entre APR y APY de forma inmediata, puedes utilizar esta &lt;a href="https://www.miryori.org/es/tools/apy-calculator" rel="noopener noreferrer"&gt;calculadora de APY y tasa efectiva&lt;/a&gt;, que muestra el desglose paso a paso.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;Nota: Los cálculos mostrados son ejemplos matemáticos descriptivos y no constituyen asesoramiento financiero.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>espanol</category>
      <category>programming</category>
      <category>math</category>
      <category>finance</category>
    </item>
    <item>
      <title>Zinseszins-Berechnung im Code: Warum die Monats-Schleife Fließkomma-Fehler akkumuliert</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Thu, 19 Nov 2026 05:29:15 +0000</pubDate>
      <link>https://dev.to/miri-calc/zinseszins-berechnung-im-code-warum-die-monats-schleife-fliesskomma-fehler-akkumuliert-48je</link>
      <guid>https://dev.to/miri-calc/zinseszins-berechnung-im-code-warum-die-monats-schleife-fliesskomma-fehler-akkumuliert-48je</guid>
      <description>&lt;p&gt;Wenn man das Wachstum eines Depots über Jahre berechnet, greifen viele Entwickler zu einer einfachen Monats-Schleife: In jedem Schritt wird das Kapital um $(1 + r/12)$ multipliziert. Bei langen Laufzeiten oder hochfrequenten Zinsanpassungen führt diese iterative Multiplikation jedoch zu akkumulierten Rundungsfehlern in der IEEE-754-Fließkomma-Arithmetik.&lt;/p&gt;

&lt;h3&gt;
  
  
  Die mathematische geschlossene Formel
&lt;/h3&gt;

&lt;p&gt;Die exakte geschlossene Formel für das Endkapital $K_t$ nach $t$ Jahren bei einer jährlichen Verzinsung $r$ und $m$ Zinsperioden pro Jahr lautet:&lt;/p&gt;

&lt;p&gt;$$K_t = K_0 \cdot \left(1 + rac{r}{m}&lt;br&gt;
ight)^{m \cdot t}$$&lt;/p&gt;

&lt;p&gt;Für die umgekehrte Berechnung – die effektive Jahresverzinsung ($APY$) oder die mittlere jährliche Wachstumsrate ($CAGR$) – gilt:&lt;/p&gt;

&lt;p&gt;$$r_{\text{eff}} = \left(1 + \frac{r}{m}\right)^m - 1$$&lt;/p&gt;
&lt;h3&gt;
  
  
  Das Problem der schleifenträgheit im Code
&lt;/h3&gt;

&lt;p&gt;Im folgenden Vergleich sieht man, wie eine Schleife über $360$ Monate im Vergleich zur analytischen Potenzfunktion abweicht:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_growth_loop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;principal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;annual_rate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;monthly_rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;annual_rate&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;12.0&lt;/span&gt;
    &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;principal&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;monthly_rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_growth_closed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;principal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;annual_rate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;years&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Exakte Formel mittels math.pow oder exp(log)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;principal&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;annual_rate&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;12.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;12.0&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;years&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bei großen Summen und vielen Iterationen erzeugt die geschlossene Formel nicht nur eine Laufzeit von $\mathcal{O}(1)$ statt $\mathcal{O}(N)$, sondern vermeidet auch den exponentiellen Aufbau von Rundungsungenauigkeiten.&lt;/p&gt;

&lt;h3&gt;
  
  
  Randfälle bei der Modellierung
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Negative Zinsen oder Inflation&lt;/strong&gt;: Wenn $r &amp;lt; 0$, muss $(1 + r/m) &amp;gt; 0$ bleiben, da sonst komplexe Zahlen oder &lt;code&gt;ValueError&lt;/code&gt; entstehen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gebührenabzug pro Periode&lt;/strong&gt;: Werden feste Monatsgebühren $g$ abgezogen, muss die Rekursion $K_{k+1} = K_k \cdot (1 + r/m) - g$ gelöst werden:
$$K_t = K_0 (1 + r/m)^{mt} - g \cdot rac{(1 + r/m)^{mt} - 1}{r/m}$$&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Interaktiver Rechner zur Überprüfung
&lt;/h3&gt;

&lt;p&gt;Zur schnellen Überprüfung von Zinseszins-Szenarien und zum Vergleich von eff. Jahreszins und Monatsraten steht dieser &lt;a href="https://www.miryori.org/de/tools/compound-interest-calculator" rel="noopener noreferrer"&gt;Zinseszinsrechner&lt;/a&gt; zur Verfügung. Er stellt die Formel schrittweise dar und berechnet Zinseszinsen ohne Schleifenfehler.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;Hinweis: Alle Berechnungen dienen reinen Bildungs- und Modellierungszwecken und stellen keine Finanzberatung dar.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>german</category>
      <category>programming</category>
      <category>math</category>
      <category>finance</category>
    </item>
    <item>
      <title>고정 금리 대출 월 상환액 코드 구현: 놓치기 쉬운 3가지 경계 조건</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Tue, 17 Nov 2026 08:32:16 +0000</pubDate>
      <link>https://dev.to/miri-calc/gojeong-geumri-daecul-weol-sanghwanaeg-kodeu-guhyeon-nohcigi-swiun-3gaji-gyeonggye-jogeon-1p03</link>
      <guid>https://dev.to/miri-calc/gojeong-geumri-daecul-weol-sanghwanaeg-kodeu-guhyeon-nohcigi-swiun-3gaji-gyeonggye-jogeon-1p03</guid>
      <description>&lt;p&gt;고정 금리 대출의 월 상환액을 계산할 때 가장 흔한 실수는 이자율을 그대로 사용하는 것입니다. 연 6% 이자율을 매달 6%로 넣으면 안 됩니다. 월 이자율은 &lt;code&gt;r = 0.06 / 12&lt;/code&gt;이고, 상환 기간은 &lt;code&gt;n =年限 × 12&lt;/code&gt;개월입니다.&lt;/p&gt;

&lt;h2&gt;
  
  
  등액 상환 공식과 부동소수점 함정
&lt;/h2&gt;

&lt;p&gt;매달 같은 금액을 갚는 등액 상환(annuity) 공식은 다음과 같습니다.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;M = P × r / (1 - (1 + r)^(-n))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;여기서 &lt;code&gt;P&lt;/code&gt;는 원금, &lt;code&gt;r&lt;/code&gt;은 월 이자율, &lt;code&gt;n&lt;/code&gt;은 총 상환 횟수입니다. 이 공식을 자바스크립트로 그대로 옮기면 &lt;code&gt;(1 + r) ** -n&lt;/code&gt;에서 미세한 부동소수점 오차가 생깁니다. 아주 작은 이자율(예: &lt;code&gt;r = 0.0001&lt;/code&gt;)에서는 &lt;code&gt;1 + r&lt;/code&gt;이 1과 거의 같아져 분모가 0에 수렴하고, 결과가 불안정해집니다.&lt;/p&gt;

&lt;p&gt;실무에서는 이런 경계 조건을 위한 보완이 필요합니다.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;r === 0&lt;/code&gt;인 경우: 이자가 없으므로 &lt;code&gt;M = P / n&lt;/code&gt;으로 직접 계산&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;n&lt;/code&gt;이 매우 큰 경우: &lt;code&gt;(1 + r)^n&lt;/code&gt;이 오버플로우하지 않는지 확인&lt;/li&gt;
&lt;li&gt;화폐 단위는 부동소수점 대신 정수(센트)로 다루어 합계 오차 방지&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  원금과 이자 분해
&lt;/h2&gt;

&lt;p&gt;매달 납부액에서 이자와 원금을 나누는 것도 간단하지 않습니다. 첫 달 이자는 &lt;code&gt;P × r&lt;/code&gt;이고, 원금 상환액은 &lt;code&gt;M - P × r&lt;/code&gt;입니다. 다음 달부터는 원금 잔액이 줄어든 만큼 이자가 감소합니다. 이 과정을 반복하면 전체 상환 스케줄을 만들 수 있고, 중도 상환 시점의 잔액도 정확히 구할 수 있습니다.&lt;/p&gt;

&lt;p&gt;이런 경계 조건을 직접 구현해서 검증해 보고 싶다면 &lt;a href="https://www.miryori.org/ko/tools/loan-calculator" rel="noopener noreferrer"&gt;대출 계산기&lt;/a&gt;에서 연이자율·기간·원금을 바꿔 가며 결과를 바로 확인할 수 있습니다. 모든 계산은 브라우저에서만 이루어지며 입력값이 서버로 전송되지 않습니다.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;참고: 위 코드 예시는 소프트웨어 계산 검증용이며 금융 상품 권유가 아닙니다.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>korean</category>
    </item>
    <item>
      <title>BMI計算式のローカル実装：JASSO基準とWHO基準の境界線処理と浮動小数点誤差</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Mon, 16 Nov 2026 10:24:30 +0000</pubDate>
      <link>https://dev.to/miri-calc/bmiji-suan-shi-norokarushi-zhuang-jassoji-zhun-towhoji-zhun-nojing-jie-xian-chu-li-tofu-dong-xiao-shu-dian-wu-chai-401f</link>
      <guid>https://dev.to/miri-calc/bmiji-suan-shi-norokarushi-zhuang-jassoji-zhun-towhoji-zhun-nojing-jie-xian-chu-li-tofu-dong-xiao-shu-dian-wu-chai-401f</guid>
      <description>&lt;p&gt;WebアプリケーションでBMI（Body Mass Index）を計算する際、最も単純な数式であっても単位換算や判定境界、浮動小数点数の丸め処理で仕様の差異が生じます。&lt;/p&gt;

&lt;h2&gt;
  
  
  1. 基本計算式と単位換算の注意点
&lt;/h2&gt;

&lt;p&gt;メートル法における基本式は以下の通りです：&lt;/p&gt;

&lt;p&gt;$$BMI = \frac{\text{体重(kg)}}{\left(\text{身長(m)}\right)^2}$$&lt;/p&gt;

&lt;p&gt;JavaScriptでの最も素朴な実装例：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateBMI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;weightKg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;heightCm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;heightM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;heightCm&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heightM&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;weightKg&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heightM&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;heightM&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;注意すべき境界条件：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;単位の混同&lt;/strong&gt;: 身長を &lt;code&gt;cm&lt;/code&gt; のまま2乗してしまうと &lt;code&gt;170^2 = 28900&lt;/code&gt; となり、結果が &lt;code&gt;0.0023&lt;/code&gt; と計算されます。&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ヤード・ポンド法との換算&lt;/strong&gt;: 米国単位（&lt;code&gt;lbs&lt;/code&gt;, &lt;code&gt;in&lt;/code&gt;）の場合は係数 &lt;code&gt;703&lt;/code&gt; を乗算する必要があります：
$$BMI = \frac{\text{weight(lbs)}}{\left(\text{height(in)}\right)^2} \times 703$$&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  2. 日本肥満学会（JASSO）基準とWHO基準の違い
&lt;/h2&gt;

&lt;p&gt;同じBMI数値であっても、判定区分が異なります：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;18.5未満&lt;/strong&gt;: 低体重（やせ） — 日本・WHO共通&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;18.5以上 25.0未満&lt;/strong&gt;: 普通体重（日本基準） / 18.5〜24.9: Normal（WHO基準）&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;25.0以上&lt;/strong&gt;: 日本肥満学会では「肥満（1度〜4度）」と判定されますが、WHO国際基準では25.0〜29.9は「Pre-obese（過体重）」、30.0以上が「Obese（肥満）」に分類されます。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ステップごとの計算式と単位切り替えを試すには、&lt;a href="https://www.miryori.org/ja/tools/bmi-calculator" rel="noopener noreferrer"&gt;Miryori BMI計算ツール（日本語版）&lt;/a&gt; を利用できます。&lt;/p&gt;

&lt;h2&gt;
  
  
  Related reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://ameblo.jp/miryori-calc/entry-12984631973.html" rel="noopener noreferrer"&gt;アメブロでのBMI計算式と判定基準の日本語解説記事&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;YMYL note: 本記事は一般的な数値計算の解説であり、医学的な診断や治療の代替となるものではありません。&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>japanese</category>
      <category>javascript</category>
      <category>math</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Calcul des intérêts composés en JavaScript et Python : formule fermée vs boucles</title>
      <dc:creator>Ashley Chen</dc:creator>
      <pubDate>Mon, 16 Nov 2026 09:53:33 +0000</pubDate>
      <link>https://dev.to/miri-calc/calcul-des-interets-composes-en-javascript-et-python-formule-fermee-vs-boucles-3im7</link>
      <guid>https://dev.to/miri-calc/calcul-des-interets-composes-en-javascript-et-python-formule-fermee-vs-boucles-3im7</guid>
      <description>&lt;p&gt;Le calcul des intérêts composés avec versements périodiques est souvent implémenté via des boucles itératives mensuelles, ce qui accumule des erreurs d'arrondi sur de longues périodes.&lt;/p&gt;

&lt;h2&gt;
  
  
  La solution analytique fermée
&lt;/h2&gt;

&lt;p&gt;La capitalisation avec versements $PMT$ s'exprime par :&lt;/p&gt;

&lt;p&gt;$$A = P \cdot \left(1 + \frac{r}{n}&lt;br&gt;
ight)^{n \cdot t} + PMT \cdot \frac{\left(1 + \frac{r}{n}&lt;br&gt;
ight)^{n \cdot t} - 1}{\frac{r}{n}}$$&lt;/p&gt;

&lt;p&gt;Pour simuler des intérêts composés avec graphique et tableau de croissance en français, vous pouvez utiliser le &lt;a href="https://www.miryori.org/fr/tools/compound-interest-calculator" rel="noopener noreferrer"&gt;Miryori Compound Interest Calculator&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://linuxfr.org/users/miryori/journaux/interets-composes-en-code-pourquoi-le-calcul-mensuel-surpasse-les-approximations" rel="noopener noreferrer"&gt;une note technique sur les intérêts composés sur LinuxFr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;YMYL note: ces simulations sont des exemples mathématiques et ne sauraient remplacer un conseil financier personnalisé.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>french</category>
      <category>javascript</category>
      <category>python</category>
      <category>finance</category>
    </item>
  </channel>
</rss>
