<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Rust on Chase the Devil</title>
		<link>https://31416.org/tags/rust/</link>
		<description>Recent content in Rust on Chase the Devil</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Sun, 07 Jun 2026 03:43:00 +0000</lastBuildDate>
		
			<atom:link href="https://31416.org/tags/rust/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>A Bachelier Normal Implied Volatility Solver</title>
				<link>https://31416.org/post/a-faster-bachelier-normal-implied-volatility-solver/</link>
				<pubDate>Sun, 07 Jun 2026 03:43:00 +0000</pubDate>
				<guid>https://31416.org/post/a-faster-bachelier-normal-implied-volatility-solver/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://www.clarusft.com/bachelier-model-fast-accurate-implied-volatility/&#34;&gt;Around 2014&lt;/a&gt;, I &lt;a href=&#34;https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2420757&#34;&gt;proposed&lt;/a&gt; a few Bachelier implied volatility &amp;ldquo;solvers&amp;rdquo;. The first one was inspired by Steven G. Johnson&amp;rsquo;s Faddeeva package for the complex error function: it used a piecewise Chebyshev polynomial representation to have a near machine accurate representation of the Bachelier implied volatility. Why did I put &amp;ldquo;solver&amp;rdquo; in quotes? Because the problem can be reduced to a 1D function representation (as originally shown by &lt;a href=&#34;https://papers.ssrn.com/sol3/papers.cfm?abstract_id=990747&#34;&gt;Choi, Kim and Kwak&lt;/a&gt; in 2009). Then, I was encouraged by Gary Kennedy to find a simpler rational function approximation, I used 3 or 4 rational functions to cover the full range of the Bachelier implied volatility function.&lt;/p&gt;</description>
			</item>
			<item>
				<title>The Role of Erfcx and Erfc in the Black-Scholes Formula</title>
				<link>https://31416.org/post/black-formula-erfcx-erfc-backends/</link>
				<pubDate>Sat, 30 May 2026 03:43:00 +0000</pubDate>
				<guid>https://31416.org/post/black-formula-erfcx-erfc-backends/</guid>
				<description>&lt;p&gt;This note compares special-function choices at the level that matters to the &lt;a href=&#34;https://31416.org/post/a-faster-monotone-implied-volatility-solver/&#34;&gt;implied volatility solvers&lt;/a&gt;: the normalized Black beta price, not &lt;a href=&#34;https://31416.org/post/erfcx-cody-commons-johnson/&#34;&gt;standalone &lt;code&gt;erfcx(x)&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;code&gt;x = log(F/K) &amp;lt;= 0&lt;/code&gt; and total volatility &lt;code&gt;s = sigma sqrt(T)&lt;/code&gt;, the beta-space OTM call price is&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f0f0f0;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;B(x, s) = 0.5 * (exp(x/2) * erfc(q1) - exp(-x/2) * erfc(q2))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;q1 = -(x/s + s/2) / sqrt(2)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;q2 = -(x/s - s/2) / sqrt(2)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The corresponding forward-normalized OTM-call price is &lt;code&gt;c = B(x, s) / sqrt(ex)&lt;/code&gt;, with &lt;code&gt;ex = exp(x)&lt;/code&gt;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Which erfcx?</title>
				<link>https://31416.org/post/erfcx-cody-commons-johnson/</link>
				<pubDate>Sun, 24 May 2026 03:43:00 +0000</pubDate>
				<guid>https://31416.org/post/erfcx-cody-commons-johnson/</guid>
				<description>&lt;p&gt;The &lt;a href=&#34;https://31416.org/post/a-faster-monotone-implied-volatility-solver/&#34;&gt;use of erfcx&lt;/a&gt; instead of direct erfc or CDF in a Black-Scholes implied volatility solver leads to gain in accuracy and performance in general. But which erfcx should we use?&lt;/p&gt;&#xA;&lt;p&gt;This note compares practical erfcx implementations for Rust implied volatility solvers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Commons: the local Rust port of &lt;a href=&#34;https://github.com/apache/commons-numbers/blob/master/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostErf.java&#34;&gt;Apache Commons Numbers&lt;/a&gt; &lt;code&gt;BoostErf.erfcx&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cody: the &lt;a href=&#34;https://docs.rs/jaeckel/latest/jaeckel/fn.erfcx_cody.html&#34;&gt;Cody rational approximation&lt;/a&gt; exposed by the &lt;code&gt;jaeckel = 0.2.0&lt;/code&gt; crate during this comparison, originally coming from   &lt;a href=&#34;https://www.netlib.org/slatec/src/&#34;&gt;Netlib SLATEC library&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Johnson: Steven G. Johnson&amp;rsquo;s Faddeeva implementation, as exposed by &lt;code&gt;errorfunctions = 0.2.0&lt;/code&gt;, &lt;a href=&#34;https://github.com/Cactus-proj/special-functions/tree/main/sys/faddeeva-sys&#34;&gt;&lt;code&gt;faddeeva-sys = 0.1.0&lt;/code&gt;&lt;/a&gt;, and Julia &lt;code&gt;SpecialFunctions.erfcx(::Float64)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The Commons-style implementation is a local Rust port of the &lt;a href=&#34;https://issues.apache.org/jira/si/jira.issueviews:issue-html/NUMBERS-177/NUMBERS-177.html&#34;&gt;Apache Commons Numbers/BoostErf approach&lt;/a&gt;. It computes the small central region through the local &lt;code&gt;erf&lt;/code&gt; rational approximation and uses &lt;code&gt;exp_m1(x*x)&lt;/code&gt; to avoid cancellation in &lt;code&gt;exp(x^2) * erfc(x)&lt;/code&gt; near zero. For positive inputs it uses several rational subintervals: a central polynomial/rational &lt;code&gt;erf&lt;/code&gt; branch, erfc-style rational branches around &lt;code&gt;0.5..1.5&lt;/code&gt;, &lt;code&gt;1.5..2.5&lt;/code&gt;, and &lt;code&gt;2.5..4&lt;/code&gt;,  and a rational function taken from &lt;em&gt;Rational Chebyshev approximations for the error function&lt;/em&gt;  by W. J. Cody, Math. Comp., 1969, PP. 631-638 beyond that. For very large positive &lt;code&gt;x&lt;/code&gt;, it returns &lt;code&gt;1 / (sqrt(pi) * x)&lt;/code&gt;. For negative &lt;code&gt;x&lt;/code&gt;, it uses the reflected form with a split-square exponential, returns &lt;code&gt;Inf&lt;/code&gt; below the finite overflow cutoff, and otherwise computes &lt;code&gt;2 exp(x^2) - erfcx(|x|)&lt;/code&gt; in a way that preserves more bits near the overflow boundary.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Modern Programming Language for Monte-Carlo</title>
				<link>https://31416.org/post/modern-programming-language-for-monte-carlo/</link>
				<pubDate>Sat, 18 Apr 2015 22:58:00 +0000</pubDate>
				<guid>https://31416.org/post/modern-programming-language-for-monte-carlo/</guid>
				<description>&lt;p&gt;A few recent programming languages sparked my interest:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;http://julialang.org/&#34;&gt;Julia&lt;/a&gt; because of the wide coverage of mathematical functions, and great attention to quality of the implementations. It has also some interesting web interface.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.dartlang.org&#34;&gt;Dart&lt;/a&gt;: because it&amp;rsquo;s a language focused purely on building apps for the web, and has a supposedly good VM.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;http://www.rust-lang.org/&#34;&gt;Rust&lt;/a&gt;: it&amp;rsquo;s the latest fad. It has interesting concepts around concurrency and a focus on being low level all the while being simpler than C.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I decided to see how well suited they would be on a simple Monte-Carlo simulation of a forward start option under the Black model. I am no expert at all in any of the languages, so this is a beginner&amp;rsquo;s test. I compared the runtime for executing 16K simulations times a multiplier.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
