
(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 11 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 50.9%
accelerator-lowering-expm1.f64N/A
*-lowering-*.f64100.0%
Applied egg-rr100.0%
(FPCore (a x)
:precision binary64
(if (<= (* a x) -100.0)
-1.0
(+
(* a x)
(*
a
(*
(* a x)
(*
x
(+
0.5
(*
(* a x)
(+ 0.16666666666666666 (* a (* x 0.041666666666666664)))))))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = (a * x) + (a * ((a * x) * (x * (0.5 + ((a * x) * (0.16666666666666666 + (a * (x * 0.041666666666666664))))))));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-100.0d0)) then
tmp = -1.0d0
else
tmp = (a * x) + (a * ((a * x) * (x * (0.5d0 + ((a * x) * (0.16666666666666666d0 + (a * (x * 0.041666666666666664d0))))))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = (a * x) + (a * ((a * x) * (x * (0.5 + ((a * x) * (0.16666666666666666 + (a * (x * 0.041666666666666664))))))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -1.0 else: tmp = (a * x) + (a * ((a * x) * (x * (0.5 + ((a * x) * (0.16666666666666666 + (a * (x * 0.041666666666666664)))))))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = -1.0; else tmp = Float64(Float64(a * x) + Float64(a * Float64(Float64(a * x) * Float64(x * Float64(0.5 + Float64(Float64(a * x) * Float64(0.16666666666666666 + Float64(a * Float64(x * 0.041666666666666664))))))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -1.0; else tmp = (a * x) + (a * ((a * x) * (x * (0.5 + ((a * x) * (0.16666666666666666 + (a * (x * 0.041666666666666664)))))))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], -1.0, N[(N[(a * x), $MachinePrecision] + N[(a * N[(N[(a * x), $MachinePrecision] * N[(x * N[(0.5 + N[(N[(a * x), $MachinePrecision] * N[(0.16666666666666666 + N[(a * N[(x * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;a \cdot x + a \cdot \left(\left(a \cdot x\right) \cdot \left(x \cdot \left(0.5 + \left(a \cdot x\right) \cdot \left(0.16666666666666666 + a \cdot \left(x \cdot 0.041666666666666664\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f645.3%
Simplified5.3%
flip3-+N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
cube-multN/A
*-lowering-*.f64N/A
Applied egg-rr2.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified98.9%
Taylor expanded in x around inf
Simplified100.0%
if -100 < (*.f64 a x) Initial program 27.3%
Taylor expanded in a around 0
Simplified99.0%
distribute-rgt-inN/A
*-lft-identityN/A
distribute-rgt-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
Applied egg-rr99.0%
Final simplification99.3%
(FPCore (a x)
:precision binary64
(if (<= (* a x) -100.0)
-1.0
(*
a
(+
x
(*
(* a x)
(*
x
(+
0.5
(*
(* a x)
(+ 0.16666666666666666 (* a (* x 0.041666666666666664)))))))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = a * (x + ((a * x) * (x * (0.5 + ((a * x) * (0.16666666666666666 + (a * (x * 0.041666666666666664))))))));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-100.0d0)) then
tmp = -1.0d0
else
tmp = a * (x + ((a * x) * (x * (0.5d0 + ((a * x) * (0.16666666666666666d0 + (a * (x * 0.041666666666666664d0))))))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = a * (x + ((a * x) * (x * (0.5 + ((a * x) * (0.16666666666666666 + (a * (x * 0.041666666666666664))))))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -1.0 else: tmp = a * (x + ((a * x) * (x * (0.5 + ((a * x) * (0.16666666666666666 + (a * (x * 0.041666666666666664)))))))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = -1.0; else tmp = Float64(a * Float64(x + Float64(Float64(a * x) * Float64(x * Float64(0.5 + Float64(Float64(a * x) * Float64(0.16666666666666666 + Float64(a * Float64(x * 0.041666666666666664))))))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -1.0; else tmp = a * (x + ((a * x) * (x * (0.5 + ((a * x) * (0.16666666666666666 + (a * (x * 0.041666666666666664)))))))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], -1.0, N[(a * N[(x + N[(N[(a * x), $MachinePrecision] * N[(x * N[(0.5 + N[(N[(a * x), $MachinePrecision] * N[(0.16666666666666666 + N[(a * N[(x * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(x + \left(a \cdot x\right) \cdot \left(x \cdot \left(0.5 + \left(a \cdot x\right) \cdot \left(0.16666666666666666 + a \cdot \left(x \cdot 0.041666666666666664\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f645.3%
Simplified5.3%
flip3-+N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
cube-multN/A
*-lowering-*.f64N/A
Applied egg-rr2.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified98.9%
Taylor expanded in x around inf
Simplified100.0%
if -100 < (*.f64 a x) Initial program 27.3%
Taylor expanded in a around 0
Simplified99.0%
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
+-lowering-+.f64N/A
Applied egg-rr99.0%
Final simplification99.3%
(FPCore (a x)
:precision binary64
(if (<= (* a x) -100.0)
-1.0
(*
a
(*
x
(+
1.0
(*
a
(*
x
(+
0.5
(*
(* a x)
(+ 0.16666666666666666 (* (* a x) 0.041666666666666664)))))))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = a * (x * (1.0 + (a * (x * (0.5 + ((a * x) * (0.16666666666666666 + ((a * x) * 0.041666666666666664))))))));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-100.0d0)) then
tmp = -1.0d0
else
tmp = a * (x * (1.0d0 + (a * (x * (0.5d0 + ((a * x) * (0.16666666666666666d0 + ((a * x) * 0.041666666666666664d0))))))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = a * (x * (1.0 + (a * (x * (0.5 + ((a * x) * (0.16666666666666666 + ((a * x) * 0.041666666666666664))))))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -1.0 else: tmp = a * (x * (1.0 + (a * (x * (0.5 + ((a * x) * (0.16666666666666666 + ((a * x) * 0.041666666666666664)))))))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = -1.0; else tmp = Float64(a * Float64(x * Float64(1.0 + Float64(a * Float64(x * Float64(0.5 + Float64(Float64(a * x) * Float64(0.16666666666666666 + Float64(Float64(a * x) * 0.041666666666666664))))))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -1.0; else tmp = a * (x * (1.0 + (a * (x * (0.5 + ((a * x) * (0.16666666666666666 + ((a * x) * 0.041666666666666664)))))))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], -1.0, N[(a * N[(x * N[(1.0 + N[(a * N[(x * N[(0.5 + N[(N[(a * x), $MachinePrecision] * N[(0.16666666666666666 + N[(N[(a * x), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(x \cdot \left(1 + a \cdot \left(x \cdot \left(0.5 + \left(a \cdot x\right) \cdot \left(0.16666666666666666 + \left(a \cdot x\right) \cdot 0.041666666666666664\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f645.3%
Simplified5.3%
flip3-+N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
cube-multN/A
*-lowering-*.f64N/A
Applied egg-rr2.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified98.9%
Taylor expanded in x around inf
Simplified100.0%
if -100 < (*.f64 a x) Initial program 27.3%
Taylor expanded in a around 0
Simplified99.0%
(FPCore (a x) :precision binary64 (if (<= (* a x) -100.0) -1.0 (* (* a x) (+ 1.0 (* (* a x) (+ 0.5 (* x (* a 0.16666666666666666))))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = (a * x) * (1.0 + ((a * x) * (0.5 + (x * (a * 0.16666666666666666)))));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-100.0d0)) then
tmp = -1.0d0
else
tmp = (a * x) * (1.0d0 + ((a * x) * (0.5d0 + (x * (a * 0.16666666666666666d0)))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = (a * x) * (1.0 + ((a * x) * (0.5 + (x * (a * 0.16666666666666666)))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -1.0 else: tmp = (a * x) * (1.0 + ((a * x) * (0.5 + (x * (a * 0.16666666666666666))))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = -1.0; else tmp = Float64(Float64(a * x) * Float64(1.0 + Float64(Float64(a * x) * Float64(0.5 + Float64(x * Float64(a * 0.16666666666666666)))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -1.0; else tmp = (a * x) * (1.0 + ((a * x) * (0.5 + (x * (a * 0.16666666666666666))))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], -1.0, N[(N[(a * x), $MachinePrecision] * N[(1.0 + N[(N[(a * x), $MachinePrecision] * N[(0.5 + N[(x * N[(a * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot x\right) \cdot \left(1 + \left(a \cdot x\right) \cdot \left(0.5 + x \cdot \left(a \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f645.3%
Simplified5.3%
flip3-+N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
cube-multN/A
*-lowering-*.f64N/A
Applied egg-rr2.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified98.9%
Taylor expanded in x around inf
Simplified100.0%
if -100 < (*.f64 a x) Initial program 27.3%
Taylor expanded in a around 0
+-commutativeN/A
distribute-lft-inN/A
associate-+l+N/A
associate-*r*N/A
associate-*r*N/A
unpow3N/A
unpow2N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
distribute-lft1-inN/A
distribute-rgt-outN/A
Simplified98.8%
(FPCore (a x) :precision binary64 (if (<= (* a x) -100.0) -1.0 (+ (* a x) (* a (* x (* a (/ x 2.0)))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = (a * x) + (a * (x * (a * (x / 2.0))));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-100.0d0)) then
tmp = -1.0d0
else
tmp = (a * x) + (a * (x * (a * (x / 2.0d0))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = (a * x) + (a * (x * (a * (x / 2.0))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -1.0 else: tmp = (a * x) + (a * (x * (a * (x / 2.0)))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = -1.0; else tmp = Float64(Float64(a * x) + Float64(a * Float64(x * Float64(a * Float64(x / 2.0))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -1.0; else tmp = (a * x) + (a * (x * (a * (x / 2.0)))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], -1.0, N[(N[(a * x), $MachinePrecision] + N[(a * N[(x * N[(a * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;a \cdot x + a \cdot \left(x \cdot \left(a \cdot \frac{x}{2}\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f645.3%
Simplified5.3%
flip3-+N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
cube-multN/A
*-lowering-*.f64N/A
Applied egg-rr2.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified98.9%
Taylor expanded in x around inf
Simplified100.0%
if -100 < (*.f64 a x) Initial program 27.3%
Taylor expanded in a around 0
distribute-lft-inN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6498.5%
Simplified98.5%
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
+-lowering-+.f64N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
metadata-evalN/A
div-invN/A
/-lowering-/.f64N/A
*-lowering-*.f6498.5%
Applied egg-rr98.5%
Final simplification99.0%
(FPCore (a x) :precision binary64 (if (<= (* a x) -100.0) -1.0 (* (* a x) (+ 1.0 (* (* a x) 0.5)))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = (a * x) * (1.0 + ((a * 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) <= (-100.0d0)) then
tmp = -1.0d0
else
tmp = (a * x) * (1.0d0 + ((a * x) * 0.5d0))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = (a * x) * (1.0 + ((a * x) * 0.5));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -1.0 else: tmp = (a * x) * (1.0 + ((a * x) * 0.5)) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = -1.0; else tmp = Float64(Float64(a * x) * Float64(1.0 + Float64(Float64(a * x) * 0.5))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -1.0; else tmp = (a * x) * (1.0 + ((a * x) * 0.5)); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], -1.0, N[(N[(a * x), $MachinePrecision] * N[(1.0 + N[(N[(a * x), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot x\right) \cdot \left(1 + \left(a \cdot x\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f645.3%
Simplified5.3%
flip3-+N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
cube-multN/A
*-lowering-*.f64N/A
Applied egg-rr2.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified98.9%
Taylor expanded in x around inf
Simplified100.0%
if -100 < (*.f64 a x) Initial program 27.3%
Taylor expanded in a around 0
distribute-lft-inN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6498.5%
Simplified98.5%
(FPCore (a x) :precision binary64 (if (<= (* a x) -100.0) -1.0 (* a (* x (+ 1.0 (* a (* x 0.5)))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = a * (x * (1.0 + (a * (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) <= (-100.0d0)) then
tmp = -1.0d0
else
tmp = a * (x * (1.0d0 + (a * (x * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = a * (x * (1.0 + (a * (x * 0.5))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -1.0 else: tmp = a * (x * (1.0 + (a * (x * 0.5)))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = -1.0; else tmp = Float64(a * Float64(x * Float64(1.0 + Float64(a * Float64(x * 0.5))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -1.0; else tmp = a * (x * (1.0 + (a * (x * 0.5)))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], -1.0, N[(a * N[(x * N[(1.0 + N[(a * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(x \cdot \left(1 + a \cdot \left(x \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f645.3%
Simplified5.3%
flip3-+N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
cube-multN/A
*-lowering-*.f64N/A
Applied egg-rr2.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified98.9%
Taylor expanded in x around inf
Simplified100.0%
if -100 < (*.f64 a x) Initial program 27.3%
accelerator-lowering-expm1.f64N/A
*-lowering-*.f6499.9%
Applied egg-rr99.9%
Taylor expanded in a around 0
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
distribute-lft-inN/A
*-lowering-*.f64N/A
associate-*r*N/A
*-commutativeN/A
*-lft-identityN/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
distribute-rgt-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6498.5%
Simplified98.5%
(FPCore (a x) :precision binary64 (if (<= (* a x) -100.0) -1.0 (* a x)))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.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) <= (-100.0d0)) then
tmp = -1.0d0
else
tmp = a * x
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -1.0;
} else {
tmp = a * x;
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -1.0 else: tmp = a * x return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = -1.0; else tmp = Float64(a * x); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -1.0; else tmp = a * x; end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], -1.0, N[(a * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;a \cdot x\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f645.3%
Simplified5.3%
flip3-+N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
cube-multN/A
*-lowering-*.f64N/A
Applied egg-rr2.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified98.9%
Taylor expanded in x around inf
Simplified100.0%
if -100 < (*.f64 a x) Initial program 27.3%
Taylor expanded in a around 0
*-lowering-*.f6497.7%
Simplified97.7%
(FPCore (a x) :precision binary64 (if (<= x 1.85e-146) 0.0 -1.0))
double code(double a, double x) {
double tmp;
if (x <= 1.85e-146) {
tmp = 0.0;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.85d-146) then
tmp = 0.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if (x <= 1.85e-146) {
tmp = 0.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, x): tmp = 0 if x <= 1.85e-146: tmp = 0.0 else: tmp = -1.0 return tmp
function code(a, x) tmp = 0.0 if (x <= 1.85e-146) tmp = 0.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if (x <= 1.85e-146) tmp = 0.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[x, 1.85e-146], 0.0, -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.85 \cdot 10^{-146}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < 1.84999999999999993e-146Initial program 49.7%
Taylor expanded in a around 0
Simplified21.9%
metadata-eval21.9%
Applied egg-rr21.9%
if 1.84999999999999993e-146 < x Initial program 53.6%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f648.8%
Simplified8.8%
flip3-+N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
cube-multN/A
*-lowering-*.f64N/A
Applied egg-rr7.8%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified53.2%
Taylor expanded in x around inf
Simplified48.8%
(FPCore (a x) :precision binary64 -1.0)
double code(double a, double x) {
return -1.0;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
code = -1.0d0
end function
public static double code(double a, double x) {
return -1.0;
}
def code(a, x): return -1.0
function code(a, x) return -1.0 end
function tmp = code(a, x) tmp = -1.0; end
code[a_, x_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 50.9%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f6419.1%
Simplified19.1%
flip3-+N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
cube-multN/A
*-lowering-*.f64N/A
Applied egg-rr18.4%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
Simplified49.3%
Taylor expanded in x around inf
Simplified34.9%
(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}
herbie shell --seed 2024192
(FPCore (a x)
:name "expax (section 3.5)"
:precision binary64
:pre (> 710.0 (* a x))
:alt
(! :herbie-platform default (expm1 (* a x)))
(- (exp (* a x)) 1.0))