
(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 12 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 (- (+ x y) (* z (+ x y))))
double code(double x, double y, double z) {
return (x + y) - (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 = (x + y) - (z * (x + y))
end function
public static double code(double x, double y, double z) {
return (x + y) - (z * (x + y));
}
def code(x, y, z): return (x + y) - (z * (x + y))
function code(x, y, z) return Float64(Float64(x + y) - Float64(z * Float64(x + y))) end
function tmp = code(x, y, z) tmp = (x + y) - (z * (x + y)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] - N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) - z \cdot \left(x + y\right)
\end{array}
Initial program 100.0%
sub-neg100.0%
distribute-lft-in100.0%
*-commutative100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 z))) (t_1 (* x (- z))))
(if (<= z -9e+261)
t_1
(if (<= z -2.9e+155)
(* y (- z))
(if (<= z -1.4e+106)
t_1
(if (<= z -6e-10)
t_0
(if (<= z 1.0) (+ x y) (if (<= z 1.04e+223) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - z);
double t_1 = x * -z;
double tmp;
if (z <= -9e+261) {
tmp = t_1;
} else if (z <= -2.9e+155) {
tmp = y * -z;
} else if (z <= -1.4e+106) {
tmp = t_1;
} else if (z <= -6e-10) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x + y;
} else if (z <= 1.04e+223) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = y * (1.0d0 - z)
t_1 = x * -z
if (z <= (-9d+261)) then
tmp = t_1
else if (z <= (-2.9d+155)) then
tmp = y * -z
else if (z <= (-1.4d+106)) then
tmp = t_1
else if (z <= (-6d-10)) then
tmp = t_0
else if (z <= 1.0d0) then
tmp = x + y
else if (z <= 1.04d+223) then
tmp = t_1
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 t_1 = x * -z;
double tmp;
if (z <= -9e+261) {
tmp = t_1;
} else if (z <= -2.9e+155) {
tmp = y * -z;
} else if (z <= -1.4e+106) {
tmp = t_1;
} else if (z <= -6e-10) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x + y;
} else if (z <= 1.04e+223) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - z) t_1 = x * -z tmp = 0 if z <= -9e+261: tmp = t_1 elif z <= -2.9e+155: tmp = y * -z elif z <= -1.4e+106: tmp = t_1 elif z <= -6e-10: tmp = t_0 elif z <= 1.0: tmp = x + y elif z <= 1.04e+223: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - z)) t_1 = Float64(x * Float64(-z)) tmp = 0.0 if (z <= -9e+261) tmp = t_1; elseif (z <= -2.9e+155) tmp = Float64(y * Float64(-z)); elseif (z <= -1.4e+106) tmp = t_1; elseif (z <= -6e-10) tmp = t_0; elseif (z <= 1.0) tmp = Float64(x + y); elseif (z <= 1.04e+223) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - z); t_1 = x * -z; tmp = 0.0; if (z <= -9e+261) tmp = t_1; elseif (z <= -2.9e+155) tmp = y * -z; elseif (z <= -1.4e+106) tmp = t_1; elseif (z <= -6e-10) tmp = t_0; elseif (z <= 1.0) tmp = x + y; elseif (z <= 1.04e+223) tmp = t_1; 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]}, Block[{t$95$1 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[z, -9e+261], t$95$1, If[LessEqual[z, -2.9e+155], N[(y * (-z)), $MachinePrecision], If[LessEqual[z, -1.4e+106], t$95$1, If[LessEqual[z, -6e-10], t$95$0, If[LessEqual[z, 1.0], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.04e+223], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - z\right)\\
t_1 := x \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -9 \cdot 10^{+261}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -2.9 \cdot 10^{+155}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{+106}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -6 \cdot 10^{-10}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 1.04 \cdot 10^{+223}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -8.9999999999999998e261 or -2.8999999999999999e155 < z < -1.39999999999999996e106 or 1 < z < 1.04e223Initial program 100.0%
Taylor expanded in z around inf 99.7%
mul-1-neg99.7%
distribute-lft-neg-out99.7%
*-commutative99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in y around 0 46.3%
associate-*r*46.3%
mul-1-neg46.3%
Simplified46.3%
if -8.9999999999999998e261 < z < -2.8999999999999999e155Initial program 100.0%
Taylor expanded in x around 0 35.0%
Taylor expanded in z around inf 35.0%
mul-1-neg35.0%
distribute-rgt-neg-in35.0%
Simplified35.0%
if -1.39999999999999996e106 < z < -6e-10 or 1.04e223 < z Initial program 99.9%
Taylor expanded in x around 0 51.4%
if -6e-10 < z < 1Initial program 99.9%
Taylor expanded in z around 0 97.7%
+-commutative97.7%
Simplified97.7%
Final simplification70.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* y (- z))))
(if (<= z -2.9e+262)
t_0
(if (<= z -3.8e+150)
t_1
(if (<= z -1350000.0)
t_0
(if (<= z 1.0) (+ x y) (if (<= z 3.8e+223) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = y * -z;
double tmp;
if (z <= -2.9e+262) {
tmp = t_0;
} else if (z <= -3.8e+150) {
tmp = t_1;
} else if (z <= -1350000.0) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x + y;
} else if (z <= 3.8e+223) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = x * -z
t_1 = y * -z
if (z <= (-2.9d+262)) then
tmp = t_0
else if (z <= (-3.8d+150)) then
tmp = t_1
else if (z <= (-1350000.0d0)) then
tmp = t_0
else if (z <= 1.0d0) then
tmp = x + y
else if (z <= 3.8d+223) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = y * -z;
double tmp;
if (z <= -2.9e+262) {
tmp = t_0;
} else if (z <= -3.8e+150) {
tmp = t_1;
} else if (z <= -1350000.0) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x + y;
} else if (z <= 3.8e+223) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = y * -z tmp = 0 if z <= -2.9e+262: tmp = t_0 elif z <= -3.8e+150: tmp = t_1 elif z <= -1350000.0: tmp = t_0 elif z <= 1.0: tmp = x + y elif z <= 3.8e+223: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) t_1 = Float64(y * Float64(-z)) tmp = 0.0 if (z <= -2.9e+262) tmp = t_0; elseif (z <= -3.8e+150) tmp = t_1; elseif (z <= -1350000.0) tmp = t_0; elseif (z <= 1.0) tmp = Float64(x + y); elseif (z <= 3.8e+223) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; t_1 = y * -z; tmp = 0.0; if (z <= -2.9e+262) tmp = t_0; elseif (z <= -3.8e+150) tmp = t_1; elseif (z <= -1350000.0) tmp = t_0; elseif (z <= 1.0) tmp = x + y; elseif (z <= 3.8e+223) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(y * (-z)), $MachinePrecision]}, If[LessEqual[z, -2.9e+262], t$95$0, If[LessEqual[z, -3.8e+150], t$95$1, If[LessEqual[z, -1350000.0], t$95$0, If[LessEqual[z, 1.0], N[(x + y), $MachinePrecision], If[LessEqual[z, 3.8e+223], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := y \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -2.9 \cdot 10^{+262}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3.8 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1350000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+223}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.8999999999999998e262 or -3.79999999999999989e150 < z < -1.35e6 or 1 < z < 3.8e223Initial program 100.0%
Taylor expanded in z around inf 98.5%
mul-1-neg98.5%
distribute-lft-neg-out98.5%
*-commutative98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in y around 0 44.9%
associate-*r*44.9%
mul-1-neg44.9%
Simplified44.9%
if -2.8999999999999998e262 < z < -3.79999999999999989e150 or 3.8e223 < z Initial program 100.0%
Taylor expanded in x around 0 40.8%
Taylor expanded in z around inf 40.8%
mul-1-neg40.8%
distribute-rgt-neg-in40.8%
Simplified40.8%
if -1.35e6 < z < 1Initial program 99.9%
Taylor expanded in z around 0 93.9%
+-commutative93.9%
Simplified93.9%
Final simplification69.0%
(FPCore (x y z) :precision binary64 (if (or (<= (- 1.0 z) -5000000000000.0) (not (<= (- 1.0 z) 2.0))) (* (- z) (+ x y)) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - z) <= -5000000000000.0) || !((1.0 - z) <= 2.0)) {
tmp = -z * (x + y);
} else {
tmp = x + 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 (((1.0d0 - z) <= (-5000000000000.0d0)) .or. (.not. ((1.0d0 - z) <= 2.0d0))) then
tmp = -z * (x + y)
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - z) <= -5000000000000.0) || !((1.0 - z) <= 2.0)) {
tmp = -z * (x + y);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - z) <= -5000000000000.0) or not ((1.0 - z) <= 2.0): tmp = -z * (x + y) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(1.0 - z) <= -5000000000000.0) || !(Float64(1.0 - z) <= 2.0)) tmp = Float64(Float64(-z) * Float64(x + y)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - z) <= -5000000000000.0) || ~(((1.0 - z) <= 2.0))) tmp = -z * (x + y); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(1.0 - z), $MachinePrecision], -5000000000000.0], N[Not[LessEqual[N[(1.0 - z), $MachinePrecision], 2.0]], $MachinePrecision]], N[((-z) * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - z \leq -5000000000000 \lor \neg \left(1 - z \leq 2\right):\\
\;\;\;\;\left(-z\right) \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) z) < -5e12 or 2 < (-.f64 #s(literal 1 binary64) z) Initial program 100.0%
Taylor expanded in z around inf 97.4%
mul-1-neg97.4%
distribute-lft-neg-out97.4%
*-commutative97.4%
+-commutative97.4%
Simplified97.4%
if -5e12 < (-.f64 #s(literal 1 binary64) z) < 2Initial program 99.9%
Taylor expanded in z around 0 95.8%
+-commutative95.8%
Simplified95.8%
Final simplification96.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -110.0) (not (<= z 1.0))) (* y (- z)) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -110.0) || !(z <= 1.0)) {
tmp = y * -z;
} else {
tmp = x + 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 ((z <= (-110.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = y * -z
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -110.0) || !(z <= 1.0)) {
tmp = y * -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -110.0) or not (z <= 1.0): tmp = y * -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -110.0) || !(z <= 1.0)) tmp = Float64(y * Float64(-z)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -110.0) || ~((z <= 1.0))) tmp = y * -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -110.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(y * (-z)), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -110 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;y \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -110 or 1 < z Initial program 100.0%
Taylor expanded in x around 0 52.4%
Taylor expanded in z around inf 51.7%
mul-1-neg51.7%
distribute-rgt-neg-in51.7%
Simplified51.7%
if -110 < z < 1Initial program 99.9%
Taylor expanded in z around 0 95.2%
+-commutative95.2%
Simplified95.2%
Final simplification73.1%
(FPCore (x y z) :precision binary64 (if (<= y 7e-108) (* x (- 1.0 z)) (* y (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 7e-108) {
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 <= 7d-108) 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 <= 7e-108) {
tmp = x * (1.0 - z);
} else {
tmp = y * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7e-108: tmp = x * (1.0 - z) else: tmp = y * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7e-108) 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 <= 7e-108) tmp = x * (1.0 - z); else tmp = y * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7e-108], 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 \cdot 10^{-108}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 6.9999999999999997e-108Initial program 99.9%
Taylor expanded in x around inf 61.4%
*-commutative61.4%
Simplified61.4%
if 6.9999999999999997e-108 < y Initial program 100.0%
Taylor expanded in x around 0 72.7%
Final simplification65.1%
(FPCore (x y z) :precision binary64 (if (<= y 6.5e-108) (- x (* x z)) (* y (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.5e-108) {
tmp = x - (x * 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 <= 6.5d-108) then
tmp = x - (x * 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 <= 6.5e-108) {
tmp = x - (x * z);
} else {
tmp = y * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6.5e-108: tmp = x - (x * z) else: tmp = y * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6.5e-108) tmp = Float64(x - Float64(x * 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 <= 6.5e-108) tmp = x - (x * z); else tmp = y * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6.5e-108], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{-108}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 6.5000000000000002e-108Initial program 99.9%
sub-neg99.9%
distribute-lft-in100.0%
*-commutative100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 61.4%
mul-1-neg61.4%
unsub-neg61.4%
*-commutative61.4%
Applied egg-rr61.4%
if 6.5000000000000002e-108 < y Initial program 100.0%
Taylor expanded in x around 0 72.7%
Final simplification65.1%
(FPCore (x y z) :precision binary64 (if (<= y 7e-108) (- x (* x z)) (- y (* y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 7e-108) {
tmp = x - (x * 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 <= 7d-108) then
tmp = x - (x * 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 <= 7e-108) {
tmp = x - (x * z);
} else {
tmp = y - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7e-108: tmp = x - (x * z) else: tmp = y - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7e-108) tmp = Float64(x - Float64(x * z)); else tmp = Float64(y - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 7e-108) tmp = x - (x * z); else tmp = y - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7e-108], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(y - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{-108}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot z\\
\end{array}
\end{array}
if y < 6.9999999999999997e-108Initial program 99.9%
sub-neg99.9%
distribute-lft-in100.0%
*-commutative100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 61.4%
mul-1-neg61.4%
unsub-neg61.4%
*-commutative61.4%
Applied egg-rr61.4%
if 6.9999999999999997e-108 < y Initial program 100.0%
Taylor expanded in x around 0 72.7%
distribute-rgt-out--72.7%
*-un-lft-identity72.7%
Applied egg-rr72.7%
Final simplification65.1%
(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 (if (<= y 1.16e-89) x y))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.16e-89) {
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 <= 1.16d-89) 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 <= 1.16e-89) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.16e-89: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.16e-89) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.16e-89) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.16e-89], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.16 \cdot 10^{-89}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 1.15999999999999993e-89Initial program 99.9%
Taylor expanded in x around inf 60.9%
*-commutative60.9%
Simplified60.9%
Taylor expanded in z around 0 29.8%
if 1.15999999999999993e-89 < y Initial program 100.0%
Taylor expanded in x around 0 72.9%
Taylor expanded in z around 0 45.1%
Final simplification34.7%
(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 48.8%
+-commutative48.8%
Simplified48.8%
Final simplification48.8%
(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 51.9%
*-commutative51.9%
Simplified51.9%
Taylor expanded in z around 0 25.7%
Final simplification25.7%
herbie shell --seed 2024095
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, H"
:precision binary64
(* (+ x y) (- 1.0 z)))