
(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 10 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 (* x (- z))) (t_1 (* y (- z))))
(if (<= z -1e+222)
t_0
(if (<= z -3.15e+155)
t_1
(if (<= z -3.6e+62)
t_0
(if (<= z -200.0)
t_1
(if (<= z 1.0)
(+ x y)
(if (or (<= z 4.8e+179) (not (<= z 2.6e+229))) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = y * -z;
double tmp;
if (z <= -1e+222) {
tmp = t_0;
} else if (z <= -3.15e+155) {
tmp = t_1;
} else if (z <= -3.6e+62) {
tmp = t_0;
} else if (z <= -200.0) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x + y;
} else if ((z <= 4.8e+179) || !(z <= 2.6e+229)) {
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 = x * -z
t_1 = y * -z
if (z <= (-1d+222)) then
tmp = t_0
else if (z <= (-3.15d+155)) then
tmp = t_1
else if (z <= (-3.6d+62)) then
tmp = t_0
else if (z <= (-200.0d0)) then
tmp = t_1
else if (z <= 1.0d0) then
tmp = x + y
else if ((z <= 4.8d+179) .or. (.not. (z <= 2.6d+229))) 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 = x * -z;
double t_1 = y * -z;
double tmp;
if (z <= -1e+222) {
tmp = t_0;
} else if (z <= -3.15e+155) {
tmp = t_1;
} else if (z <= -3.6e+62) {
tmp = t_0;
} else if (z <= -200.0) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x + y;
} else if ((z <= 4.8e+179) || !(z <= 2.6e+229)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = y * -z tmp = 0 if z <= -1e+222: tmp = t_0 elif z <= -3.15e+155: tmp = t_1 elif z <= -3.6e+62: tmp = t_0 elif z <= -200.0: tmp = t_1 elif z <= 1.0: tmp = x + y elif (z <= 4.8e+179) or not (z <= 2.6e+229): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) t_1 = Float64(y * Float64(-z)) tmp = 0.0 if (z <= -1e+222) tmp = t_0; elseif (z <= -3.15e+155) tmp = t_1; elseif (z <= -3.6e+62) tmp = t_0; elseif (z <= -200.0) tmp = t_1; elseif (z <= 1.0) tmp = Float64(x + y); elseif ((z <= 4.8e+179) || !(z <= 2.6e+229)) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; t_1 = y * -z; tmp = 0.0; if (z <= -1e+222) tmp = t_0; elseif (z <= -3.15e+155) tmp = t_1; elseif (z <= -3.6e+62) tmp = t_0; elseif (z <= -200.0) tmp = t_1; elseif (z <= 1.0) tmp = x + y; elseif ((z <= 4.8e+179) || ~((z <= 2.6e+229))) tmp = t_1; else tmp = t_0; 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, -1e+222], t$95$0, If[LessEqual[z, -3.15e+155], t$95$1, If[LessEqual[z, -3.6e+62], t$95$0, If[LessEqual[z, -200.0], t$95$1, If[LessEqual[z, 1.0], N[(x + y), $MachinePrecision], If[Or[LessEqual[z, 4.8e+179], N[Not[LessEqual[z, 2.6e+229]], $MachinePrecision]], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := y \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -1 \cdot 10^{+222}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3.15 \cdot 10^{+155}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -200:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{+179} \lor \neg \left(z \leq 2.6 \cdot 10^{+229}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1e222 or -3.15e155 < z < -3.6e62 or 4.80000000000000025e179 < z < 2.6e229Initial program 100.0%
sub-neg100.0%
distribute-lft-in100.0%
*-commutative100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 67.3%
Taylor expanded in z around inf 67.3%
associate-*r*67.3%
neg-mul-167.3%
Simplified67.3%
if -1e222 < z < -3.15e155 or -3.6e62 < z < -200 or 1 < z < 4.80000000000000025e179 or 2.6e229 < z Initial program 100.0%
Taylor expanded in x around inf 80.3%
sub-neg80.3%
+-commutative80.3%
associate-+l+80.3%
sub-neg80.3%
+-commutative80.3%
remove-double-neg80.3%
mul-1-neg80.3%
distribute-lft-out80.3%
mul-1-neg80.3%
unsub-neg80.3%
*-commutative80.3%
*-commutative80.3%
associate-/l*81.6%
distribute-lft-out--81.6%
Simplified81.6%
Taylor expanded in z around inf 78.8%
mul-1-neg78.8%
associate-*r*88.5%
distribute-rgt-neg-in88.5%
*-commutative88.5%
distribute-neg-in88.5%
metadata-eval88.5%
sub-neg88.5%
Simplified88.5%
Taylor expanded in x around 0 59.2%
mul-1-neg59.2%
*-commutative59.2%
distribute-rgt-neg-in59.2%
Simplified59.2%
if -200 < z < 1Initial program 100.0%
Taylor expanded in z around 0 99.0%
+-commutative99.0%
Simplified99.0%
Final simplification80.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 z))))
(if (<= (- 1.0 z) -10.0)
t_0
(if (<= (- 1.0 z) 10.0)
(+ x y)
(if (<= (- 1.0 z) 3e+62)
t_0
(if (or (<= (- 1.0 z) 2e+155) (not (<= (- 1.0 z) 5e+220)))
(* x (- z))
(* y (- z))))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - z);
double tmp;
if ((1.0 - z) <= -10.0) {
tmp = t_0;
} else if ((1.0 - z) <= 10.0) {
tmp = x + y;
} else if ((1.0 - z) <= 3e+62) {
tmp = t_0;
} else if (((1.0 - z) <= 2e+155) || !((1.0 - z) <= 5e+220)) {
tmp = x * -z;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 - z)
if ((1.0d0 - z) <= (-10.0d0)) then
tmp = t_0
else if ((1.0d0 - z) <= 10.0d0) then
tmp = x + y
else if ((1.0d0 - z) <= 3d+62) then
tmp = t_0
else if (((1.0d0 - z) <= 2d+155) .or. (.not. ((1.0d0 - z) <= 5d+220))) then
tmp = x * -z
else
tmp = y * -z
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) <= -10.0) {
tmp = t_0;
} else if ((1.0 - z) <= 10.0) {
tmp = x + y;
} else if ((1.0 - z) <= 3e+62) {
tmp = t_0;
} else if (((1.0 - z) <= 2e+155) || !((1.0 - z) <= 5e+220)) {
tmp = x * -z;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - z) tmp = 0 if (1.0 - z) <= -10.0: tmp = t_0 elif (1.0 - z) <= 10.0: tmp = x + y elif (1.0 - z) <= 3e+62: tmp = t_0 elif ((1.0 - z) <= 2e+155) or not ((1.0 - z) <= 5e+220): tmp = x * -z else: tmp = y * -z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - z)) tmp = 0.0 if (Float64(1.0 - z) <= -10.0) tmp = t_0; elseif (Float64(1.0 - z) <= 10.0) tmp = Float64(x + y); elseif (Float64(1.0 - z) <= 3e+62) tmp = t_0; elseif ((Float64(1.0 - z) <= 2e+155) || !(Float64(1.0 - z) <= 5e+220)) tmp = Float64(x * Float64(-z)); else tmp = Float64(y * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - z); tmp = 0.0; if ((1.0 - z) <= -10.0) tmp = t_0; elseif ((1.0 - z) <= 10.0) tmp = x + y; elseif ((1.0 - z) <= 3e+62) tmp = t_0; elseif (((1.0 - z) <= 2e+155) || ~(((1.0 - z) <= 5e+220))) tmp = x * -z; else tmp = y * -z; 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], -10.0], t$95$0, If[LessEqual[N[(1.0 - z), $MachinePrecision], 10.0], N[(x + y), $MachinePrecision], If[LessEqual[N[(1.0 - z), $MachinePrecision], 3e+62], t$95$0, If[Or[LessEqual[N[(1.0 - z), $MachinePrecision], 2e+155], N[Not[LessEqual[N[(1.0 - z), $MachinePrecision], 5e+220]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - z\right)\\
\mathbf{if}\;1 - z \leq -10:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;1 - z \leq 10:\\
\;\;\;\;x + y\\
\mathbf{elif}\;1 - z \leq 3 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;1 - z \leq 2 \cdot 10^{+155} \lor \neg \left(1 - z \leq 5 \cdot 10^{+220}\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) z) < -10 or 10 < (-.f64 #s(literal 1 binary64) z) < 3e62Initial program 100.0%
Taylor expanded in x around 0 55.9%
if -10 < (-.f64 #s(literal 1 binary64) z) < 10Initial program 100.0%
Taylor expanded in z around 0 99.0%
+-commutative99.0%
Simplified99.0%
if 3e62 < (-.f64 #s(literal 1 binary64) z) < 2.00000000000000001e155 or 5.0000000000000002e220 < (-.f64 #s(literal 1 binary64) z) Initial program 100.0%
sub-neg100.0%
distribute-lft-in100.0%
*-commutative100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 65.3%
Taylor expanded in z around inf 65.3%
associate-*r*65.3%
neg-mul-165.3%
Simplified65.3%
if 2.00000000000000001e155 < (-.f64 #s(literal 1 binary64) z) < 5.0000000000000002e220Initial program 99.8%
Taylor expanded in x around inf 90.2%
sub-neg90.2%
+-commutative90.2%
associate-+l+90.2%
sub-neg90.2%
+-commutative90.2%
remove-double-neg90.2%
mul-1-neg90.2%
distribute-lft-out90.2%
mul-1-neg90.2%
unsub-neg90.2%
*-commutative90.2%
*-commutative90.2%
associate-/l*89.8%
distribute-lft-out--89.8%
Simplified89.8%
Taylor expanded in z around inf 89.8%
mul-1-neg89.8%
associate-*r*99.7%
distribute-rgt-neg-in99.7%
*-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
Simplified99.7%
Taylor expanded in x around 0 50.4%
mul-1-neg50.4%
*-commutative50.4%
distribute-rgt-neg-in50.4%
Simplified50.4%
Final simplification77.7%
(FPCore (x y z) :precision binary64 (if (or (<= (- 1.0 z) -10.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) <= -10.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) <= (-10.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) <= -10.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) <= -10.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) <= -10.0) || !(Float64(1.0 - z) <= 2.0)) tmp = Float64(z * Float64(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) <= -10.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], -10.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 -10 \lor \neg \left(1 - z \leq 2\right):\\
\;\;\;\;z \cdot \left(\left(-x\right) - y\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) z) < -10 or 2 < (-.f64 #s(literal 1 binary64) z) Initial program 100.0%
Taylor expanded in z around inf 97.3%
mul-1-neg97.3%
distribute-lft-neg-out97.3%
*-commutative97.3%
+-commutative97.3%
Simplified97.3%
if -10 < (-.f64 #s(literal 1 binary64) z) < 2Initial program 100.0%
Taylor expanded in z around 0 99.7%
+-commutative99.7%
Simplified99.7%
Final simplification98.4%
(FPCore (x y z)
:precision binary64
(if (<= x -1e-62)
(- x (* x z))
(if (<= x -1.65e-130)
(+ x y)
(if (<= x -2.9e-148) (* x (- 1.0 z)) (* y (- 1.0 z))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1e-62) {
tmp = x - (x * z);
} else if (x <= -1.65e-130) {
tmp = x + y;
} else if (x <= -2.9e-148) {
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 (x <= (-1d-62)) then
tmp = x - (x * z)
else if (x <= (-1.65d-130)) then
tmp = x + y
else if (x <= (-2.9d-148)) 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 (x <= -1e-62) {
tmp = x - (x * z);
} else if (x <= -1.65e-130) {
tmp = x + y;
} else if (x <= -2.9e-148) {
tmp = x * (1.0 - z);
} else {
tmp = y * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1e-62: tmp = x - (x * z) elif x <= -1.65e-130: tmp = x + y elif x <= -2.9e-148: tmp = x * (1.0 - z) else: tmp = y * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1e-62) tmp = Float64(x - Float64(x * z)); elseif (x <= -1.65e-130) tmp = Float64(x + y); elseif (x <= -2.9e-148) 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 (x <= -1e-62) tmp = x - (x * z); elseif (x <= -1.65e-130) tmp = x + y; elseif (x <= -2.9e-148) tmp = x * (1.0 - z); else tmp = y * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1e-62], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.65e-130], N[(x + y), $MachinePrecision], If[LessEqual[x, -2.9e-148], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-62}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{elif}\;x \leq -1.65 \cdot 10^{-130}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-148}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if x < -1e-62Initial program 100.0%
sub-neg100.0%
distribute-lft-in100.0%
*-commutative100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 72.8%
mul-1-neg72.8%
unsub-neg72.8%
Applied egg-rr72.8%
if -1e-62 < x < -1.6499999999999999e-130Initial program 100.0%
Taylor expanded in z around 0 58.2%
+-commutative58.2%
Simplified58.2%
if -1.6499999999999999e-130 < x < -2.8999999999999998e-148Initial program 100.0%
Taylor expanded in x around inf 44.9%
*-commutative44.9%
Simplified44.9%
if -2.8999999999999998e-148 < x Initial program 100.0%
Taylor expanded in x around 0 63.4%
Final simplification65.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 z))))
(if (<= x -5.9e-64)
t_0
(if (<= x -2e-130) (+ x y) (if (<= x -2.9e-148) t_0 (* y (- 1.0 z)))))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - z);
double tmp;
if (x <= -5.9e-64) {
tmp = t_0;
} else if (x <= -2e-130) {
tmp = x + y;
} else if (x <= -2.9e-148) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x * (1.0d0 - z)
if (x <= (-5.9d-64)) then
tmp = t_0
else if (x <= (-2d-130)) then
tmp = x + y
else if (x <= (-2.9d-148)) then
tmp = t_0
else
tmp = y * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - z);
double tmp;
if (x <= -5.9e-64) {
tmp = t_0;
} else if (x <= -2e-130) {
tmp = x + y;
} else if (x <= -2.9e-148) {
tmp = t_0;
} else {
tmp = y * (1.0 - z);
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - z) tmp = 0 if x <= -5.9e-64: tmp = t_0 elif x <= -2e-130: tmp = x + y elif x <= -2.9e-148: tmp = t_0 else: tmp = y * (1.0 - z) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - z)) tmp = 0.0 if (x <= -5.9e-64) tmp = t_0; elseif (x <= -2e-130) tmp = Float64(x + y); elseif (x <= -2.9e-148) tmp = t_0; else tmp = Float64(y * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - z); tmp = 0.0; if (x <= -5.9e-64) tmp = t_0; elseif (x <= -2e-130) tmp = x + y; elseif (x <= -2.9e-148) tmp = t_0; else tmp = y * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.9e-64], t$95$0, If[LessEqual[x, -2e-130], N[(x + y), $MachinePrecision], If[LessEqual[x, -2.9e-148], t$95$0, N[(y * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - z\right)\\
\mathbf{if}\;x \leq -5.9 \cdot 10^{-64}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-130}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-148}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if x < -5.89999999999999995e-64 or -2.0000000000000002e-130 < x < -2.8999999999999998e-148Initial program 100.0%
Taylor expanded in x around inf 71.4%
*-commutative71.4%
Simplified71.4%
if -5.89999999999999995e-64 < x < -2.0000000000000002e-130Initial program 100.0%
Taylor expanded in z around 0 58.2%
+-commutative58.2%
Simplified58.2%
if -2.8999999999999998e-148 < x Initial program 100.0%
Taylor expanded in x around 0 63.4%
Final simplification65.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -140.0) (not (<= z 1.0))) (* y (- z)) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -140.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 <= (-140.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 <= -140.0) || !(z <= 1.0)) {
tmp = y * -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -140.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 <= -140.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 <= -140.0) || ~((z <= 1.0))) tmp = y * -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -140.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 -140 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;y \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -140 or 1 < z Initial program 100.0%
Taylor expanded in x around inf 84.4%
sub-neg84.4%
+-commutative84.4%
associate-+l+84.4%
sub-neg84.4%
+-commutative84.4%
remove-double-neg84.4%
mul-1-neg84.4%
distribute-lft-out84.4%
mul-1-neg84.4%
unsub-neg84.4%
*-commutative84.4%
*-commutative84.4%
associate-/l*86.6%
distribute-lft-out--86.6%
Simplified86.6%
Taylor expanded in z around inf 85.0%
mul-1-neg85.0%
associate-*r*93.4%
distribute-rgt-neg-in93.4%
*-commutative93.4%
distribute-neg-in93.4%
metadata-eval93.4%
sub-neg93.4%
Simplified93.4%
Taylor expanded in x around 0 50.6%
mul-1-neg50.6%
*-commutative50.6%
distribute-rgt-neg-in50.6%
Simplified50.6%
if -140 < z < 1Initial program 100.0%
Taylor expanded in z around 0 99.0%
+-commutative99.0%
Simplified99.0%
Final simplification73.7%
(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 (+ 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.9%
+-commutative48.9%
Simplified48.9%
Final simplification48.9%
(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 48.7%
*-commutative48.7%
Simplified48.7%
Taylor expanded in z around 0 21.6%
herbie shell --seed 2024086
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, H"
:precision binary64
(* (+ x y) (- 1.0 z)))