
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + 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 + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + 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 + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
(FPCore (x y z) :precision binary64 (+ (* 2.0 (+ x y)) (+ x z)))
double code(double x, double y, double z) {
return (2.0 * (x + y)) + (x + z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (2.0d0 * (x + y)) + (x + z)
end function
public static double code(double x, double y, double z) {
return (2.0 * (x + y)) + (x + z);
}
def code(x, y, z): return (2.0 * (x + y)) + (x + z)
function code(x, y, z) return Float64(Float64(2.0 * Float64(x + y)) + Float64(x + z)) end
function tmp = code(x, y, z) tmp = (2.0 * (x + y)) + (x + z); end
code[x_, y_, z_] := N[(N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision] + N[(x + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(x + y\right) + \left(x + z\right)
\end{array}
Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
(FPCore (x y z)
:precision binary64
(if (<= y -4e+145)
(* 2.0 y)
(if (<= y -3e-50)
(* x 3.0)
(if (<= y 8.2e-15) z (if (<= y 2.1e+36) (* x 3.0) (* 2.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e+145) {
tmp = 2.0 * y;
} else if (y <= -3e-50) {
tmp = x * 3.0;
} else if (y <= 8.2e-15) {
tmp = z;
} else if (y <= 2.1e+36) {
tmp = x * 3.0;
} else {
tmp = 2.0 * 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 <= (-4d+145)) then
tmp = 2.0d0 * y
else if (y <= (-3d-50)) then
tmp = x * 3.0d0
else if (y <= 8.2d-15) then
tmp = z
else if (y <= 2.1d+36) then
tmp = x * 3.0d0
else
tmp = 2.0d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4e+145) {
tmp = 2.0 * y;
} else if (y <= -3e-50) {
tmp = x * 3.0;
} else if (y <= 8.2e-15) {
tmp = z;
} else if (y <= 2.1e+36) {
tmp = x * 3.0;
} else {
tmp = 2.0 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4e+145: tmp = 2.0 * y elif y <= -3e-50: tmp = x * 3.0 elif y <= 8.2e-15: tmp = z elif y <= 2.1e+36: tmp = x * 3.0 else: tmp = 2.0 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4e+145) tmp = Float64(2.0 * y); elseif (y <= -3e-50) tmp = Float64(x * 3.0); elseif (y <= 8.2e-15) tmp = z; elseif (y <= 2.1e+36) tmp = Float64(x * 3.0); else tmp = Float64(2.0 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4e+145) tmp = 2.0 * y; elseif (y <= -3e-50) tmp = x * 3.0; elseif (y <= 8.2e-15) tmp = z; elseif (y <= 2.1e+36) tmp = x * 3.0; else tmp = 2.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4e+145], N[(2.0 * y), $MachinePrecision], If[LessEqual[y, -3e-50], N[(x * 3.0), $MachinePrecision], If[LessEqual[y, 8.2e-15], z, If[LessEqual[y, 2.1e+36], N[(x * 3.0), $MachinePrecision], N[(2.0 * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+145}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;y \leq -3 \cdot 10^{-50}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{-15}:\\
\;\;\;\;z\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+36}:\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;2 \cdot y\\
\end{array}
\end{array}
if y < -4e145 or 2.10000000000000004e36 < y Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
remove-double-neg100.0%
unsub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
distribute-neg-in100.0%
distribute-neg-out100.0%
neg-mul-1100.0%
count-2100.0%
distribute-lft-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
distribute-rgt-out100.0%
distribute-neg-out100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 86.8%
*-commutative86.8%
Simplified86.8%
Taylor expanded in z around 0 73.8%
*-commutative73.8%
Simplified73.8%
if -4e145 < y < -2.9999999999999999e-50 or 8.20000000000000072e-15 < y < 2.10000000000000004e36Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 58.0%
*-commutative58.0%
Simplified58.0%
if -2.9999999999999999e-50 < y < 8.20000000000000072e-15Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
remove-double-neg99.9%
unsub-neg99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
distribute-neg-in99.9%
distribute-neg-out99.9%
neg-mul-199.9%
count-299.9%
distribute-lft-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-rgt-out99.9%
distribute-neg-out99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in x around 0 58.3%
*-commutative58.3%
Simplified58.3%
Taylor expanded in z around inf 55.8%
Final simplification63.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (* 2.0 y))))
(if (<= y -2.8e-26)
t_0
(if (<= y 2e-15) z (if (<= y 3.7e+33) (* x 3.0) t_0)))))
double code(double x, double y, double z) {
double t_0 = x + (2.0 * y);
double tmp;
if (y <= -2.8e-26) {
tmp = t_0;
} else if (y <= 2e-15) {
tmp = z;
} else if (y <= 3.7e+33) {
tmp = x * 3.0;
} 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 = x + (2.0d0 * y)
if (y <= (-2.8d-26)) then
tmp = t_0
else if (y <= 2d-15) then
tmp = z
else if (y <= 3.7d+33) then
tmp = x * 3.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x + (2.0 * y);
double tmp;
if (y <= -2.8e-26) {
tmp = t_0;
} else if (y <= 2e-15) {
tmp = z;
} else if (y <= 3.7e+33) {
tmp = x * 3.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x + (2.0 * y) tmp = 0 if y <= -2.8e-26: tmp = t_0 elif y <= 2e-15: tmp = z elif y <= 3.7e+33: tmp = x * 3.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x + Float64(2.0 * y)) tmp = 0.0 if (y <= -2.8e-26) tmp = t_0; elseif (y <= 2e-15) tmp = z; elseif (y <= 3.7e+33) tmp = Float64(x * 3.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (2.0 * y); tmp = 0.0; if (y <= -2.8e-26) tmp = t_0; elseif (y <= 2e-15) tmp = z; elseif (y <= 3.7e+33) tmp = x * 3.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.8e-26], t$95$0, If[LessEqual[y, 2e-15], z, If[LessEqual[y, 3.7e+33], N[(x * 3.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + 2 \cdot y\\
\mathbf{if}\;y \leq -2.8 \cdot 10^{-26}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-15}:\\
\;\;\;\;z\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+33}:\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.8000000000000001e-26 or 3.6999999999999999e33 < y Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in z around 0 85.7%
Taylor expanded in x around 0 69.5%
if -2.8000000000000001e-26 < y < 2.0000000000000002e-15Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
remove-double-neg99.9%
unsub-neg99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
distribute-neg-in99.9%
distribute-neg-out99.9%
neg-mul-199.9%
count-299.9%
distribute-lft-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-rgt-out99.9%
distribute-neg-out99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in x around 0 57.7%
*-commutative57.7%
Simplified57.7%
Taylor expanded in z around inf 55.3%
if 2.0000000000000002e-15 < y < 3.6999999999999999e33Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 67.9%
*-commutative67.9%
Simplified67.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.0012) (not (<= y 0.00013))) (+ x (* 2.0 (+ x y))) (+ (+ x z) (* 2.0 x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0012) || !(y <= 0.00013)) {
tmp = x + (2.0 * (x + y));
} else {
tmp = (x + z) + (2.0 * x);
}
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 <= (-0.0012d0)) .or. (.not. (y <= 0.00013d0))) then
tmp = x + (2.0d0 * (x + y))
else
tmp = (x + z) + (2.0d0 * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0012) || !(y <= 0.00013)) {
tmp = x + (2.0 * (x + y));
} else {
tmp = (x + z) + (2.0 * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.0012) or not (y <= 0.00013): tmp = x + (2.0 * (x + y)) else: tmp = (x + z) + (2.0 * x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.0012) || !(y <= 0.00013)) tmp = Float64(x + Float64(2.0 * Float64(x + y))); else tmp = Float64(Float64(x + z) + Float64(2.0 * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.0012) || ~((y <= 0.00013))) tmp = x + (2.0 * (x + y)); else tmp = (x + z) + (2.0 * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.0012], N[Not[LessEqual[y, 0.00013]], $MachinePrecision]], N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + z), $MachinePrecision] + N[(2.0 * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0012 \lor \neg \left(y \leq 0.00013\right):\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + z\right) + 2 \cdot x\\
\end{array}
\end{array}
if y < -0.00119999999999999989 or 1.29999999999999989e-4 < y Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in z around 0 86.2%
if -0.00119999999999999989 < y < 1.29999999999999989e-4Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 97.7%
Final simplification91.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.8e-6) (not (<= y 3.8e-5))) (+ x (* 2.0 (+ x y))) (- z (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.8e-6) || !(y <= 3.8e-5)) {
tmp = x + (2.0 * (x + y));
} else {
tmp = z - (x * -3.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) :: tmp
if ((y <= (-3.8d-6)) .or. (.not. (y <= 3.8d-5))) then
tmp = x + (2.0d0 * (x + y))
else
tmp = z - (x * (-3.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.8e-6) || !(y <= 3.8e-5)) {
tmp = x + (2.0 * (x + y));
} else {
tmp = z - (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.8e-6) or not (y <= 3.8e-5): tmp = x + (2.0 * (x + y)) else: tmp = z - (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.8e-6) || !(y <= 3.8e-5)) tmp = Float64(x + Float64(2.0 * Float64(x + y))); else tmp = Float64(z - Float64(x * -3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.8e-6) || ~((y <= 3.8e-5))) tmp = x + (2.0 * (x + y)); else tmp = z - (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.8e-6], N[Not[LessEqual[y, 3.8e-5]], $MachinePrecision]], N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z - N[(x * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{-6} \lor \neg \left(y \leq 3.8 \cdot 10^{-5}\right):\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;z - x \cdot -3\\
\end{array}
\end{array}
if y < -3.8e-6 or 3.8000000000000002e-5 < y Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in z around 0 86.2%
if -3.8e-6 < y < 3.8000000000000002e-5Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
remove-double-neg99.9%
unsub-neg99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
distribute-neg-in99.9%
distribute-neg-out99.9%
neg-mul-199.9%
count-299.9%
distribute-lft-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-rgt-out99.9%
distribute-neg-out99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in x around inf 97.7%
*-commutative97.7%
Simplified97.7%
Final simplification91.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -4e+145) (not (<= y 3.7e+42))) (- z (* y -2.0)) (- z (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4e+145) || !(y <= 3.7e+42)) {
tmp = z - (y * -2.0);
} else {
tmp = z - (x * -3.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) :: tmp
if ((y <= (-4d+145)) .or. (.not. (y <= 3.7d+42))) then
tmp = z - (y * (-2.0d0))
else
tmp = z - (x * (-3.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4e+145) || !(y <= 3.7e+42)) {
tmp = z - (y * -2.0);
} else {
tmp = z - (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4e+145) or not (y <= 3.7e+42): tmp = z - (y * -2.0) else: tmp = z - (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4e+145) || !(y <= 3.7e+42)) tmp = Float64(z - Float64(y * -2.0)); else tmp = Float64(z - Float64(x * -3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4e+145) || ~((y <= 3.7e+42))) tmp = z - (y * -2.0); else tmp = z - (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4e+145], N[Not[LessEqual[y, 3.7e+42]], $MachinePrecision]], N[(z - N[(y * -2.0), $MachinePrecision]), $MachinePrecision], N[(z - N[(x * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+145} \lor \neg \left(y \leq 3.7 \cdot 10^{+42}\right):\\
\;\;\;\;z - y \cdot -2\\
\mathbf{else}:\\
\;\;\;\;z - x \cdot -3\\
\end{array}
\end{array}
if y < -4e145 or 3.69999999999999996e42 < y Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
remove-double-neg100.0%
unsub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
distribute-neg-in100.0%
distribute-neg-out100.0%
neg-mul-1100.0%
count-2100.0%
distribute-lft-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
distribute-rgt-out100.0%
distribute-neg-out100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 86.8%
*-commutative86.8%
Simplified86.8%
if -4e145 < y < 3.69999999999999996e42Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
remove-double-neg99.9%
unsub-neg99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
distribute-neg-in99.9%
distribute-neg-out99.9%
neg-mul-199.9%
count-299.9%
distribute-lft-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-rgt-out99.9%
distribute-neg-out99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in x around inf 92.0%
*-commutative92.0%
Simplified92.0%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.9e+148) (not (<= y 1.2e+45))) (+ x (* 2.0 y)) (- z (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.9e+148) || !(y <= 1.2e+45)) {
tmp = x + (2.0 * y);
} else {
tmp = z - (x * -3.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) :: tmp
if ((y <= (-1.9d+148)) .or. (.not. (y <= 1.2d+45))) then
tmp = x + (2.0d0 * y)
else
tmp = z - (x * (-3.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.9e+148) || !(y <= 1.2e+45)) {
tmp = x + (2.0 * y);
} else {
tmp = z - (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.9e+148) or not (y <= 1.2e+45): tmp = x + (2.0 * y) else: tmp = z - (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.9e+148) || !(y <= 1.2e+45)) tmp = Float64(x + Float64(2.0 * y)); else tmp = Float64(z - Float64(x * -3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.9e+148) || ~((y <= 1.2e+45))) tmp = x + (2.0 * y); else tmp = z - (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.9e+148], N[Not[LessEqual[y, 1.2e+45]], $MachinePrecision]], N[(x + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], N[(z - N[(x * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+148} \lor \neg \left(y \leq 1.2 \cdot 10^{+45}\right):\\
\;\;\;\;x + 2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;z - x \cdot -3\\
\end{array}
\end{array}
if y < -1.8999999999999999e148 or 1.19999999999999995e45 < y Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in z around 0 87.2%
Taylor expanded in x around 0 76.3%
if -1.8999999999999999e148 < y < 1.19999999999999995e45Initial program 100.0%
+-commutative100.0%
associate-+l+99.9%
remove-double-neg99.9%
unsub-neg99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
distribute-neg-in99.9%
distribute-neg-out99.9%
neg-mul-199.9%
count-299.9%
distribute-lft-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-rgt-out99.9%
distribute-neg-out99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in x around inf 91.4%
*-commutative91.4%
Simplified91.4%
Final simplification85.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -1760000.0) (not (<= x 1.86e+112))) (* x 3.0) z))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1760000.0) || !(x <= 1.86e+112)) {
tmp = x * 3.0;
} else {
tmp = 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 <= (-1760000.0d0)) .or. (.not. (x <= 1.86d+112))) then
tmp = x * 3.0d0
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1760000.0) || !(x <= 1.86e+112)) {
tmp = x * 3.0;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1760000.0) or not (x <= 1.86e+112): tmp = x * 3.0 else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1760000.0) || !(x <= 1.86e+112)) tmp = Float64(x * 3.0); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1760000.0) || ~((x <= 1.86e+112))) tmp = x * 3.0; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1760000.0], N[Not[LessEqual[x, 1.86e+112]], $MachinePrecision]], N[(x * 3.0), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1760000 \lor \neg \left(x \leq 1.86 \cdot 10^{+112}\right):\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -1.76e6 or 1.86000000000000002e112 < x Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 67.0%
*-commutative67.0%
Simplified67.0%
if -1.76e6 < x < 1.86000000000000002e112Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
remove-double-neg100.0%
unsub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
distribute-neg-in100.0%
distribute-neg-out100.0%
neg-mul-1100.0%
count-2100.0%
distribute-lft-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
distribute-rgt-out100.0%
distribute-neg-out100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 89.2%
*-commutative89.2%
Simplified89.2%
Taylor expanded in z around inf 45.0%
Final simplification53.8%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
remove-double-neg100.0%
unsub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
distribute-neg-in100.0%
distribute-neg-out100.0%
neg-mul-1100.0%
count-2100.0%
distribute-lft-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
distribute-rgt-out100.0%
distribute-neg-out100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 67.1%
*-commutative67.1%
Simplified67.1%
Taylor expanded in z around inf 33.0%
(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%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in z around 0 67.5%
Taylor expanded in x around 0 40.5%
Taylor expanded in x around inf 7.8%
herbie shell --seed 2024136
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
:precision binary64
(+ (+ (+ (+ (+ x y) y) x) z) x))