
(FPCore (x y z) :precision binary64 (* (+ x y) (- 1.0 z)))
double code(double x, double y, double z) {
return (x + y) * (1.0 - z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) * (1.0d0 - z)
end function
public static double code(double x, double y, double z) {
return (x + y) * (1.0 - z);
}
def code(x, y, z): return (x + y) * (1.0 - z)
function code(x, y, z) return Float64(Float64(x + y) * Float64(1.0 - z)) end
function tmp = code(x, y, z) tmp = (x + y) * (1.0 - z); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) \cdot \left(1 - z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* (+ x y) (- 1.0 z)))
double code(double x, double y, double z) {
return (x + y) * (1.0 - z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) * (1.0d0 - z)
end function
public static double code(double x, double y, double z) {
return (x + y) * (1.0 - z);
}
def code(x, y, z): return (x + y) * (1.0 - z)
function code(x, y, z) return Float64(Float64(x + y) * Float64(1.0 - z)) end
function tmp = code(x, y, z) tmp = (x + y) * (1.0 - z); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) \cdot \left(1 - z\right)
\end{array}
(FPCore (x y z) :precision binary64 (* (- 1.0 z) (+ x y)))
double code(double x, double y, double z) {
return (1.0 - z) * (x + y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 - z) * (x + y)
end function
public static double code(double x, double y, double z) {
return (1.0 - z) * (x + y);
}
def code(x, y, z): return (1.0 - z) * (x + y)
function code(x, y, z) return Float64(Float64(1.0 - z) * Float64(x + y)) end
function tmp = code(x, y, z) tmp = (1.0 - z) * (x + y); end
code[x_, y_, z_] := N[(N[(1.0 - z), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - z\right) \cdot \left(x + y\right)
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (- 1.0 z)))) (if (<= (- 1.0 z) 0.999995) t_0 (if (<= (- 1.0 z) 1.6e+19) (+ x y) t_0))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - z);
double tmp;
if ((1.0 - z) <= 0.999995) {
tmp = t_0;
} else if ((1.0 - z) <= 1.6e+19) {
tmp = x + y;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 - z)
if ((1.0d0 - z) <= 0.999995d0) then
tmp = t_0
else if ((1.0d0 - z) <= 1.6d+19) then
tmp = x + y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (1.0 - z);
double tmp;
if ((1.0 - z) <= 0.999995) {
tmp = t_0;
} else if ((1.0 - z) <= 1.6e+19) {
tmp = x + y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - z) tmp = 0 if (1.0 - z) <= 0.999995: tmp = t_0 elif (1.0 - z) <= 1.6e+19: tmp = x + y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - z)) tmp = 0.0 if (Float64(1.0 - z) <= 0.999995) tmp = t_0; elseif (Float64(1.0 - z) <= 1.6e+19) tmp = Float64(x + y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - z); tmp = 0.0; if ((1.0 - z) <= 0.999995) tmp = t_0; elseif ((1.0 - z) <= 1.6e+19) tmp = x + y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 - z), $MachinePrecision], 0.999995], t$95$0, If[LessEqual[N[(1.0 - z), $MachinePrecision], 1.6e+19], N[(x + y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - z\right)\\
\mathbf{if}\;1 - z \leq 0.999995:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;1 - z \leq 1.6 \cdot 10^{+19}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) z) < 0.99999499999999997 or 1.6e19 < (-.f64 #s(literal 1 binary64) z) Initial program 100.0%
Taylor expanded in x around 0
*-lowering-*.f64N/A
--lowering--.f6449.8%
Simplified49.8%
if 0.99999499999999997 < (-.f64 #s(literal 1 binary64) z) < 1.6e19Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
+-lowering-+.f6494.5%
Simplified94.5%
Final simplification72.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.55e-34) (* x (- 1.0 z)) (- y (* y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.55e-34) {
tmp = x * (1.0 - z);
} else {
tmp = y - (y * z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.55d-34) then
tmp = x * (1.0d0 - z)
else
tmp = y - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.55e-34) {
tmp = x * (1.0 - z);
} else {
tmp = y - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.55e-34: tmp = x * (1.0 - z) else: tmp = y - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.55e-34) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(y - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.55e-34) tmp = x * (1.0 - z); else tmp = y - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.55e-34], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{-34}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot z\\
\end{array}
\end{array}
if y < 1.5499999999999999e-34Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f6460.1%
Simplified60.1%
if 1.5499999999999999e-34 < y Initial program 100.0%
sub-negN/A
distribute-lft-inN/A
fma-defineN/A
distribute-rgt-neg-outN/A
fmm-undefN/A
*-rgt-identityN/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0
Simplified84.1%
Taylor expanded in x around 0
*-commutativeN/A
*-lowering-*.f6465.2%
Simplified65.2%
Final simplification61.5%
(FPCore (x y z) :precision binary64 (if (<= y 7.5e-35) (* x (- 1.0 z)) (* y (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 7.5e-35) {
tmp = x * (1.0 - z);
} else {
tmp = y * (1.0 - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 7.5d-35) then
tmp = x * (1.0d0 - z)
else
tmp = y * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 7.5e-35) {
tmp = x * (1.0 - z);
} else {
tmp = y * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7.5e-35: tmp = x * (1.0 - z) else: tmp = y * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7.5e-35) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(y * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 7.5e-35) tmp = x * (1.0 - z); else tmp = y * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7.5e-35], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{-35}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 7.5e-35Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f6460.1%
Simplified60.1%
if 7.5e-35 < y Initial program 100.0%
Taylor expanded in x around 0
*-lowering-*.f64N/A
--lowering--.f6465.2%
Simplified65.2%
Final simplification61.5%
(FPCore (x y z) :precision binary64 (if (<= y 4000000.0) x y))
double code(double x, double y, double z) {
double tmp;
if (y <= 4000000.0) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 4000000.0d0) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4000000.0) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4000000.0: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4000000.0) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4000000.0) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4000000.0], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 4e6Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f6461.2%
Simplified61.2%
Taylor expanded in z around 0
Simplified30.8%
if 4e6 < y Initial program 100.0%
Taylor expanded in x around 0
*-lowering-*.f64N/A
--lowering--.f6471.7%
Simplified71.7%
Taylor expanded in z around 0
Simplified35.2%
(FPCore (x y z) :precision binary64 (+ x y))
double code(double x, double y, double z) {
return x + y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + y
end function
public static double code(double x, double y, double z) {
return x + y;
}
def code(x, y, z): return x + y
function code(x, y, z) return Float64(x + y) end
function tmp = code(x, y, z) tmp = x + y; end
code[x_, y_, z_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
+-lowering-+.f6450.1%
Simplified50.1%
Final simplification50.1%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f6454.3%
Simplified54.3%
Taylor expanded in z around 0
Simplified27.3%
herbie shell --seed 2024139
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, H"
:precision binary64
(* (+ x y) (- 1.0 z)))