
(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 (- z (fma x -3.0 (* y -2.0))))
double code(double x, double y, double z) {
return z - fma(x, -3.0, (y * -2.0));
}
function code(x, y, z) return Float64(z - fma(x, -3.0, Float64(y * -2.0))) end
code[x_, y_, z_] := N[(z - N[(x * -3.0 + N[(y * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z - \mathsf{fma}\left(x, -3, y \cdot -2\right)
\end{array}
Initial 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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (* y 2.0))))
(if (<= y -4.2e+123)
t_0
(if (<= y -6.6e-163)
(* x 3.0)
(if (<= y -2.6e-210)
z
(if (<= y 3.6e-223)
(* x 3.0)
(if (<= y 6.5e-24) z (if (<= y 1.35e+100) (* x 3.0) t_0))))))))
double code(double x, double y, double z) {
double t_0 = x + (y * 2.0);
double tmp;
if (y <= -4.2e+123) {
tmp = t_0;
} else if (y <= -6.6e-163) {
tmp = x * 3.0;
} else if (y <= -2.6e-210) {
tmp = z;
} else if (y <= 3.6e-223) {
tmp = x * 3.0;
} else if (y <= 6.5e-24) {
tmp = z;
} else if (y <= 1.35e+100) {
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 + (y * 2.0d0)
if (y <= (-4.2d+123)) then
tmp = t_0
else if (y <= (-6.6d-163)) then
tmp = x * 3.0d0
else if (y <= (-2.6d-210)) then
tmp = z
else if (y <= 3.6d-223) then
tmp = x * 3.0d0
else if (y <= 6.5d-24) then
tmp = z
else if (y <= 1.35d+100) 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 + (y * 2.0);
double tmp;
if (y <= -4.2e+123) {
tmp = t_0;
} else if (y <= -6.6e-163) {
tmp = x * 3.0;
} else if (y <= -2.6e-210) {
tmp = z;
} else if (y <= 3.6e-223) {
tmp = x * 3.0;
} else if (y <= 6.5e-24) {
tmp = z;
} else if (y <= 1.35e+100) {
tmp = x * 3.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x + (y * 2.0) tmp = 0 if y <= -4.2e+123: tmp = t_0 elif y <= -6.6e-163: tmp = x * 3.0 elif y <= -2.6e-210: tmp = z elif y <= 3.6e-223: tmp = x * 3.0 elif y <= 6.5e-24: tmp = z elif y <= 1.35e+100: tmp = x * 3.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x + Float64(y * 2.0)) tmp = 0.0 if (y <= -4.2e+123) tmp = t_0; elseif (y <= -6.6e-163) tmp = Float64(x * 3.0); elseif (y <= -2.6e-210) tmp = z; elseif (y <= 3.6e-223) tmp = Float64(x * 3.0); elseif (y <= 6.5e-24) tmp = z; elseif (y <= 1.35e+100) tmp = Float64(x * 3.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (y * 2.0); tmp = 0.0; if (y <= -4.2e+123) tmp = t_0; elseif (y <= -6.6e-163) tmp = x * 3.0; elseif (y <= -2.6e-210) tmp = z; elseif (y <= 3.6e-223) tmp = x * 3.0; elseif (y <= 6.5e-24) tmp = z; elseif (y <= 1.35e+100) tmp = x * 3.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.2e+123], t$95$0, If[LessEqual[y, -6.6e-163], N[(x * 3.0), $MachinePrecision], If[LessEqual[y, -2.6e-210], z, If[LessEqual[y, 3.6e-223], N[(x * 3.0), $MachinePrecision], If[LessEqual[y, 6.5e-24], z, If[LessEqual[y, 1.35e+100], N[(x * 3.0), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + y \cdot 2\\
\mathbf{if}\;y \leq -4.2 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -6.6 \cdot 10^{-163}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;y \leq -2.6 \cdot 10^{-210}:\\
\;\;\;\;z\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-223}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{-24}:\\
\;\;\;\;z\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+100}:\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.19999999999999988e123 or 1.34999999999999999e100 < 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 82.7%
Taylor expanded in x around 0 74.2%
if -4.19999999999999988e123 < y < -6.60000000000000002e-163 or -2.5999999999999998e-210 < y < 3.6000000000000004e-223 or 6.5e-24 < y < 1.34999999999999999e100Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 57.7%
if -6.60000000000000002e-163 < y < -2.5999999999999998e-210 or 3.6000000000000004e-223 < y < 6.5e-24Initial 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 z around inf 65.8%
Final simplification64.5%
(FPCore (x y z)
:precision binary64
(if (<= y -4.2e+123)
(* y 2.0)
(if (<= y -5e-162)
(* x 3.0)
(if (<= y -1.02e-210)
z
(if (<= y 2e-223)
(* x 3.0)
(if (<= y 6.6e-24) z (if (<= y 2.4e+112) (* x 3.0) (* y 2.0))))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e+123) {
tmp = y * 2.0;
} else if (y <= -5e-162) {
tmp = x * 3.0;
} else if (y <= -1.02e-210) {
tmp = z;
} else if (y <= 2e-223) {
tmp = x * 3.0;
} else if (y <= 6.6e-24) {
tmp = z;
} else if (y <= 2.4e+112) {
tmp = x * 3.0;
} else {
tmp = y * 2.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 <= (-4.2d+123)) then
tmp = y * 2.0d0
else if (y <= (-5d-162)) then
tmp = x * 3.0d0
else if (y <= (-1.02d-210)) then
tmp = z
else if (y <= 2d-223) then
tmp = x * 3.0d0
else if (y <= 6.6d-24) then
tmp = z
else if (y <= 2.4d+112) then
tmp = x * 3.0d0
else
tmp = y * 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e+123) {
tmp = y * 2.0;
} else if (y <= -5e-162) {
tmp = x * 3.0;
} else if (y <= -1.02e-210) {
tmp = z;
} else if (y <= 2e-223) {
tmp = x * 3.0;
} else if (y <= 6.6e-24) {
tmp = z;
} else if (y <= 2.4e+112) {
tmp = x * 3.0;
} else {
tmp = y * 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.2e+123: tmp = y * 2.0 elif y <= -5e-162: tmp = x * 3.0 elif y <= -1.02e-210: tmp = z elif y <= 2e-223: tmp = x * 3.0 elif y <= 6.6e-24: tmp = z elif y <= 2.4e+112: tmp = x * 3.0 else: tmp = y * 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.2e+123) tmp = Float64(y * 2.0); elseif (y <= -5e-162) tmp = Float64(x * 3.0); elseif (y <= -1.02e-210) tmp = z; elseif (y <= 2e-223) tmp = Float64(x * 3.0); elseif (y <= 6.6e-24) tmp = z; elseif (y <= 2.4e+112) tmp = Float64(x * 3.0); else tmp = Float64(y * 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.2e+123) tmp = y * 2.0; elseif (y <= -5e-162) tmp = x * 3.0; elseif (y <= -1.02e-210) tmp = z; elseif (y <= 2e-223) tmp = x * 3.0; elseif (y <= 6.6e-24) tmp = z; elseif (y <= 2.4e+112) tmp = x * 3.0; else tmp = y * 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.2e+123], N[(y * 2.0), $MachinePrecision], If[LessEqual[y, -5e-162], N[(x * 3.0), $MachinePrecision], If[LessEqual[y, -1.02e-210], z, If[LessEqual[y, 2e-223], N[(x * 3.0), $MachinePrecision], If[LessEqual[y, 6.6e-24], z, If[LessEqual[y, 2.4e+112], N[(x * 3.0), $MachinePrecision], N[(y * 2.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+123}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;y \leq -5 \cdot 10^{-162}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;y \leq -1.02 \cdot 10^{-210}:\\
\;\;\;\;z\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-223}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{-24}:\\
\;\;\;\;z\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+112}:\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;y \cdot 2\\
\end{array}
\end{array}
if y < -4.19999999999999988e123 or 2.4e112 < 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 y around inf 73.3%
if -4.19999999999999988e123 < y < -5.00000000000000014e-162 or -1.02000000000000002e-210 < y < 1.9999999999999999e-223 or 6.59999999999999968e-24 < y < 2.4e112Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 57.6%
if -5.00000000000000014e-162 < y < -1.02000000000000002e-210 or 1.9999999999999999e-223 < y < 6.59999999999999968e-24Initial 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 z around inf 65.8%
Final simplification64.0%
(FPCore (x y z) :precision binary64 (if (<= z -2e-23) (- z (* y -2.0)) (if (<= z 2.95e+16) (+ x (* 2.0 (+ x y))) (+ x (+ z (* x 2.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e-23) {
tmp = z - (y * -2.0);
} else if (z <= 2.95e+16) {
tmp = x + (2.0 * (x + y));
} else {
tmp = x + (z + (x * 2.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 (z <= (-2d-23)) then
tmp = z - (y * (-2.0d0))
else if (z <= 2.95d+16) then
tmp = x + (2.0d0 * (x + y))
else
tmp = x + (z + (x * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2e-23) {
tmp = z - (y * -2.0);
} else if (z <= 2.95e+16) {
tmp = x + (2.0 * (x + y));
} else {
tmp = x + (z + (x * 2.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2e-23: tmp = z - (y * -2.0) elif z <= 2.95e+16: tmp = x + (2.0 * (x + y)) else: tmp = x + (z + (x * 2.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2e-23) tmp = Float64(z - Float64(y * -2.0)); elseif (z <= 2.95e+16) tmp = Float64(x + Float64(2.0 * Float64(x + y))); else tmp = Float64(x + Float64(z + Float64(x * 2.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2e-23) tmp = z - (y * -2.0); elseif (z <= 2.95e+16) tmp = x + (2.0 * (x + y)); else tmp = x + (z + (x * 2.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2e-23], N[(z - N[(y * -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.95e+16], N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-23}:\\
\;\;\;\;z - y \cdot -2\\
\mathbf{elif}\;z \leq 2.95 \cdot 10^{+16}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(z + x \cdot 2\right)\\
\end{array}
\end{array}
if z < -1.99999999999999992e-23Initial 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 80.9%
if -1.99999999999999992e-23 < z < 2.95e16Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in z around 0 93.6%
if 2.95e16 < z Initial program 100.0%
Taylor expanded in y around 0 84.3%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (if (<= z -4.6e-21) (- z (* y -2.0)) (if (<= z 1.42e+17) (+ x (* 2.0 (+ x y))) (- z (* x -3.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.6e-21) {
tmp = z - (y * -2.0);
} else if (z <= 1.42e+17) {
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 (z <= (-4.6d-21)) then
tmp = z - (y * (-2.0d0))
else if (z <= 1.42d+17) 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 (z <= -4.6e-21) {
tmp = z - (y * -2.0);
} else if (z <= 1.42e+17) {
tmp = x + (2.0 * (x + y));
} else {
tmp = z - (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.6e-21: tmp = z - (y * -2.0) elif z <= 1.42e+17: tmp = x + (2.0 * (x + y)) else: tmp = z - (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.6e-21) tmp = Float64(z - Float64(y * -2.0)); elseif (z <= 1.42e+17) 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 (z <= -4.6e-21) tmp = z - (y * -2.0); elseif (z <= 1.42e+17) tmp = x + (2.0 * (x + y)); else tmp = z - (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.6e-21], N[(z - N[(y * -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.42e+17], 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}\;z \leq -4.6 \cdot 10^{-21}:\\
\;\;\;\;z - y \cdot -2\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{+17}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;z - x \cdot -3\\
\end{array}
\end{array}
if z < -4.59999999999999999e-21Initial 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 80.9%
if -4.59999999999999999e-21 < z < 1.42e17Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in z around 0 93.6%
if 1.42e17 < z Initial 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-define100.0%
Simplified100.0%
Taylor expanded in y around 0 84.2%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.5e+124) (not (<= y 5.5e+112))) (- z (* y -2.0)) (- z (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.5e+124) || !(y <= 5.5e+112)) {
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 <= (-1.5d+124)) .or. (.not. (y <= 5.5d+112))) 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 <= -1.5e+124) || !(y <= 5.5e+112)) {
tmp = z - (y * -2.0);
} else {
tmp = z - (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.5e+124) or not (y <= 5.5e+112): tmp = z - (y * -2.0) else: tmp = z - (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.5e+124) || !(y <= 5.5e+112)) 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 <= -1.5e+124) || ~((y <= 5.5e+112))) tmp = z - (y * -2.0); else tmp = z - (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.5e+124], N[Not[LessEqual[y, 5.5e+112]], $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 -1.5 \cdot 10^{+124} \lor \neg \left(y \leq 5.5 \cdot 10^{+112}\right):\\
\;\;\;\;z - y \cdot -2\\
\mathbf{else}:\\
\;\;\;\;z - x \cdot -3\\
\end{array}
\end{array}
if y < -1.5e124 or 5.50000000000000026e112 < 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 91.0%
if -1.5e124 < y < 5.50000000000000026e112Initial program 99.9%
+-commutative99.9%
associate-+l+99.8%
remove-double-neg99.8%
unsub-neg99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
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 y around 0 86.7%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.56e+156) (not (<= y 2.2e+126))) (+ x (* y 2.0)) (- z (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.56e+156) || !(y <= 2.2e+126)) {
tmp = x + (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 <= (-1.56d+156)) .or. (.not. (y <= 2.2d+126))) then
tmp = x + (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 <= -1.56e+156) || !(y <= 2.2e+126)) {
tmp = x + (y * 2.0);
} else {
tmp = z - (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.56e+156) or not (y <= 2.2e+126): tmp = x + (y * 2.0) else: tmp = z - (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.56e+156) || !(y <= 2.2e+126)) tmp = Float64(x + 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 <= -1.56e+156) || ~((y <= 2.2e+126))) tmp = x + (y * 2.0); else tmp = z - (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.56e+156], N[Not[LessEqual[y, 2.2e+126]], $MachinePrecision]], N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(z - N[(x * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.56 \cdot 10^{+156} \lor \neg \left(y \leq 2.2 \cdot 10^{+126}\right):\\
\;\;\;\;x + y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;z - x \cdot -3\\
\end{array}
\end{array}
if y < -1.55999999999999992e156 or 2.19999999999999999e126 < 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.5%
Taylor expanded in x around 0 79.2%
if -1.55999999999999992e156 < y < 2.19999999999999999e126Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
remove-double-neg99.9%
unsub-neg99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.8%
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 y around 0 85.3%
Final simplification83.7%
(FPCore (x y z) :precision binary64 (if (<= z -2e-23) z (if (<= z 1.65e+17) (* y 2.0) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e-23) {
tmp = z;
} else if (z <= 1.65e+17) {
tmp = y * 2.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 (z <= (-2d-23)) then
tmp = z
else if (z <= 1.65d+17) then
tmp = y * 2.0d0
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2e-23) {
tmp = z;
} else if (z <= 1.65e+17) {
tmp = y * 2.0;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2e-23: tmp = z elif z <= 1.65e+17: tmp = y * 2.0 else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2e-23) tmp = z; elseif (z <= 1.65e+17) tmp = Float64(y * 2.0); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2e-23) tmp = z; elseif (z <= 1.65e+17) tmp = y * 2.0; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2e-23], z, If[LessEqual[z, 1.65e+17], N[(y * 2.0), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-23}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+17}:\\
\;\;\;\;y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -1.99999999999999992e-23 or 1.65e17 < z 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 inf 60.4%
if -1.99999999999999992e-23 < z < 1.65e17Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in y around inf 42.7%
Final simplification51.4%
(FPCore (x y z) :precision binary64 (+ (* 2.0 (+ x y)) (+ z x)))
double code(double x, double y, double z) {
return (2.0 * (x + y)) + (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 = (2.0d0 * (x + y)) + (z + x)
end function
public static double code(double x, double y, double z) {
return (2.0 * (x + y)) + (z + x);
}
def code(x, y, z): return (2.0 * (x + y)) + (z + x)
function code(x, y, z) return Float64(Float64(2.0 * Float64(x + y)) + Float64(z + x)) end
function tmp = code(x, y, z) tmp = (2.0 * (x + y)) + (z + x); end
code[x_, y_, z_] := N[(N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision] + N[(z + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(x + y\right) + \left(z + x\right)
\end{array}
Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(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 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 33.6%
herbie shell --seed 2024110
(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))