
(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 8 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 (* x (- 1.0 z))) (t_1 (* y (- z))) (t_2 (* x (- z))))
(if (<= (- 1.0 z) -2e+206)
t_1
(if (<= (- 1.0 z) -5e+131)
t_2
(if (<= (- 1.0 z) -1e+43)
t_1
(if (<= (- 1.0 z) 0.999995)
t_0
(if (<= (- 1.0 z) 2.0)
(+ x y)
(if (<= (- 1.0 z) 1e+125)
t_0
(if (or (<= (- 1.0 z) 1e+180) (not (<= (- 1.0 z) 2e+226)))
t_1
t_2)))))))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - z);
double t_1 = y * -z;
double t_2 = x * -z;
double tmp;
if ((1.0 - z) <= -2e+206) {
tmp = t_1;
} else if ((1.0 - z) <= -5e+131) {
tmp = t_2;
} else if ((1.0 - z) <= -1e+43) {
tmp = t_1;
} else if ((1.0 - z) <= 0.999995) {
tmp = t_0;
} else if ((1.0 - z) <= 2.0) {
tmp = x + y;
} else if ((1.0 - z) <= 1e+125) {
tmp = t_0;
} else if (((1.0 - z) <= 1e+180) || !((1.0 - z) <= 2e+226)) {
tmp = t_1;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = x * (1.0d0 - z)
t_1 = y * -z
t_2 = x * -z
if ((1.0d0 - z) <= (-2d+206)) then
tmp = t_1
else if ((1.0d0 - z) <= (-5d+131)) then
tmp = t_2
else if ((1.0d0 - z) <= (-1d+43)) then
tmp = t_1
else if ((1.0d0 - z) <= 0.999995d0) then
tmp = t_0
else if ((1.0d0 - z) <= 2.0d0) then
tmp = x + y
else if ((1.0d0 - z) <= 1d+125) then
tmp = t_0
else if (((1.0d0 - z) <= 1d+180) .or. (.not. ((1.0d0 - z) <= 2d+226))) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - z);
double t_1 = y * -z;
double t_2 = x * -z;
double tmp;
if ((1.0 - z) <= -2e+206) {
tmp = t_1;
} else if ((1.0 - z) <= -5e+131) {
tmp = t_2;
} else if ((1.0 - z) <= -1e+43) {
tmp = t_1;
} else if ((1.0 - z) <= 0.999995) {
tmp = t_0;
} else if ((1.0 - z) <= 2.0) {
tmp = x + y;
} else if ((1.0 - z) <= 1e+125) {
tmp = t_0;
} else if (((1.0 - z) <= 1e+180) || !((1.0 - z) <= 2e+226)) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - z) t_1 = y * -z t_2 = x * -z tmp = 0 if (1.0 - z) <= -2e+206: tmp = t_1 elif (1.0 - z) <= -5e+131: tmp = t_2 elif (1.0 - z) <= -1e+43: tmp = t_1 elif (1.0 - z) <= 0.999995: tmp = t_0 elif (1.0 - z) <= 2.0: tmp = x + y elif (1.0 - z) <= 1e+125: tmp = t_0 elif ((1.0 - z) <= 1e+180) or not ((1.0 - z) <= 2e+226): tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - z)) t_1 = Float64(y * Float64(-z)) t_2 = Float64(x * Float64(-z)) tmp = 0.0 if (Float64(1.0 - z) <= -2e+206) tmp = t_1; elseif (Float64(1.0 - z) <= -5e+131) tmp = t_2; elseif (Float64(1.0 - z) <= -1e+43) tmp = t_1; elseif (Float64(1.0 - z) <= 0.999995) tmp = t_0; elseif (Float64(1.0 - z) <= 2.0) tmp = Float64(x + y); elseif (Float64(1.0 - z) <= 1e+125) tmp = t_0; elseif ((Float64(1.0 - z) <= 1e+180) || !(Float64(1.0 - z) <= 2e+226)) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - z); t_1 = y * -z; t_2 = x * -z; tmp = 0.0; if ((1.0 - z) <= -2e+206) tmp = t_1; elseif ((1.0 - z) <= -5e+131) tmp = t_2; elseif ((1.0 - z) <= -1e+43) tmp = t_1; elseif ((1.0 - z) <= 0.999995) tmp = t_0; elseif ((1.0 - z) <= 2.0) tmp = x + y; elseif ((1.0 - z) <= 1e+125) tmp = t_0; elseif (((1.0 - z) <= 1e+180) || ~(((1.0 - z) <= 2e+226))) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * (-z)), $MachinePrecision]}, Block[{t$95$2 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[N[(1.0 - z), $MachinePrecision], -2e+206], t$95$1, If[LessEqual[N[(1.0 - z), $MachinePrecision], -5e+131], t$95$2, If[LessEqual[N[(1.0 - z), $MachinePrecision], -1e+43], t$95$1, If[LessEqual[N[(1.0 - z), $MachinePrecision], 0.999995], t$95$0, If[LessEqual[N[(1.0 - z), $MachinePrecision], 2.0], N[(x + y), $MachinePrecision], If[LessEqual[N[(1.0 - z), $MachinePrecision], 1e+125], t$95$0, If[Or[LessEqual[N[(1.0 - z), $MachinePrecision], 1e+180], N[Not[LessEqual[N[(1.0 - z), $MachinePrecision], 2e+226]], $MachinePrecision]], t$95$1, t$95$2]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - z\right)\\
t_1 := y \cdot \left(-z\right)\\
t_2 := x \cdot \left(-z\right)\\
\mathbf{if}\;1 - z \leq -2 \cdot 10^{+206}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;1 - z \leq -5 \cdot 10^{+131}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;1 - z \leq -1 \cdot 10^{+43}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;1 - z \leq 0.999995:\\
\;\;\;\;t_0\\
\mathbf{elif}\;1 - z \leq 2:\\
\;\;\;\;x + y\\
\mathbf{elif}\;1 - z \leq 10^{+125}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;1 - z \leq 10^{+180} \lor \neg \left(1 - z \leq 2 \cdot 10^{+226}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (-.f64 1 z) < -2.0000000000000001e206 or -4.99999999999999995e131 < (-.f64 1 z) < -1.00000000000000001e43 or 9.9999999999999992e124 < (-.f64 1 z) < 1e180 or 1.99999999999999992e226 < (-.f64 1 z) Initial program 100.0%
*-commutative100.0%
distribute-lft-in93.0%
fma-def96.5%
Applied egg-rr96.5%
Taylor expanded in z around inf 100.0%
neg-mul-1100.0%
+-commutative100.0%
unsub-neg100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 52.8%
associate-*r*52.8%
mul-1-neg52.8%
Simplified52.8%
if -2.0000000000000001e206 < (-.f64 1 z) < -4.99999999999999995e131 or 1e180 < (-.f64 1 z) < 1.99999999999999992e226Initial program 99.9%
Taylor expanded in x around inf 56.1%
Taylor expanded in z around inf 56.1%
associate-*r*56.1%
neg-mul-156.1%
*-commutative56.1%
Simplified56.1%
if -1.00000000000000001e43 < (-.f64 1 z) < 0.99999499999999997 or 2 < (-.f64 1 z) < 9.9999999999999992e124Initial program 100.0%
Taylor expanded in x around inf 52.1%
if 0.99999499999999997 < (-.f64 1 z) < 2Initial program 100.0%
Taylor expanded in z around 0 98.7%
Final simplification77.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- z))) (t_1 (* x (- z))))
(if (<= z -1.4e+230)
t_0
(if (<= z -7e+180)
t_1
(if (<= z -7.5e+124)
t_0
(if (<= z -28.0)
t_1
(if (<= z 1.0)
(+ x y)
(if (or (<= z 1e+43)
(and (not (<= z 1.4e+130))
(or (<= z 4.2e+204)
(and (not (<= z 2.8e+257)) (<= z 6e+294)))))
t_1
t_0))))))))
double code(double x, double y, double z) {
double t_0 = y * -z;
double t_1 = x * -z;
double tmp;
if (z <= -1.4e+230) {
tmp = t_0;
} else if (z <= -7e+180) {
tmp = t_1;
} else if (z <= -7.5e+124) {
tmp = t_0;
} else if (z <= -28.0) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x + y;
} else if ((z <= 1e+43) || (!(z <= 1.4e+130) && ((z <= 4.2e+204) || (!(z <= 2.8e+257) && (z <= 6e+294))))) {
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 * -z
t_1 = x * -z
if (z <= (-1.4d+230)) then
tmp = t_0
else if (z <= (-7d+180)) then
tmp = t_1
else if (z <= (-7.5d+124)) then
tmp = t_0
else if (z <= (-28.0d0)) then
tmp = t_1
else if (z <= 1.0d0) then
tmp = x + y
else if ((z <= 1d+43) .or. (.not. (z <= 1.4d+130)) .and. (z <= 4.2d+204) .or. (.not. (z <= 2.8d+257)) .and. (z <= 6d+294)) 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 * -z;
double t_1 = x * -z;
double tmp;
if (z <= -1.4e+230) {
tmp = t_0;
} else if (z <= -7e+180) {
tmp = t_1;
} else if (z <= -7.5e+124) {
tmp = t_0;
} else if (z <= -28.0) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x + y;
} else if ((z <= 1e+43) || (!(z <= 1.4e+130) && ((z <= 4.2e+204) || (!(z <= 2.8e+257) && (z <= 6e+294))))) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * -z t_1 = x * -z tmp = 0 if z <= -1.4e+230: tmp = t_0 elif z <= -7e+180: tmp = t_1 elif z <= -7.5e+124: tmp = t_0 elif z <= -28.0: tmp = t_1 elif z <= 1.0: tmp = x + y elif (z <= 1e+43) or (not (z <= 1.4e+130) and ((z <= 4.2e+204) or (not (z <= 2.8e+257) and (z <= 6e+294)))): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(-z)) t_1 = Float64(x * Float64(-z)) tmp = 0.0 if (z <= -1.4e+230) tmp = t_0; elseif (z <= -7e+180) tmp = t_1; elseif (z <= -7.5e+124) tmp = t_0; elseif (z <= -28.0) tmp = t_1; elseif (z <= 1.0) tmp = Float64(x + y); elseif ((z <= 1e+43) || (!(z <= 1.4e+130) && ((z <= 4.2e+204) || (!(z <= 2.8e+257) && (z <= 6e+294))))) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * -z; t_1 = x * -z; tmp = 0.0; if (z <= -1.4e+230) tmp = t_0; elseif (z <= -7e+180) tmp = t_1; elseif (z <= -7.5e+124) tmp = t_0; elseif (z <= -28.0) tmp = t_1; elseif (z <= 1.0) tmp = x + y; elseif ((z <= 1e+43) || (~((z <= 1.4e+130)) && ((z <= 4.2e+204) || (~((z <= 2.8e+257)) && (z <= 6e+294))))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[z, -1.4e+230], t$95$0, If[LessEqual[z, -7e+180], t$95$1, If[LessEqual[z, -7.5e+124], t$95$0, If[LessEqual[z, -28.0], t$95$1, If[LessEqual[z, 1.0], N[(x + y), $MachinePrecision], If[Or[LessEqual[z, 1e+43], And[N[Not[LessEqual[z, 1.4e+130]], $MachinePrecision], Or[LessEqual[z, 4.2e+204], And[N[Not[LessEqual[z, 2.8e+257]], $MachinePrecision], LessEqual[z, 6e+294]]]]], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(-z\right)\\
t_1 := x \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -1.4 \cdot 10^{+230}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -7 \cdot 10^{+180}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -7.5 \cdot 10^{+124}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -28:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 10^{+43} \lor \neg \left(z \leq 1.4 \cdot 10^{+130}\right) \land \left(z \leq 4.2 \cdot 10^{+204} \lor \neg \left(z \leq 2.8 \cdot 10^{+257}\right) \land z \leq 6 \cdot 10^{+294}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1.4000000000000001e230 or -6.9999999999999996e180 < z < -7.50000000000000038e124 or 1.00000000000000001e43 < z < 1.3999999999999999e130 or 4.2000000000000001e204 < z < 2.7999999999999998e257 or 6.00000000000000011e294 < z Initial program 100.0%
*-commutative100.0%
distribute-lft-in96.2%
fma-def96.2%
Applied egg-rr96.2%
Taylor expanded in z around inf 100.0%
neg-mul-1100.0%
+-commutative100.0%
unsub-neg100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 50.1%
associate-*r*50.1%
mul-1-neg50.1%
Simplified50.1%
if -1.4000000000000001e230 < z < -6.9999999999999996e180 or -7.50000000000000038e124 < z < -28 or 1 < z < 1.00000000000000001e43 or 1.3999999999999999e130 < z < 4.2000000000000001e204 or 2.7999999999999998e257 < z < 6.00000000000000011e294Initial program 100.0%
Taylor expanded in x around inf 50.5%
Taylor expanded in z around inf 48.9%
associate-*r*48.9%
neg-mul-148.9%
*-commutative48.9%
Simplified48.9%
if -28 < z < 1Initial program 100.0%
Taylor expanded in z around 0 98.3%
Final simplification76.0%
(FPCore (x y z) :precision binary64 (if (or (<= (- 1.0 z) -1000.0) (not (<= (- 1.0 z) 2.0))) (* z (- (- y) x)) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - z) <= -1000.0) || !((1.0 - z) <= 2.0)) {
tmp = z * (-y - x);
} 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) <= (-1000.0d0)) .or. (.not. ((1.0d0 - z) <= 2.0d0))) then
tmp = z * (-y - x)
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) <= -1000.0) || !((1.0 - z) <= 2.0)) {
tmp = z * (-y - x);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - z) <= -1000.0) or not ((1.0 - z) <= 2.0): tmp = z * (-y - x) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(1.0 - z) <= -1000.0) || !(Float64(1.0 - z) <= 2.0)) tmp = Float64(z * Float64(Float64(-y) - x)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - z) <= -1000.0) || ~(((1.0 - z) <= 2.0))) tmp = z * (-y - x); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(1.0 - z), $MachinePrecision], -1000.0], N[Not[LessEqual[N[(1.0 - z), $MachinePrecision], 2.0]], $MachinePrecision]], N[(z * N[((-y) - x), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - z \leq -1000 \lor \neg \left(1 - z \leq 2\right):\\
\;\;\;\;z \cdot \left(\left(-y\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if (-.f64 1 z) < -1e3 or 2 < (-.f64 1 z) Initial program 100.0%
Taylor expanded in z around inf 97.7%
mul-1-neg97.7%
+-commutative97.7%
distribute-rgt-neg-out97.7%
+-commutative97.7%
Simplified97.7%
if -1e3 < (-.f64 1 z) < 2Initial program 100.0%
Taylor expanded in z around 0 98.3%
Final simplification98.0%
(FPCore (x y z)
:precision binary64
(if (<= x -2.8e-30)
(- x (* x z))
(if (or (<= x -1.62e-111) (not (<= x -2.2e-129)))
(- y (* y z))
(* x (- 1.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.8e-30) {
tmp = x - (x * z);
} else if ((x <= -1.62e-111) || !(x <= -2.2e-129)) {
tmp = y - (y * z);
} else {
tmp = x * (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 (x <= (-2.8d-30)) then
tmp = x - (x * z)
else if ((x <= (-1.62d-111)) .or. (.not. (x <= (-2.2d-129)))) then
tmp = y - (y * z)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.8e-30) {
tmp = x - (x * z);
} else if ((x <= -1.62e-111) || !(x <= -2.2e-129)) {
tmp = y - (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.8e-30: tmp = x - (x * z) elif (x <= -1.62e-111) or not (x <= -2.2e-129): tmp = y - (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.8e-30) tmp = Float64(x - Float64(x * z)); elseif ((x <= -1.62e-111) || !(x <= -2.2e-129)) tmp = Float64(y - Float64(y * z)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.8e-30) tmp = x - (x * z); elseif ((x <= -1.62e-111) || ~((x <= -2.2e-129))) tmp = y - (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.8e-30], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -1.62e-111], N[Not[LessEqual[x, -2.2e-129]], $MachinePrecision]], N[(y - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-30}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{elif}\;x \leq -1.62 \cdot 10^{-111} \lor \neg \left(x \leq -2.2 \cdot 10^{-129}\right):\\
\;\;\;\;y - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if x < -2.79999999999999988e-30Initial program 100.0%
Taylor expanded in x around inf 74.5%
sub-neg74.5%
+-commutative74.5%
distribute-rgt1-in74.5%
distribute-lft-neg-out74.5%
unsub-neg74.5%
Simplified74.5%
if -2.79999999999999988e-30 < x < -1.62000000000000004e-111 or -2.20000000000000003e-129 < x Initial program 100.0%
Taylor expanded in x around 0 57.2%
sub-neg57.2%
distribute-lft-in57.2%
distribute-rgt-neg-out57.2%
unsub-neg57.2%
*-rgt-identity57.2%
Simplified57.2%
if -1.62000000000000004e-111 < x < -2.20000000000000003e-129Initial program 100.0%
Taylor expanded in x around inf 80.8%
Final simplification62.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -28.0) (not (<= z 1.0))) (* x (- z)) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -28.0) || !(z <= 1.0)) {
tmp = x * -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 <= (-28.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x * -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 <= -28.0) || !(z <= 1.0)) {
tmp = x * -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -28.0) or not (z <= 1.0): tmp = x * -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -28.0) || !(z <= 1.0)) tmp = Float64(x * Float64(-z)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -28.0) || ~((z <= 1.0))) tmp = x * -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -28.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -28 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -28 or 1 < z Initial program 100.0%
Taylor expanded in x around inf 51.8%
Taylor expanded in z around inf 50.9%
associate-*r*50.9%
neg-mul-150.9%
*-commutative50.9%
Simplified50.9%
if -28 < z < 1Initial program 100.0%
Taylor expanded in z around 0 98.3%
Final simplification76.6%
(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 55.2%
Final simplification55.2%
(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 53.5%
Taylor expanded in z around 0 31.0%
Final simplification31.0%
herbie shell --seed 2023240
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, H"
:precision binary64
(* (+ x y) (- 1.0 z)))