<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by mahek on Medium]]></title>
        <description><![CDATA[Stories by mahek on Medium]]></description>
        <link>https://medium.com/@maheksanghvi2006?source=rss-ab9a93c85132------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by mahek on Medium</title>
            <link>https://medium.com/@maheksanghvi2006?source=rss-ab9a93c85132------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 15:30:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maheksanghvi2006/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Term That Refused to Vanish: From Brownian Motion to Black Scholes]]></title>
            <link>https://medium.com/@maheksanghvi2006/the-term-that-refused-to-vanish-from-brownian-motion-to-black-scholes-f7cac089b287?source=rss-ab9a93c85132------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7cac089b287</guid>
            <category><![CDATA[black-scholes-model]]></category>
            <category><![CDATA[stochastic-calculus]]></category>
            <category><![CDATA[quantitative-finance]]></category>
            <category><![CDATA[brownian-motion]]></category>
            <category><![CDATA[mathematical-finance]]></category>
            <dc:creator><![CDATA[mahek]]></dc:creator>
            <pubDate>Tue, 26 May 2026 20:43:30 GMT</pubDate>
            <atom:updated>2026-05-26T20:43:30.631Z</atom:updated>
            <content:encoded><![CDATA[<p>When we first learn calculus, it feels almost universal. Functions are smooth, changes are small, and higher-order terms disappear fast enough to ignore. The mathematics is structured and predictable.</p><p>But the moment we introduce <strong>randomness</strong>, something subtle changes.</p><p>Financial markets are not driven by smooth trajectories. Prices move through thousands of tiny shocks, arriving continuously, one after another, across every scale of time. And when randomness accumulates continuously, ordinary calculus begins to break in a very specific way.</p><p><strong>Second order</strong> terms stop <strong>vanishing</strong>.</p><p>That single fact changes everything.</p><p>The mathematics behind Black Scholes, stochastic differential equations, and Itô calculus all emerge from this one unexpected failure. To understand why, we have to begin somewhere much simpler: a coin toss random walk.</p><p>Assume you are repeatedly tossing a fair coin. The probability of heads is 0.5 and the probability of tails is also 0.5. Every time the coin lands heads, you move up by one step. Every time it lands tails, you move down by one step.</p><p>At first, this looks almost too simple to matter. The motion is completely <strong>discrete</strong>. Each move is independent of the last, and at every step the process only has two possible outcomes: up or down.</p><p>But once we start accumulating these tiny random movements over time, something more interesting begins to emerge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1gnIMpuwdI2POn_XChftmQ.png" /></figure><p>Here, instead of looking at each toss individually, we now track the cumulative position after every step. Starting from zero, each new toss either pushes the process upward or downward, causing the path to wander unpredictably through time.</p><p>This accumulated process is called a <strong>random walk</strong>.</p><p>But financial markets do not evolve in discrete daily jumps. Prices fluctuate continuously. Between any two moments, no matter how small, new trades occur, information arrives, and prices adjust again.<br>If we want to model market motion mathematically, the timestep cannot remain fixed. The intervals have to become smaller and smaller.</p><p>But a problem immediately appears.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*1UdlK2B0sCeAAO8Y5GExJw.gif" /></figure><p>As the number of steps increases, the uncertainty of the random walk keeps growing. If we simply keep adding more and more fixed jumps while shrinking the timestep toward zero, the process becomes increasingly unstable. The <strong>variance</strong> explodes rather than settling into a meaningful continuous limit.</p><p>So the jumps themselves must shrink as the number of steps grows.<br>Instead of moving by fixed increments of (+1) and (-1), we scale each step by :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/84/1*FvO_6qGZU4aO1Q6qluiICw.png" /></figure><p>This particular scaling is <strong>not arbitrary</strong>. Since variance adds across independent steps, scaling by <strong>1/√n​</strong> is exactly what keeps the <strong>total variance finite</strong> instead of exploding toward infinity.</p><p>Now the individual movements become smaller as the number of steps increases, while the total variance remains finite. The resulting process is called a <strong>scaled random walk</strong>.</p><p>And as the timestep approaches zero, this scaled random walk approaches, in a precise probabilistic sense, something far stranger:<strong> Brownian motion</strong>.</p><p>A standard Brownian motion Wₜ satisfies four key properties:</p><ul><li>Always starts at<em> W₀ = 0</em></li><li>The path is continuous, with no jumps or gaps</li><li>Future increments are independent of the past, meaning the process has no memory of previous movement</li><li>Increments over a time interval (s , t) are normally distributed, with variance proportional to the length of the interval: Wₜ − Wₛ ∼ N (0, t − s); which means the uncertainty of the process grows with time. The farther we move away from the starting point, the wider the spread of possible outcomes becomes.</li></ul><p>At first glance, this still seems compatible with ordinary calculus. After all, the path is continuous.</p><p>The problem is that Brownian motion is not merely random. It is violently irregular. If we zoom into an ordinary smooth curve, the path eventually begins to resemble a straight line. Brownian motion never does. No matter how closely we magnify the trajectory, new fluctuations continue to appear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*fHWYr7pwCIluDMHDOgFKTQ.gif" /></figure><p>Mathematically, Brownian motion is continuous everywhere and differentiable nowhere.</p><p>That single fact is enough to break the intuition ordinary calculus relies on.</p><p>To understand why ordinary calculus begins to fail, we need to look more carefully at how irregular a Brownian path actually is.</p><p>For an ordinary smooth curve, the total distance traveled along the path remains finite. If we partition the interval into smaller and smaller pieces and sum the absolute change over each segment, the quantity eventually stabilizes.</p><p>For a function f(t), this total variation is written as: <strong>∑|f(tᵢ) − f(tᵢ₋₁)|</strong></p><p>A smooth curve behaves predictably under finer partitions because locally it begins to resemble a straight line. <strong>Brownian motion does not.</strong></p><p>As we refine the partition, new fluctuations continue appearing at every scale. Instead of converging, the total variation grows without bound.</p><p>A Brownian path has <strong>infinite total variation</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*ttdGjSylKXuG7YohKXXS2A.gif" /></figure><p>But squaring the increments changes the behavior completely.Rather than summing the absolute changes, consider the quantity:<br><strong>∑ (Wₜᵢ − Wₜᵢ₋₁)²</strong></p><p>This is called the <strong>quadratic variation</strong> of the process.</p><p>Unlike total variation, this quantity does converge. As the partition becomes finer and finer, the sum approaches: <strong><em>∑ (ΔW)² → T<br></em></strong>Even though individual Brownian increments become extremely small over short time intervals, they scale like: <strong><em>ΔW ∼ √(Δt)<br></em></strong>so squaring them produces:<em>（</em><strong><em>ΔW)² ∼ Δt </em></strong>in expectation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*k8gkw0266brdW5cMGjtmxw.gif" /></figure><p>Ordinary Brownian motion adds the same absolute randomness regardless of price. Real markets do not behave this way. The magnitude of the movement depends on the current price itself. A 1% move matters more naturally than a fixed dollar jump. So instead of modeling additive changes, we model proportional changes by scaling the randomness with the stock price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3YzRzL1Ur5TWL__Uo44n6g.png" /></figure><h3>The Term That Refused to Vanish</h3><p>First, we introduce both the drift and the diffusion term, allowing the process to evolve into a full <strong>Geometric Brownian Motion</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sME_UJ7udNs3xC2WzwPgfA.png" /></figure><p>Here, μ represents the average growth rate of the stock, while σ measures the intensity of its randomness or volatility.</p><p>The <strong>drift term</strong> still behaves normally under classical calculus. But the <strong>diffusion term</strong> contains Brownian motion, and Brownian motion has non zero quadratic variation. This is exactly where classical calculus breaks and we have to turn to <strong>Itô calculus</strong>.</p><p>Prerequisites from normal calculus :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nndV-Xxd3ehurFTAU8H6Fw.png" /></figure><p>To see where the extra term comes from, we return briefly to the Taylor expansion itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O4XHiPaD3s3W3ETLG9E9KA.png" /></figure><p>Up to this point, we have treated X(t) like an ordinary variable. But once the process itself becomes stochastic, the second order Brownian terms stop vanishing and the expansion changes completely.</p><p>But first, in order to derive Itô’s lemma in full generality, we now rewrite the process in a more abstract stochastic form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g-wINDMc1JltMwUEDy9Vmw.png" /></figure><p>After substituting the stochastic differential into the Taylor expansion, we get :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ELJJ_Tc-pldc6fJMQgdEw.png" /></figure><p>As dt→0, most higher-order terms disappear exactly as they do in ordinary calculus. The exception is the Brownian term (dW²).</p><p>What is dW² actually equal to?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dTiHlAk9aEGkilw7PpmlkA.png" /></figure><p>Using the Weiner process dW = ε√dt, where ε ∼ N(0,1), we found the Expected value and Variance of the brownian motion term dW².</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XWWQAzysJjZ5F5FGqumAwA.png" /></figure><p>Even though dW² is random, its variance scales like dt². As dt → 0, we also have dt² → 0, causing the variance to become negligible. Since dt² shrinks much faster than dt itself, it becomes a higher-order infinitesimal term and vanishes in the continuous-time limit. The randomness inside the term effectively disappears, so the process behaves as a non stochastic process. Once the stochastic fluctuation vanishes, we can replace the term by its expected value: <strong>E [dW²] = dt</strong></p><p>Giving the key substitution rule of Itô calculus:: <strong>dW² = dt</strong></p><p>This is the exact moment where second-order terms stop vanishing and Itô calculus separates itself from ordinary calculus.</p><p>Bringing together every surviving term, we finally arrive at <strong>Itô’s lemma</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*je10ajj7Ba11HFqgk09B_g.png" /></figure><p>Now let’s see how to apply Itô’s lemma on an actual equation :</p><p>Since <strong>f(S)=ln⁡(S) </strong>depends only on the stock price and not explicitly on time, the time-derivative term disappears from Itô’s lemma.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*ItH75ol6B9mKxx6dz1m4XA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*03wlfkHVT-uByq6kJJ9iYA.png" /></figure><p>Lognormal property is important because :</p><ul><li>stock prices always remain positive</li><li>returns become normally distributed</li><li>price changes become multiplicative rather than additive</li></ul><p>So far, we have modeled how stock prices move under randomness and shown that under Geometric Brownian Motion, stock prices follow a lognormal distribution.</p><p>Modeling how a stock moves is only half the problem. Knowing the dynamics of the underlying asset still does not tell us how a contract built on top of that randomness should be priced. One of the simplest examples is a <strong>call option</strong>.</p><p>Suppose a stock is currently trading at $100.</p><p>Now imagine a contract that gives you the right to buy the stock for $100 six months later by paying an upfront premium of $10. This is called a call option.</p><p>If the stock rises to $120, you can still buy it for $100 and profit from the difference. If the stock falls below $100, the contract becomes useless and you simply lose the premium.</p><p>The payoff at expiry is: max(Sₜ − K, 0)</p><p>where Sₜ = stock price at expiry and K = strike price.</p><p>The buyer of the option is called the long call holder, while the seller is called the short call holder. In a European option, the contract can only be exercised at expiry.</p><p>Before constructing the hedge, recall that the stock itself still evolves stochastically through Geometric Brownian Motion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vO_NF7xwYedLoRdkyM31HQ.png" /></figure><p>To eliminate the randomness from the system, we construct a very particular portfolio. We take a long position in one option while shorting Δ units of the underlying stock. Here, Δ measures how sensitively the option price changes with respect to the stock price itself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*F_q00Ajq6SGcJ5j4K9C4FA.png" /></figure><p>By choosing this quantity carefully, the stochastic Brownian component inside the portfolio can be cancelled completely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1VZTddNwhM8rTIMrmrbfxA.png" /></figure><p>The randomness has not disappeared from the stock itself. Instead, it has been neutralized inside the portfolio through the hedge. This is the central idea behind delta hedging.</p><p>Changes in the portfolio happen every infinitesimal second so let’s calculate that :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*oBsormK4gdsH3fFTtePfYw.png" /></figure><p>Once the dW term disappears, the portfolio no longer contains any randomness. The uncertainty has been completely removed, so the portfolio becomes risk free.</p><p>A risk free portfolio should therefore grow exactly at the risk free interest rate (r):<strong> dΠ = rΠ dt</strong></p><p>If this were not true, arbitrage opportunities would appear.</p><p>Arbitrage simply means making a guaranteed profit with no risk involved. For example, if something could be bought for $100 and immediately sold for $110, we would make a guaranteed $10 profit instantly. Markets should not allow situations like this.</p><p>Now let’s look at three conditions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KOLO0lh6jIpkqGtb-AdhDA.png" /></figure><p>Let’s substitute the terms back and get the final equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*nPbKoalGiM5Sysqss2JjEQ.png" /></figure><p>And after<strong> eliminating</strong> the<strong> stochastic term</strong> through <strong>delta hedging</strong>, the <em>randomness disappears </em>entirely from the portfolio evolution. <br>What remains is a deterministic equation governing the price of the option itself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*nylrmN1m14CQ1U32OeqBmA.png" /></figure><p>This is the <strong>Black Scholes</strong> equation.</p><p>And hidden inside it is the same second-order term that refused to vanish all the way back in Brownian motion:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*L--jMMRPaRoYcepSj1WS5g.png" /></figure><p>Without <strong>quadratic variation</strong>, this term would never survive. Without that surviving term, <strong>Itô calculus</strong> would collapse back into ordinary calculus. And without Itô calculus, the mathematical foundation of modern <strong>quantitative finance</strong> would not exist.</p><p>The entire structure of Black-Scholes emerges from a single unexpected fact :</p><p><strong>Brownian motion forces second order terms to matter.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7cac089b287" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Backpropagation Through Time Isn’t Complicated — Until It Is]]></title>
            <link>https://medium.com/@maheksanghvi2006/backpropagation-through-time-isnt-complicated-until-it-is-4fb2ebf55d61?source=rss-ab9a93c85132------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fb2ebf55d61</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[mahek]]></dc:creator>
            <pubDate>Sun, 15 Mar 2026 09:52:52 GMT</pubDate>
            <atom:updated>2026-03-15T09:52:52.323Z</atom:updated>
            <content:encoded><![CDATA[<p>When we first learn backpropagation, it feels almost elegant. Gradients flow backward through layers, weights adjust, and the network slowly learns. The mathematics is structured and predictable.</p><p>But the moment we introduce time, something subtle changes.</p><p>Recurrent Neural Networks were designed for sequences: language, sentiment analysis, sentence prediction, time series, situations where the current input depends on what came before. Instead of stacking layers deeper in space, RNNs reuse the same weights across time. A single hidden state carries information forward, step after step.</p><p>At first glance, this looks like a small architectural tweak.</p><p>Mathematically, it is not.</p><p>Backpropagation is no longer just moving through layers. It is moving through time. And when gradients flow across time, they do something unexpected: they multiply.</p><p>That multiplication is where the real story begins.</p><p>Let’s take a look at the architecture of Recurrent Neural Networks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*GO_tKHvU-divMeAfhq4-Pg.gif" /></figure><p>Let’s try to understand how unfolding through time affects the gradient using a toy example:<br>Suppose you have to conduct sentiment analysis on three sentences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dC7wNGDY14YLyh08-U4AtQ.png" /></figure><p>Each word gets encoded as a one-hot vector.</p><p>Here the column for y stands for the sentiment analysis; as in if y = 1 then it’s a positive sentiment and if y = 0 then it’s a negative sentiment.<br>The model reads one word at a time, left to right, carrying a hidden state forward as it goes.</p><p>For simplicity, we’ll use just three hidden nodes and a single sigmoid output.</p><p>Here’s what that looks like unrolled across time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yMZPGHEEOClB1pHrxeTCZg.png" /></figure><p>The forward pass is governed by four equations. These define the recurrence — how the hidden state evolves, how the output is computed, and how loss is measured:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_N_gI3EypOAuLQPd50RA1g.png" /></figure><p>To minimize the loss, we apply gradient descent across three sets of parameters: input weights Wᵢ, hidden weights Wₕ, and output weights W₀. This requires computing three partial derivatives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*l5Lb7tuxP3EfirHnB72VdQ.png" /></figure><p>We compute these derivatives using a <strong>dependency graph</strong>. To find how the loss depends on a weight, you simply trace every path from that weight to the loss and apply the chain rule along each path.</p><p>We start with ∂L/∂W₀ as it’s the most straightforward, since it doesn’t involve the recurrence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*9zpM-WAiEctM_UVJM-QR0g.png" /></figure><p>Now let’s find ∂L/∂Wᵢ. This is where the recurrent structure makes itself known. Because Wᵢ is shared across timesteps, it appears in the computation of O₁, O₂, and O₃ simultaneously. In graph terms, there are multiple paths from Wᵢ to the loss, one through each timestep. By the <strong>total derivative rule</strong>, we sum the contributions from every path:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Aj9vhv12ZK60yxmHfsPt5g.png" /></figure><p>This is what backpropagation through time actually is: the chain rule applied across the full temporal unrolling of the network, not just across layers.<br>The structure of ∂L/∂Wₕ is identical. Wₕ is also shared across timesteps, so the same logic applies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4W4donheSO4UEQt36vIRA.png" /></figure><p>We can also write these two gradients in a compressed manner :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*ycRU_WcbFUWY48mUBKJXMg.png" /></figure><p>As is tradition in calculus, we simplify an equation only to immediately expand it again:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NUzw4x23h96L4Tv4cV_2A.png" /></figure><p>Each term in this sum contains a chain of partial derivatives of the form ∂Oⱼ/∂Oⱼ₋₁. The further back in time we go, the more of these terms we multiply together. This is the quantity we need to analyze carefully.</p><p>But before we zoom in, we need to recall a few terms :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kc1k83txDBYdxrrtFx2ekA.png" /></figure><p>Since we are differentiating with respect to Oⱼ₋₁, the term XᵢⱼWᵢ vanishes. It has no dependence on Oⱼ₋₁, so its partial derivative is zero. What remains is ∂Oⱼ/∂Oⱼ₋₁, which we now simplify.</p><p>First, we apply the chain rule</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*xLPFs2hMXt4lHIOpsfg7cQ.png" /></figure><p>If you have ever wanted a reason to care about matrices, here it is. When you have a vector of functions each depending on a vector of variables, a single derivative is no longer enough. You need every partial of every function with respect to every variable, all at once. That beautiful object is called a <strong>Jacobian</strong>. We build one here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dmdhDKSnzuPPOBk4xBmMWw.png" /></figure><p>Now something fascinating happens: all the off-diagonal entries vanish. Why? Let’s look at what aⱼ and Oⱼ actually are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zblouczSAwUBKb3dmOO2UQ.png" /></figure><p>So our Jacobian transforms to</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qTQn_nwON6rZ5ApgA7PWBQ.png" /></figure><p>Hence our Jacobian reduces to a clean diagonal matrix of activation derivatives. Now we have both pieces of ∂Oⱼ/∂Oⱼ₋₁. Let’s put them together and trace back to what we were originally solving for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KFCiUKZnr-MPfGZOMnr6Tg.png" /></figure><p>Bounded functions are functions whose output always stays in a fixed range. We generally use two activation functions: tanh and sigmoid (logistic), so let’s examine the bounds of their derivatives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*OXjl_DL5-ss0Q2LcYdP5hw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dgl4Fra9e4jw8ltP9sldVg.png" /><figcaption>bounds of sigmoid and tanh</figcaption></figure><p>Now that we’ve established the bounds of both the functions, let us zoom out further and compute the value of our original term.</p><p>And remember, it was never just one such term. It was a product of (t−k) of them, one for each timestep we backpropagate through.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*iMc2vA6rjDEBWRKSn_vcFw.png" /></figure><h3>If γλ &lt; 1: it becomes a vanishing gradient problem.</h3><p>Each multiplication shrinks the gradient slightly.</p><p>After many timesteps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*ACy3TAxplChaEBfL8ykBdA.png" /></figure><p>The gradient decays exponentially. Signals from early timesteps become too small to influence learning.</p><p>This is the <strong>vanishing gradient problem</strong>.</p><p>The network effectively “forgets” long-range dependencies because the gradient disappears before it reaches earlier states.</p><h3>If γλ &gt; 1: it becomes an exploding gradient problem</h3><p>Each multiplication amplifies the gradient.</p><p>After many timesteps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/1*tgbI9lsN8PdtkvATYr3klA.png" /></figure><p>This is the <strong>exploding gradient problem</strong>.</p><p>The network becomes numerically unstable because small errors are magnified through time.</p><p>Both pathologies reduce to the same mathematical fact: BPTT requires multiplying the same transformation repeatedly across time, and repeated multiplication is exponential. The behavior of that exponential is completely determined by whether γλ is less than or greater than one.</p><p>There is nothing mysterious here. It is the chain rule, applied over and over again across time, doing exactly what repeated multiplication always does.</p><p>We followed the gradient all the way back through time. And we watched it either fade into nothing or blow up into chaos. Vanishing or exploding. There is no middle ground.</p><p>But here is the thing about understanding a problem completely. Once you see exactly where it breaks, you know exactly where to push back.</p><p>So let us push back.</p><p>Three approaches have been developed to address these problems, each attacking a different part of the equation.</p><ol><li><strong>Truncated Backpropagation Through Time:</strong></li></ol><p>Instead of computing the full product across all timesteps, we stop after k steps. The inner product in the<em> </em>gradient sum runs only up to a fixed window, so t−k is bounded by design and (γλ)^(t−k) never gets long enough to cause problems.</p><p>The tradeoff is that the network cannot learn dependencies beyond that window.</p><p>2. <strong>Gradient Clipping:</strong></p><p>The forward and backward pass remain unchanged. After computing the gradient g, if ‖g‖ &gt; c for some threshold c, we rescale: g ← c · g / ‖g‖.</p><p>The direction is preserved; only the magnitude is controlled. This handles the exploding case but does nothing for vanishing gradients.</p><p>3. <strong>LSTMs:</strong></p><p>Rather than patching the gradient after the fact, LSTMs redesign the recurrence itself :<br>By introducing a <strong>cell state Cₜ that updates additively: Cₜ = fₜ ⊙ Cₜ₋₁ + iₜ ⊙ C̃ₜ.</strong></p><p>Because the update is additive rather than multiplicative through a nonlinearity, the gradient is no longer governed by (γλ)^(t−k).</p><p>Fortunately, the remedies are as direct as the problem itself :<br>1. Truncated BPTT stops the multiplication before it runs away. <br>2. Gradient clipping allows the explosion, then gently insists it behave. <br>3. Architectures like LSTMs go one step further — they redesign the recurrence so the problem never arises in the first place.</p><p>Exactly how those redesigns work mathematically is a story of its own.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fb2ebf55d61" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>