
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
double code(double a, double x) {
return exp((a * x)) - 1.0;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
code = exp((a * x)) - 1.0d0
end function
public static double code(double a, double x) {
return Math.exp((a * x)) - 1.0;
}
def code(a, x): return math.exp((a * x)) - 1.0
function code(a, x) return Float64(exp(Float64(a * x)) - 1.0) end
function tmp = code(a, x) tmp = exp((a * x)) - 1.0; end
code[a_, x_] := N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
e^{a \cdot x} - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
double code(double a, double x) {
return exp((a * x)) - 1.0;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
code = exp((a * x)) - 1.0d0
end function
public static double code(double a, double x) {
return Math.exp((a * x)) - 1.0;
}
def code(a, x): return math.exp((a * x)) - 1.0
function code(a, x) return Float64(exp(Float64(a * x)) - 1.0) end
function tmp = code(a, x) tmp = exp((a * x)) - 1.0; end
code[a_, x_] := N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
e^{a \cdot x} - 1
\end{array}
(FPCore (a x) :precision binary64 (expm1 (* a x)))
double code(double a, double x) {
return expm1((a * x));
}
public static double code(double a, double x) {
return Math.expm1((a * x));
}
def code(a, x): return math.expm1((a * x))
function code(a, x) return expm1(Float64(a * x)) end
code[a_, x_] := N[(Exp[N[(a * x), $MachinePrecision]] - 1), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{expm1}\left(a \cdot x\right)
\end{array}
Initial program 67.2%
expm1-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a x)
:precision binary64
(let* ((t_0 (* a (* x (* a 0.5)))) (t_1 (* x t_0)) (t_2 (* x (+ a t_0))))
(if (<= (* a x) -500.0)
-2.0
(if (<= (* a x) 1e+14)
t_2
(if (<= (* a x) 5e+70)
(* a (+ x (* a (* x (* x 0.5)))))
(if (<= (* a x) 5e+75)
(* x (+ a (* x (* a (* a 0.5)))))
(if (<= (* a x) 2e+126)
(/ (- (* (* a x) (* a x)) (* t_1 t_1)) (- (* a x) t_1))
t_2)))))))
double code(double a, double x) {
double t_0 = a * (x * (a * 0.5));
double t_1 = x * t_0;
double t_2 = x * (a + t_0);
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if ((a * x) <= 1e+14) {
tmp = t_2;
} else if ((a * x) <= 5e+70) {
tmp = a * (x + (a * (x * (x * 0.5))));
} else if ((a * x) <= 5e+75) {
tmp = x * (a + (x * (a * (a * 0.5))));
} else if ((a * x) <= 2e+126) {
tmp = (((a * x) * (a * x)) - (t_1 * t_1)) / ((a * x) - t_1);
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = a * (x * (a * 0.5d0))
t_1 = x * t_0
t_2 = x * (a + t_0)
if ((a * x) <= (-500.0d0)) then
tmp = -2.0d0
else if ((a * x) <= 1d+14) then
tmp = t_2
else if ((a * x) <= 5d+70) then
tmp = a * (x + (a * (x * (x * 0.5d0))))
else if ((a * x) <= 5d+75) then
tmp = x * (a + (x * (a * (a * 0.5d0))))
else if ((a * x) <= 2d+126) then
tmp = (((a * x) * (a * x)) - (t_1 * t_1)) / ((a * x) - t_1)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = a * (x * (a * 0.5));
double t_1 = x * t_0;
double t_2 = x * (a + t_0);
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if ((a * x) <= 1e+14) {
tmp = t_2;
} else if ((a * x) <= 5e+70) {
tmp = a * (x + (a * (x * (x * 0.5))));
} else if ((a * x) <= 5e+75) {
tmp = x * (a + (x * (a * (a * 0.5))));
} else if ((a * x) <= 2e+126) {
tmp = (((a * x) * (a * x)) - (t_1 * t_1)) / ((a * x) - t_1);
} else {
tmp = t_2;
}
return tmp;
}
def code(a, x): t_0 = a * (x * (a * 0.5)) t_1 = x * t_0 t_2 = x * (a + t_0) tmp = 0 if (a * x) <= -500.0: tmp = -2.0 elif (a * x) <= 1e+14: tmp = t_2 elif (a * x) <= 5e+70: tmp = a * (x + (a * (x * (x * 0.5)))) elif (a * x) <= 5e+75: tmp = x * (a + (x * (a * (a * 0.5)))) elif (a * x) <= 2e+126: tmp = (((a * x) * (a * x)) - (t_1 * t_1)) / ((a * x) - t_1) else: tmp = t_2 return tmp
function code(a, x) t_0 = Float64(a * Float64(x * Float64(a * 0.5))) t_1 = Float64(x * t_0) t_2 = Float64(x * Float64(a + t_0)) tmp = 0.0 if (Float64(a * x) <= -500.0) tmp = -2.0; elseif (Float64(a * x) <= 1e+14) tmp = t_2; elseif (Float64(a * x) <= 5e+70) tmp = Float64(a * Float64(x + Float64(a * Float64(x * Float64(x * 0.5))))); elseif (Float64(a * x) <= 5e+75) tmp = Float64(x * Float64(a + Float64(x * Float64(a * Float64(a * 0.5))))); elseif (Float64(a * x) <= 2e+126) tmp = Float64(Float64(Float64(Float64(a * x) * Float64(a * x)) - Float64(t_1 * t_1)) / Float64(Float64(a * x) - t_1)); else tmp = t_2; end return tmp end
function tmp_2 = code(a, x) t_0 = a * (x * (a * 0.5)); t_1 = x * t_0; t_2 = x * (a + t_0); tmp = 0.0; if ((a * x) <= -500.0) tmp = -2.0; elseif ((a * x) <= 1e+14) tmp = t_2; elseif ((a * x) <= 5e+70) tmp = a * (x + (a * (x * (x * 0.5)))); elseif ((a * x) <= 5e+75) tmp = x * (a + (x * (a * (a * 0.5)))); elseif ((a * x) <= 2e+126) tmp = (((a * x) * (a * x)) - (t_1 * t_1)) / ((a * x) - t_1); else tmp = t_2; end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(a * N[(x * N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(a + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * x), $MachinePrecision], -500.0], -2.0, If[LessEqual[N[(a * x), $MachinePrecision], 1e+14], t$95$2, If[LessEqual[N[(a * x), $MachinePrecision], 5e+70], N[(a * N[(x + N[(a * N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * x), $MachinePrecision], 5e+75], N[(x * N[(a + N[(x * N[(a * N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * x), $MachinePrecision], 2e+126], N[(N[(N[(N[(a * x), $MachinePrecision] * N[(a * x), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(N[(a * x), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(x \cdot \left(a \cdot 0.5\right)\right)\\
t_1 := x \cdot t_0\\
t_2 := x \cdot \left(a + t_0\right)\\
\mathbf{if}\;a \cdot x \leq -500:\\
\;\;\;\;-2\\
\mathbf{elif}\;a \cdot x \leq 10^{+14}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot x \leq 5 \cdot 10^{+70}:\\
\;\;\;\;a \cdot \left(x + a \cdot \left(x \cdot \left(x \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;a \cdot x \leq 5 \cdot 10^{+75}:\\
\;\;\;\;x \cdot \left(a + x \cdot \left(a \cdot \left(a \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;a \cdot x \leq 2 \cdot 10^{+126}:\\
\;\;\;\;\frac{\left(a \cdot x\right) \cdot \left(a \cdot x\right) - t_1 \cdot t_1}{a \cdot x - t_1}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (*.f64 a x) < -500Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.5%
+-commutative0.5%
associate-*r*0.5%
unpow20.5%
associate-*r*0.9%
distribute-rgt-out1.1%
*-commutative1.1%
*-commutative1.1%
unpow21.1%
associate-*l*1.1%
Simplified1.1%
distribute-lft-in0.9%
flip-+0.6%
*-commutative0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.5%
Applied egg-rr0.5%
Taylor expanded in a around inf 0.4%
*-commutative0.4%
unpow20.4%
unpow20.4%
Simplified0.4%
Taylor expanded in a around 0 18.8%
if -500 < (*.f64 a x) < 1e14 or 1.99999999999999985e126 < (*.f64 a x) Initial program 51.1%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 88.4%
+-commutative88.4%
associate-*r*88.4%
unpow288.4%
associate-*r*93.8%
distribute-rgt-out93.8%
*-commutative93.8%
*-commutative93.8%
unpow293.8%
associate-*l*93.8%
Simplified93.8%
+-commutative93.8%
distribute-lft-in93.8%
*-commutative93.8%
associate-*l*97.3%
*-commutative97.3%
Applied egg-rr97.3%
*-commutative97.3%
distribute-lft-out97.3%
*-commutative97.3%
Applied egg-rr97.3%
if 1e14 < (*.f64 a x) < 5.0000000000000002e70Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 1.8%
*-commutative1.8%
associate-*l*1.8%
unpow21.8%
associate-*l*21.2%
distribute-lft-out21.2%
unpow221.2%
associate-*l*21.2%
Simplified21.2%
if 5.0000000000000002e70 < (*.f64 a x) < 5.0000000000000002e75Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.0%
+-commutative0.0%
associate-*r*0.0%
unpow20.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
if 5.0000000000000002e75 < (*.f64 a x) < 1.99999999999999985e126Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 13.5%
+-commutative13.5%
associate-*r*13.5%
unpow213.5%
associate-*r*5.4%
distribute-rgt-out5.4%
*-commutative5.4%
*-commutative5.4%
unpow25.4%
associate-*l*5.4%
Simplified5.4%
distribute-lft-in5.4%
flip-+91.3%
*-commutative91.3%
*-commutative91.3%
*-commutative91.3%
associate-*l*91.3%
*-commutative91.3%
associate-*l*90.9%
*-commutative90.9%
*-commutative90.9%
associate-*l*100.0%
Applied egg-rr100.0%
Final simplification75.5%
(FPCore (a x)
:precision binary64
(let* ((t_0 (* a (* x (* a 0.5)))) (t_1 (* x t_0)))
(if (<= (* a x) -500.0)
-2.0
(if (<= (* a x) 1e+14)
(* x (+ a t_0))
(if (<= (* a x) 5e+70)
(* a (+ x (* a (* x (* x 0.5)))))
(if (<= (* a x) 5e+75)
(* x (+ a (* x (* a (* a 0.5)))))
(if (<= (* a x) 1e+117)
(/
(- (* (* a x) (* a x)) (* t_1 t_1))
(* (* (* a a) (* x x)) -0.5))
(* (* x x) (* 0.5 (* a a))))))))))
double code(double a, double x) {
double t_0 = a * (x * (a * 0.5));
double t_1 = x * t_0;
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if ((a * x) <= 1e+14) {
tmp = x * (a + t_0);
} else if ((a * x) <= 5e+70) {
tmp = a * (x + (a * (x * (x * 0.5))));
} else if ((a * x) <= 5e+75) {
tmp = x * (a + (x * (a * (a * 0.5))));
} else if ((a * x) <= 1e+117) {
tmp = (((a * x) * (a * x)) - (t_1 * t_1)) / (((a * a) * (x * x)) * -0.5);
} else {
tmp = (x * x) * (0.5 * (a * a));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = a * (x * (a * 0.5d0))
t_1 = x * t_0
if ((a * x) <= (-500.0d0)) then
tmp = -2.0d0
else if ((a * x) <= 1d+14) then
tmp = x * (a + t_0)
else if ((a * x) <= 5d+70) then
tmp = a * (x + (a * (x * (x * 0.5d0))))
else if ((a * x) <= 5d+75) then
tmp = x * (a + (x * (a * (a * 0.5d0))))
else if ((a * x) <= 1d+117) then
tmp = (((a * x) * (a * x)) - (t_1 * t_1)) / (((a * a) * (x * x)) * (-0.5d0))
else
tmp = (x * x) * (0.5d0 * (a * a))
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = a * (x * (a * 0.5));
double t_1 = x * t_0;
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if ((a * x) <= 1e+14) {
tmp = x * (a + t_0);
} else if ((a * x) <= 5e+70) {
tmp = a * (x + (a * (x * (x * 0.5))));
} else if ((a * x) <= 5e+75) {
tmp = x * (a + (x * (a * (a * 0.5))));
} else if ((a * x) <= 1e+117) {
tmp = (((a * x) * (a * x)) - (t_1 * t_1)) / (((a * a) * (x * x)) * -0.5);
} else {
tmp = (x * x) * (0.5 * (a * a));
}
return tmp;
}
def code(a, x): t_0 = a * (x * (a * 0.5)) t_1 = x * t_0 tmp = 0 if (a * x) <= -500.0: tmp = -2.0 elif (a * x) <= 1e+14: tmp = x * (a + t_0) elif (a * x) <= 5e+70: tmp = a * (x + (a * (x * (x * 0.5)))) elif (a * x) <= 5e+75: tmp = x * (a + (x * (a * (a * 0.5)))) elif (a * x) <= 1e+117: tmp = (((a * x) * (a * x)) - (t_1 * t_1)) / (((a * a) * (x * x)) * -0.5) else: tmp = (x * x) * (0.5 * (a * a)) return tmp
function code(a, x) t_0 = Float64(a * Float64(x * Float64(a * 0.5))) t_1 = Float64(x * t_0) tmp = 0.0 if (Float64(a * x) <= -500.0) tmp = -2.0; elseif (Float64(a * x) <= 1e+14) tmp = Float64(x * Float64(a + t_0)); elseif (Float64(a * x) <= 5e+70) tmp = Float64(a * Float64(x + Float64(a * Float64(x * Float64(x * 0.5))))); elseif (Float64(a * x) <= 5e+75) tmp = Float64(x * Float64(a + Float64(x * Float64(a * Float64(a * 0.5))))); elseif (Float64(a * x) <= 1e+117) tmp = Float64(Float64(Float64(Float64(a * x) * Float64(a * x)) - Float64(t_1 * t_1)) / Float64(Float64(Float64(a * a) * Float64(x * x)) * -0.5)); else tmp = Float64(Float64(x * x) * Float64(0.5 * Float64(a * a))); end return tmp end
function tmp_2 = code(a, x) t_0 = a * (x * (a * 0.5)); t_1 = x * t_0; tmp = 0.0; if ((a * x) <= -500.0) tmp = -2.0; elseif ((a * x) <= 1e+14) tmp = x * (a + t_0); elseif ((a * x) <= 5e+70) tmp = a * (x + (a * (x * (x * 0.5)))); elseif ((a * x) <= 5e+75) tmp = x * (a + (x * (a * (a * 0.5)))); elseif ((a * x) <= 1e+117) tmp = (((a * x) * (a * x)) - (t_1 * t_1)) / (((a * a) * (x * x)) * -0.5); else tmp = (x * x) * (0.5 * (a * a)); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(a * N[(x * N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, If[LessEqual[N[(a * x), $MachinePrecision], -500.0], -2.0, If[LessEqual[N[(a * x), $MachinePrecision], 1e+14], N[(x * N[(a + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * x), $MachinePrecision], 5e+70], N[(a * N[(x + N[(a * N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * x), $MachinePrecision], 5e+75], N[(x * N[(a + N[(x * N[(a * N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * x), $MachinePrecision], 1e+117], N[(N[(N[(N[(a * x), $MachinePrecision] * N[(a * x), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(a * a), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(x \cdot \left(a \cdot 0.5\right)\right)\\
t_1 := x \cdot t_0\\
\mathbf{if}\;a \cdot x \leq -500:\\
\;\;\;\;-2\\
\mathbf{elif}\;a \cdot x \leq 10^{+14}:\\
\;\;\;\;x \cdot \left(a + t_0\right)\\
\mathbf{elif}\;a \cdot x \leq 5 \cdot 10^{+70}:\\
\;\;\;\;a \cdot \left(x + a \cdot \left(x \cdot \left(x \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;a \cdot x \leq 5 \cdot 10^{+75}:\\
\;\;\;\;x \cdot \left(a + x \cdot \left(a \cdot \left(a \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;a \cdot x \leq 10^{+117}:\\
\;\;\;\;\frac{\left(a \cdot x\right) \cdot \left(a \cdot x\right) - t_1 \cdot t_1}{\left(\left(a \cdot a\right) \cdot \left(x \cdot x\right)\right) \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(0.5 \cdot \left(a \cdot a\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -500Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.5%
+-commutative0.5%
associate-*r*0.5%
unpow20.5%
associate-*r*0.9%
distribute-rgt-out1.1%
*-commutative1.1%
*-commutative1.1%
unpow21.1%
associate-*l*1.1%
Simplified1.1%
distribute-lft-in0.9%
flip-+0.6%
*-commutative0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.5%
Applied egg-rr0.5%
Taylor expanded in a around inf 0.4%
*-commutative0.4%
unpow20.4%
unpow20.4%
Simplified0.4%
Taylor expanded in a around 0 18.8%
if -500 < (*.f64 a x) < 1e14Initial program 35.8%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 85.5%
+-commutative85.5%
associate-*r*85.5%
unpow285.5%
associate-*r*92.5%
distribute-rgt-out92.5%
*-commutative92.5%
*-commutative92.5%
unpow292.5%
associate-*l*92.5%
Simplified92.5%
+-commutative92.5%
distribute-lft-in92.5%
*-commutative92.5%
associate-*l*97.2%
*-commutative97.2%
Applied egg-rr97.2%
*-commutative97.2%
distribute-lft-out97.2%
*-commutative97.2%
Applied egg-rr97.2%
if 1e14 < (*.f64 a x) < 5.0000000000000002e70Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 1.8%
*-commutative1.8%
associate-*l*1.8%
unpow21.8%
associate-*l*21.2%
distribute-lft-out21.2%
unpow221.2%
associate-*l*21.2%
Simplified21.2%
if 5.0000000000000002e70 < (*.f64 a x) < 5.0000000000000002e75Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.0%
+-commutative0.0%
associate-*r*0.0%
unpow20.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
if 5.0000000000000002e75 < (*.f64 a x) < 1.00000000000000005e117Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 4.9%
+-commutative4.9%
associate-*r*4.9%
unpow24.9%
associate-*r*5.3%
distribute-rgt-out5.3%
*-commutative5.3%
*-commutative5.3%
unpow25.3%
associate-*l*5.3%
Simplified5.3%
distribute-lft-in5.3%
flip-+90.4%
*-commutative90.4%
*-commutative90.4%
*-commutative90.4%
associate-*l*90.4%
*-commutative90.4%
associate-*l*90.0%
*-commutative90.0%
*-commutative90.0%
associate-*l*100.0%
Applied egg-rr100.0%
Taylor expanded in a around inf 90.0%
*-commutative90.0%
unpow290.0%
unpow290.0%
Simplified90.0%
if 1.00000000000000005e117 < (*.f64 a x) Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 97.6%
*-commutative97.6%
associate-*l*97.6%
unpow297.6%
associate-*l*95.5%
distribute-lft-out95.5%
unpow295.5%
associate-*l*95.5%
Simplified95.5%
Taylor expanded in a around inf 97.6%
unpow297.6%
unpow297.6%
associate-*r*95.5%
Simplified95.5%
Taylor expanded in a around 0 97.6%
unpow297.6%
associate-*r*97.6%
unpow297.6%
Simplified97.6%
Final simplification75.0%
(FPCore (a x)
:precision binary64
(if (<= (* a x) -500.0)
-2.0
(if (or (<= (* a x) 1e+14) (not (<= (* a x) 5e+70)))
(* x (+ a (* a (* x (* a 0.5)))))
(* a (+ x (* a (* x (* x 0.5))))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if (((a * x) <= 1e+14) || !((a * x) <= 5e+70)) {
tmp = x * (a + (a * (x * (a * 0.5))));
} else {
tmp = a * (x + (a * (x * (x * 0.5))));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-500.0d0)) then
tmp = -2.0d0
else if (((a * x) <= 1d+14) .or. (.not. ((a * x) <= 5d+70))) then
tmp = x * (a + (a * (x * (a * 0.5d0))))
else
tmp = a * (x + (a * (x * (x * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if (((a * x) <= 1e+14) || !((a * x) <= 5e+70)) {
tmp = x * (a + (a * (x * (a * 0.5))));
} else {
tmp = a * (x + (a * (x * (x * 0.5))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -500.0: tmp = -2.0 elif ((a * x) <= 1e+14) or not ((a * x) <= 5e+70): tmp = x * (a + (a * (x * (a * 0.5)))) else: tmp = a * (x + (a * (x * (x * 0.5)))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -500.0) tmp = -2.0; elseif ((Float64(a * x) <= 1e+14) || !(Float64(a * x) <= 5e+70)) tmp = Float64(x * Float64(a + Float64(a * Float64(x * Float64(a * 0.5))))); else tmp = Float64(a * Float64(x + Float64(a * Float64(x * Float64(x * 0.5))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -500.0) tmp = -2.0; elseif (((a * x) <= 1e+14) || ~(((a * x) <= 5e+70))) tmp = x * (a + (a * (x * (a * 0.5)))); else tmp = a * (x + (a * (x * (x * 0.5)))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -500.0], -2.0, If[Or[LessEqual[N[(a * x), $MachinePrecision], 1e+14], N[Not[LessEqual[N[(a * x), $MachinePrecision], 5e+70]], $MachinePrecision]], N[(x * N[(a + N[(a * N[(x * N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[(x + N[(a * N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -500:\\
\;\;\;\;-2\\
\mathbf{elif}\;a \cdot x \leq 10^{+14} \lor \neg \left(a \cdot x \leq 5 \cdot 10^{+70}\right):\\
\;\;\;\;x \cdot \left(a + a \cdot \left(x \cdot \left(a \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(x + a \cdot \left(x \cdot \left(x \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -500Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.5%
+-commutative0.5%
associate-*r*0.5%
unpow20.5%
associate-*r*0.9%
distribute-rgt-out1.1%
*-commutative1.1%
*-commutative1.1%
unpow21.1%
associate-*l*1.1%
Simplified1.1%
distribute-lft-in0.9%
flip-+0.6%
*-commutative0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.5%
Applied egg-rr0.5%
Taylor expanded in a around inf 0.4%
*-commutative0.4%
unpow20.4%
unpow20.4%
Simplified0.4%
Taylor expanded in a around 0 18.8%
if -500 < (*.f64 a x) < 1e14 or 5.0000000000000002e70 < (*.f64 a x) Initial program 54.3%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 83.4%
+-commutative83.4%
associate-*r*83.4%
unpow283.4%
associate-*r*88.5%
distribute-rgt-out88.5%
*-commutative88.5%
*-commutative88.5%
unpow288.5%
associate-*l*88.5%
Simplified88.5%
+-commutative88.5%
distribute-lft-in88.5%
*-commutative88.5%
associate-*l*91.8%
*-commutative91.8%
Applied egg-rr91.8%
*-commutative91.8%
distribute-lft-out91.9%
*-commutative91.9%
Applied egg-rr91.9%
if 1e14 < (*.f64 a x) < 5.0000000000000002e70Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 1.8%
*-commutative1.8%
associate-*l*1.8%
unpow21.8%
associate-*l*21.2%
distribute-lft-out21.2%
unpow221.2%
associate-*l*21.2%
Simplified21.2%
Final simplification71.4%
(FPCore (a x) :precision binary64 (if (<= (* a x) -500.0) -2.0 (if (<= (* a x) 0.0001) (* a x) (* a (+ x (* a (* x (* x 0.5))))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if ((a * x) <= 0.0001) {
tmp = a * x;
} else {
tmp = a * (x + (a * (x * (x * 0.5))));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-500.0d0)) then
tmp = -2.0d0
else if ((a * x) <= 0.0001d0) then
tmp = a * x
else
tmp = a * (x + (a * (x * (x * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if ((a * x) <= 0.0001) {
tmp = a * x;
} else {
tmp = a * (x + (a * (x * (x * 0.5))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -500.0: tmp = -2.0 elif (a * x) <= 0.0001: tmp = a * x else: tmp = a * (x + (a * (x * (x * 0.5)))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -500.0) tmp = -2.0; elseif (Float64(a * x) <= 0.0001) tmp = Float64(a * x); else tmp = Float64(a * Float64(x + Float64(a * Float64(x * Float64(x * 0.5))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -500.0) tmp = -2.0; elseif ((a * x) <= 0.0001) tmp = a * x; else tmp = a * (x + (a * (x * (x * 0.5)))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -500.0], -2.0, If[LessEqual[N[(a * x), $MachinePrecision], 0.0001], N[(a * x), $MachinePrecision], N[(a * N[(x + N[(a * N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -500:\\
\;\;\;\;-2\\
\mathbf{elif}\;a \cdot x \leq 0.0001:\\
\;\;\;\;a \cdot x\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(x + a \cdot \left(x \cdot \left(x \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -500Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.5%
+-commutative0.5%
associate-*r*0.5%
unpow20.5%
associate-*r*0.9%
distribute-rgt-out1.1%
*-commutative1.1%
*-commutative1.1%
unpow21.1%
associate-*l*1.1%
Simplified1.1%
distribute-lft-in0.9%
flip-+0.6%
*-commutative0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.5%
Applied egg-rr0.5%
Taylor expanded in a around inf 0.4%
*-commutative0.4%
unpow20.4%
unpow20.4%
Simplified0.4%
Taylor expanded in a around 0 18.8%
if -500 < (*.f64 a x) < 1.00000000000000005e-4Initial program 34.3%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 98.6%
if 1.00000000000000005e-4 < (*.f64 a x) Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 62.3%
*-commutative62.3%
associate-*l*62.3%
unpow262.3%
associate-*l*68.7%
distribute-lft-out68.7%
unpow268.7%
associate-*l*68.7%
Simplified68.7%
Final simplification71.7%
(FPCore (a x) :precision binary64 (if (<= (* a x) -500.0) -2.0 (if (<= (* a x) 5e-21) (* a x) (* x (+ a (* x (* a (* a 0.5))))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if ((a * x) <= 5e-21) {
tmp = a * x;
} else {
tmp = x * (a + (x * (a * (a * 0.5))));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-500.0d0)) then
tmp = -2.0d0
else if ((a * x) <= 5d-21) then
tmp = a * x
else
tmp = x * (a + (x * (a * (a * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if ((a * x) <= 5e-21) {
tmp = a * x;
} else {
tmp = x * (a + (x * (a * (a * 0.5))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -500.0: tmp = -2.0 elif (a * x) <= 5e-21: tmp = a * x else: tmp = x * (a + (x * (a * (a * 0.5)))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -500.0) tmp = -2.0; elseif (Float64(a * x) <= 5e-21) tmp = Float64(a * x); else tmp = Float64(x * Float64(a + Float64(x * Float64(a * Float64(a * 0.5))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -500.0) tmp = -2.0; elseif ((a * x) <= 5e-21) tmp = a * x; else tmp = x * (a + (x * (a * (a * 0.5)))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -500.0], -2.0, If[LessEqual[N[(a * x), $MachinePrecision], 5e-21], N[(a * x), $MachinePrecision], N[(x * N[(a + N[(x * N[(a * N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -500:\\
\;\;\;\;-2\\
\mathbf{elif}\;a \cdot x \leq 5 \cdot 10^{-21}:\\
\;\;\;\;a \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(a + x \cdot \left(a \cdot \left(a \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -500Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.5%
+-commutative0.5%
associate-*r*0.5%
unpow20.5%
associate-*r*0.9%
distribute-rgt-out1.1%
*-commutative1.1%
*-commutative1.1%
unpow21.1%
associate-*l*1.1%
Simplified1.1%
distribute-lft-in0.9%
flip-+0.6%
*-commutative0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.5%
Applied egg-rr0.5%
Taylor expanded in a around inf 0.4%
*-commutative0.4%
unpow20.4%
unpow20.4%
Simplified0.4%
Taylor expanded in a around 0 18.8%
if -500 < (*.f64 a x) < 4.99999999999999973e-21Initial program 34.2%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 99.3%
if 4.99999999999999973e-21 < (*.f64 a x) Initial program 96.6%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 60.1%
+-commutative60.1%
associate-*r*60.1%
unpow260.1%
associate-*r*67.4%
distribute-rgt-out67.4%
*-commutative67.4%
*-commutative67.4%
unpow267.4%
associate-*l*67.4%
Simplified67.4%
Final simplification71.2%
(FPCore (a x) :precision binary64 (if (<= (* a x) -500.0) -2.0 (if (<= (* a x) 1e+14) (* a x) (* 0.5 (* a (* a (* x x)))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if ((a * x) <= 1e+14) {
tmp = a * x;
} else {
tmp = 0.5 * (a * (a * (x * x)));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-500.0d0)) then
tmp = -2.0d0
else if ((a * x) <= 1d+14) then
tmp = a * x
else
tmp = 0.5d0 * (a * (a * (x * x)))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -500.0) {
tmp = -2.0;
} else if ((a * x) <= 1e+14) {
tmp = a * x;
} else {
tmp = 0.5 * (a * (a * (x * x)));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -500.0: tmp = -2.0 elif (a * x) <= 1e+14: tmp = a * x else: tmp = 0.5 * (a * (a * (x * x))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -500.0) tmp = -2.0; elseif (Float64(a * x) <= 1e+14) tmp = Float64(a * x); else tmp = Float64(0.5 * Float64(a * Float64(a * Float64(x * x)))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -500.0) tmp = -2.0; elseif ((a * x) <= 1e+14) tmp = a * x; else tmp = 0.5 * (a * (a * (x * x))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -500.0], -2.0, If[LessEqual[N[(a * x), $MachinePrecision], 1e+14], N[(a * x), $MachinePrecision], N[(0.5 * N[(a * N[(a * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -500:\\
\;\;\;\;-2\\
\mathbf{elif}\;a \cdot x \leq 10^{+14}:\\
\;\;\;\;a \cdot x\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(a \cdot \left(a \cdot \left(x \cdot x\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -500Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.5%
+-commutative0.5%
associate-*r*0.5%
unpow20.5%
associate-*r*0.9%
distribute-rgt-out1.1%
*-commutative1.1%
*-commutative1.1%
unpow21.1%
associate-*l*1.1%
Simplified1.1%
distribute-lft-in0.9%
flip-+0.6%
*-commutative0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.5%
Applied egg-rr0.5%
Taylor expanded in a around inf 0.4%
*-commutative0.4%
unpow20.4%
unpow20.4%
Simplified0.4%
Taylor expanded in a around 0 18.8%
if -500 < (*.f64 a x) < 1e14Initial program 35.8%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 96.4%
if 1e14 < (*.f64 a x) Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 65.1%
*-commutative65.1%
associate-*l*65.1%
unpow265.1%
associate-*l*68.7%
distribute-lft-out68.7%
unpow268.7%
associate-*l*68.7%
Simplified68.7%
Taylor expanded in a around inf 65.1%
unpow265.1%
unpow265.1%
associate-*r*68.5%
Simplified68.5%
Final simplification70.9%
(FPCore (a x) :precision binary64 (if (<= (* a x) -2.0) -2.0 (* a x)))
double code(double a, double x) {
double tmp;
if ((a * x) <= -2.0) {
tmp = -2.0;
} else {
tmp = a * x;
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-2.0d0)) then
tmp = -2.0d0
else
tmp = a * x
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -2.0) {
tmp = -2.0;
} else {
tmp = a * x;
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -2.0: tmp = -2.0 else: tmp = a * x return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -2.0) tmp = -2.0; else tmp = Float64(a * x); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -2.0) tmp = -2.0; else tmp = a * x; end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -2.0], -2.0, N[(a * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -2:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;a \cdot x\\
\end{array}
\end{array}
if (*.f64 a x) < -2Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.5%
+-commutative0.5%
associate-*r*0.5%
unpow20.5%
associate-*r*0.9%
distribute-rgt-out1.1%
*-commutative1.1%
*-commutative1.1%
unpow21.1%
associate-*l*1.1%
Simplified1.1%
distribute-lft-in0.9%
flip-+0.6%
*-commutative0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
associate-*l*0.6%
*-commutative0.6%
*-commutative0.6%
associate-*l*0.5%
Applied egg-rr0.5%
Taylor expanded in a around inf 0.4%
*-commutative0.4%
unpow20.4%
unpow20.4%
Simplified0.4%
Taylor expanded in a around 0 18.8%
if -2 < (*.f64 a x) Initial program 56.9%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 75.7%
Final simplification62.1%
(FPCore (a x) :precision binary64 -2.0)
double code(double a, double x) {
return -2.0;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
code = -2.0d0
end function
public static double code(double a, double x) {
return -2.0;
}
def code(a, x): return -2.0
function code(a, x) return -2.0 end
function tmp = code(a, x) tmp = -2.0; end
code[a_, x_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 67.2%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 60.2%
+-commutative60.2%
associate-*r*60.2%
unpow260.2%
associate-*r*65.5%
distribute-rgt-out65.6%
*-commutative65.6%
*-commutative65.6%
unpow265.6%
associate-*l*65.6%
Simplified65.6%
distribute-lft-in65.5%
flip-+22.6%
*-commutative22.6%
*-commutative22.6%
*-commutative22.6%
associate-*l*22.6%
*-commutative22.6%
associate-*l*22.6%
*-commutative22.6%
*-commutative22.6%
associate-*l*25.4%
Applied egg-rr25.4%
Taylor expanded in a around inf 4.1%
*-commutative4.1%
unpow24.1%
unpow24.1%
Simplified4.1%
Taylor expanded in a around 0 6.4%
Final simplification6.4%
(FPCore (a x) :precision binary64 (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)))
double code(double a, double x) {
double tmp;
if (fabs((a * x)) < 0.1) {
tmp = (a * x) * (1.0 + (((a * x) / 2.0) + (pow((a * x), 2.0) / 6.0)));
} else {
tmp = exp((a * x)) - 1.0;
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if (abs((a * x)) < 0.1d0) then
tmp = (a * x) * (1.0d0 + (((a * x) / 2.0d0) + (((a * x) ** 2.0d0) / 6.0d0)))
else
tmp = exp((a * x)) - 1.0d0
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if (Math.abs((a * x)) < 0.1) {
tmp = (a * x) * (1.0 + (((a * x) / 2.0) + (Math.pow((a * x), 2.0) / 6.0)));
} else {
tmp = Math.exp((a * x)) - 1.0;
}
return tmp;
}
def code(a, x): tmp = 0 if math.fabs((a * x)) < 0.1: tmp = (a * x) * (1.0 + (((a * x) / 2.0) + (math.pow((a * x), 2.0) / 6.0))) else: tmp = math.exp((a * x)) - 1.0 return tmp
function code(a, x) tmp = 0.0 if (abs(Float64(a * x)) < 0.1) tmp = Float64(Float64(a * x) * Float64(1.0 + Float64(Float64(Float64(a * x) / 2.0) + Float64((Float64(a * x) ^ 2.0) / 6.0)))); else tmp = Float64(exp(Float64(a * x)) - 1.0); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if (abs((a * x)) < 0.1) tmp = (a * x) * (1.0 + (((a * x) / 2.0) + (((a * x) ^ 2.0) / 6.0))); else tmp = exp((a * x)) - 1.0; end tmp_2 = tmp; end
code[a_, x_] := If[Less[N[Abs[N[(a * x), $MachinePrecision]], $MachinePrecision], 0.1], N[(N[(a * x), $MachinePrecision] * N[(1.0 + N[(N[(N[(a * x), $MachinePrecision] / 2.0), $MachinePrecision] + N[(N[Power[N[(a * x), $MachinePrecision], 2.0], $MachinePrecision] / 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\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}
\end{array}
herbie shell --seed 2023200
(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))