Average Error: 29.1 → 0.1
Time: 26.1s
Precision: binary64
Cost: 20032
\[e^{a \cdot x} - 1 \]
\[\frac{\mathsf{expm1}\left(2 \cdot \left(a \cdot x\right)\right)}{\sqrt{e^{\left(a + a\right) \cdot x}} + 1} \]
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
(FPCore (a x)
 :precision binary64
 (/ (expm1 (* 2.0 (* a x))) (+ (sqrt (exp (* (+ a a) x))) 1.0)))
double code(double a, double x) {
	return exp((a * x)) - 1.0;
}
double code(double a, double x) {
	return expm1((2.0 * (a * x))) / (sqrt(exp(((a + a) * x))) + 1.0);
}
public static double code(double a, double x) {
	return Math.exp((a * x)) - 1.0;
}
public static double code(double a, double x) {
	return Math.expm1((2.0 * (a * x))) / (Math.sqrt(Math.exp(((a + a) * x))) + 1.0);
}
def code(a, x):
	return math.exp((a * x)) - 1.0
def code(a, x):
	return math.expm1((2.0 * (a * x))) / (math.sqrt(math.exp(((a + a) * x))) + 1.0)
function code(a, x)
	return Float64(exp(Float64(a * x)) - 1.0)
end
function code(a, x)
	return Float64(expm1(Float64(2.0 * Float64(a * x))) / Float64(sqrt(exp(Float64(Float64(a + a) * x))) + 1.0))
end
code[a_, x_] := N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]
code[a_, x_] := N[(N[(Exp[N[(2.0 * N[(a * x), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(N[Sqrt[N[Exp[N[(N[(a + a), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
e^{a \cdot x} - 1
\frac{\mathsf{expm1}\left(2 \cdot \left(a \cdot x\right)\right)}{\sqrt{e^{\left(a + a\right) \cdot x}} + 1}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.1
Target0.2
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;\left|a \cdot x\right| < 0.1:\\ \;\;\;\;\left(a \cdot x\right) \cdot \left(1 + \left(\frac{a \cdot x}{2} + \frac{{\left(a \cdot x\right)}^{2}}{6}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;e^{a \cdot x} - 1\\ \end{array} \]

Derivation

  1. Initial program 29.1

    \[e^{a \cdot x} - 1 \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
    Proof
  3. Applied egg-rr29.1

    \[\leadsto \color{blue}{\frac{e^{2 \cdot \left(a \cdot x\right)}}{e^{a \cdot x} + 1} + \left(-\frac{1}{e^{a \cdot x} + 1}\right)} \]
  4. Simplified0.1

    \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(2 \cdot \left(a \cdot x\right)\right)}{e^{a \cdot x} + 1}} \]
    Proof
  5. Applied egg-rr0.1

    \[\leadsto \frac{\mathsf{expm1}\left(2 \cdot \left(a \cdot x\right)\right)}{\color{blue}{{\left(e^{\left(a + a\right) \cdot x}\right)}^{0.5}} + 1} \]
  6. Simplified0.1

    \[\leadsto \frac{\mathsf{expm1}\left(2 \cdot \left(a \cdot x\right)\right)}{\color{blue}{\sqrt{e^{\left(a + a\right) \cdot x}}} + 1} \]
    Proof

Alternatives

Alternative 1
Error0.1
Cost13504
\[\frac{\mathsf{expm1}\left(2 \cdot \left(a \cdot x\right)\right)}{e^{a \cdot x} + 1} \]
Alternative 2
Error0.0
Cost6592
\[\mathsf{expm1}\left(a \cdot x\right) \]
Alternative 3
Error61.2
Cost192
\[0.3333333333333333 \cdot a \]
Alternative 4
Error61.2
Cost64
\[a \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (a x)
  :name "expax (section 3.5)"
  :precision binary64

  :herbie-target
  (if (< (fabs (* a x)) 0.1) (* (* a x) (+ 1.0 (+ (/ (* a x) 2.0) (/ (pow (* a x) 2.0) 6.0)))) (- (exp (* a x)) 1.0))

  (- (exp (* a x)) 1.0))