
(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 9 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%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= x -15500000000.0)
(* x 3.0)
(if (<= x -6.5e-154)
z
(if (<= x -1e-286)
(* y 2.0)
(if (<= x 6.8e-261)
z
(if (<= x 2.3e-217)
(* y 2.0)
(if (<= x 1.15e-60) z (if (<= x 3.5e+41) (* y 2.0) (* x 3.0)))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -15500000000.0) {
tmp = x * 3.0;
} else if (x <= -6.5e-154) {
tmp = z;
} else if (x <= -1e-286) {
tmp = y * 2.0;
} else if (x <= 6.8e-261) {
tmp = z;
} else if (x <= 2.3e-217) {
tmp = y * 2.0;
} else if (x <= 1.15e-60) {
tmp = z;
} else if (x <= 3.5e+41) {
tmp = y * 2.0;
} else {
tmp = 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 (x <= (-15500000000.0d0)) then
tmp = x * 3.0d0
else if (x <= (-6.5d-154)) then
tmp = z
else if (x <= (-1d-286)) then
tmp = y * 2.0d0
else if (x <= 6.8d-261) then
tmp = z
else if (x <= 2.3d-217) then
tmp = y * 2.0d0
else if (x <= 1.15d-60) then
tmp = z
else if (x <= 3.5d+41) then
tmp = y * 2.0d0
else
tmp = x * 3.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -15500000000.0) {
tmp = x * 3.0;
} else if (x <= -6.5e-154) {
tmp = z;
} else if (x <= -1e-286) {
tmp = y * 2.0;
} else if (x <= 6.8e-261) {
tmp = z;
} else if (x <= 2.3e-217) {
tmp = y * 2.0;
} else if (x <= 1.15e-60) {
tmp = z;
} else if (x <= 3.5e+41) {
tmp = y * 2.0;
} else {
tmp = x * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -15500000000.0: tmp = x * 3.0 elif x <= -6.5e-154: tmp = z elif x <= -1e-286: tmp = y * 2.0 elif x <= 6.8e-261: tmp = z elif x <= 2.3e-217: tmp = y * 2.0 elif x <= 1.15e-60: tmp = z elif x <= 3.5e+41: tmp = y * 2.0 else: tmp = x * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -15500000000.0) tmp = Float64(x * 3.0); elseif (x <= -6.5e-154) tmp = z; elseif (x <= -1e-286) tmp = Float64(y * 2.0); elseif (x <= 6.8e-261) tmp = z; elseif (x <= 2.3e-217) tmp = Float64(y * 2.0); elseif (x <= 1.15e-60) tmp = z; elseif (x <= 3.5e+41) tmp = Float64(y * 2.0); else tmp = Float64(x * 3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -15500000000.0) tmp = x * 3.0; elseif (x <= -6.5e-154) tmp = z; elseif (x <= -1e-286) tmp = y * 2.0; elseif (x <= 6.8e-261) tmp = z; elseif (x <= 2.3e-217) tmp = y * 2.0; elseif (x <= 1.15e-60) tmp = z; elseif (x <= 3.5e+41) tmp = y * 2.0; else tmp = x * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -15500000000.0], N[(x * 3.0), $MachinePrecision], If[LessEqual[x, -6.5e-154], z, If[LessEqual[x, -1e-286], N[(y * 2.0), $MachinePrecision], If[LessEqual[x, 6.8e-261], z, If[LessEqual[x, 2.3e-217], N[(y * 2.0), $MachinePrecision], If[LessEqual[x, 1.15e-60], z, If[LessEqual[x, 3.5e+41], N[(y * 2.0), $MachinePrecision], N[(x * 3.0), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -15500000000:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{-154}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-286}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{-261}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-217}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-60}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+41}:\\
\;\;\;\;y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;x \cdot 3\\
\end{array}
\end{array}
if x < -1.55e10 or 3.4999999999999999e41 < x Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.8%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 65.7%
if -1.55e10 < x < -6.5000000000000003e-154 or -1.00000000000000005e-286 < x < 6.8e-261 or 2.30000000000000005e-217 < x < 1.1500000000000001e-60Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in z around inf 59.4%
if -6.5000000000000003e-154 < x < -1.00000000000000005e-286 or 6.8e-261 < x < 2.30000000000000005e-217 or 1.1500000000000001e-60 < x < 3.4999999999999999e41Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 68.2%
Final simplification64.2%
(FPCore (x y z)
:precision binary64
(if (<= z -1.65e+27)
(+ z x)
(if (<= z -2.8e-181)
(* y 2.0)
(if (<= z 3.5e-179)
(* x 3.0)
(if (<= z 2.1e-78)
(* y 2.0)
(if (<= z 6.5e-25)
(* x 3.0)
(if (<= z 6.5e+109) (* y 2.0) (+ z x))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.65e+27) {
tmp = z + x;
} else if (z <= -2.8e-181) {
tmp = y * 2.0;
} else if (z <= 3.5e-179) {
tmp = x * 3.0;
} else if (z <= 2.1e-78) {
tmp = y * 2.0;
} else if (z <= 6.5e-25) {
tmp = x * 3.0;
} else if (z <= 6.5e+109) {
tmp = y * 2.0;
} else {
tmp = z + 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 (z <= (-1.65d+27)) then
tmp = z + x
else if (z <= (-2.8d-181)) then
tmp = y * 2.0d0
else if (z <= 3.5d-179) then
tmp = x * 3.0d0
else if (z <= 2.1d-78) then
tmp = y * 2.0d0
else if (z <= 6.5d-25) then
tmp = x * 3.0d0
else if (z <= 6.5d+109) then
tmp = y * 2.0d0
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.65e+27) {
tmp = z + x;
} else if (z <= -2.8e-181) {
tmp = y * 2.0;
} else if (z <= 3.5e-179) {
tmp = x * 3.0;
} else if (z <= 2.1e-78) {
tmp = y * 2.0;
} else if (z <= 6.5e-25) {
tmp = x * 3.0;
} else if (z <= 6.5e+109) {
tmp = y * 2.0;
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.65e+27: tmp = z + x elif z <= -2.8e-181: tmp = y * 2.0 elif z <= 3.5e-179: tmp = x * 3.0 elif z <= 2.1e-78: tmp = y * 2.0 elif z <= 6.5e-25: tmp = x * 3.0 elif z <= 6.5e+109: tmp = y * 2.0 else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.65e+27) tmp = Float64(z + x); elseif (z <= -2.8e-181) tmp = Float64(y * 2.0); elseif (z <= 3.5e-179) tmp = Float64(x * 3.0); elseif (z <= 2.1e-78) tmp = Float64(y * 2.0); elseif (z <= 6.5e-25) tmp = Float64(x * 3.0); elseif (z <= 6.5e+109) tmp = Float64(y * 2.0); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.65e+27) tmp = z + x; elseif (z <= -2.8e-181) tmp = y * 2.0; elseif (z <= 3.5e-179) tmp = x * 3.0; elseif (z <= 2.1e-78) tmp = y * 2.0; elseif (z <= 6.5e-25) tmp = x * 3.0; elseif (z <= 6.5e+109) tmp = y * 2.0; else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.65e+27], N[(z + x), $MachinePrecision], If[LessEqual[z, -2.8e-181], N[(y * 2.0), $MachinePrecision], If[LessEqual[z, 3.5e-179], N[(x * 3.0), $MachinePrecision], If[LessEqual[z, 2.1e-78], N[(y * 2.0), $MachinePrecision], If[LessEqual[z, 6.5e-25], N[(x * 3.0), $MachinePrecision], If[LessEqual[z, 6.5e+109], N[(y * 2.0), $MachinePrecision], N[(z + x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{+27}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{-181}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-179}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-78}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{-25}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+109}:\\
\;\;\;\;y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if z < -1.6499999999999999e27 or 6.5e109 < 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 99.9%
associate-+r+99.9%
distribute-rgt-in99.9%
clear-num99.8%
un-div-inv99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 99.8%
Taylor expanded in z around inf 74.6%
if -1.6499999999999999e27 < z < -2.79999999999999986e-181 or 3.50000000000000024e-179 < z < 2.1000000000000001e-78 or 6.5e-25 < z < 6.5e109Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around inf 56.3%
if -2.79999999999999986e-181 < z < 3.50000000000000024e-179 or 2.1000000000000001e-78 < z < 6.5e-25Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 58.1%
Final simplification63.3%
(FPCore (x y z) :precision binary64 (if (<= x -2.15e-30) (+ z (* x 3.0)) (if (<= x 47.0) (+ z (* y 2.0)) (+ (* x 3.0) (* y 2.0)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.15e-30) {
tmp = z + (x * 3.0);
} else if (x <= 47.0) {
tmp = z + (y * 2.0);
} else {
tmp = (x * 3.0) + (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 (x <= (-2.15d-30)) then
tmp = z + (x * 3.0d0)
else if (x <= 47.0d0) then
tmp = z + (y * 2.0d0)
else
tmp = (x * 3.0d0) + (y * 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.15e-30) {
tmp = z + (x * 3.0);
} else if (x <= 47.0) {
tmp = z + (y * 2.0);
} else {
tmp = (x * 3.0) + (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.15e-30: tmp = z + (x * 3.0) elif x <= 47.0: tmp = z + (y * 2.0) else: tmp = (x * 3.0) + (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.15e-30) tmp = Float64(z + Float64(x * 3.0)); elseif (x <= 47.0) tmp = Float64(z + Float64(y * 2.0)); else tmp = Float64(Float64(x * 3.0) + Float64(y * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.15e-30) tmp = z + (x * 3.0); elseif (x <= 47.0) tmp = z + (y * 2.0); else tmp = (x * 3.0) + (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.15e-30], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 47.0], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(x * 3.0), $MachinePrecision] + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15 \cdot 10^{-30}:\\
\;\;\;\;z + x \cdot 3\\
\mathbf{elif}\;x \leq 47:\\
\;\;\;\;z + y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;x \cdot 3 + y \cdot 2\\
\end{array}
\end{array}
if x < -2.14999999999999983e-30Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 81.8%
if -2.14999999999999983e-30 < x < 47Initial program 99.9%
+-commutative99.9%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 92.6%
if 47 < x Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 84.5%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -6.4e+162) (not (<= x 1.15e+152))) (* x 3.0) (+ z (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6.4e+162) || !(x <= 1.15e+152)) {
tmp = x * 3.0;
} else {
tmp = z + (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 ((x <= (-6.4d+162)) .or. (.not. (x <= 1.15d+152))) then
tmp = x * 3.0d0
else
tmp = z + (y * 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -6.4e+162) || !(x <= 1.15e+152)) {
tmp = x * 3.0;
} else {
tmp = z + (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6.4e+162) or not (x <= 1.15e+152): tmp = x * 3.0 else: tmp = z + (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -6.4e+162) || !(x <= 1.15e+152)) tmp = Float64(x * 3.0); else tmp = Float64(z + Float64(y * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -6.4e+162) || ~((x <= 1.15e+152))) tmp = x * 3.0; else tmp = z + (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6.4e+162], N[Not[LessEqual[x, 1.15e+152]], $MachinePrecision]], N[(x * 3.0), $MachinePrecision], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{+162} \lor \neg \left(x \leq 1.15 \cdot 10^{+152}\right):\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + y \cdot 2\\
\end{array}
\end{array}
if x < -6.4000000000000002e162 or 1.14999999999999993e152 < x Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.8%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 81.8%
if -6.4000000000000002e162 < x < 1.14999999999999993e152Initial program 99.9%
+-commutative99.9%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+99.9%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 83.9%
Final simplification83.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.15e-30) (not (<= x 3.15e+41))) (+ z (* x 3.0)) (+ z (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.15e-30) || !(x <= 3.15e+41)) {
tmp = z + (x * 3.0);
} else {
tmp = z + (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 ((x <= (-2.15d-30)) .or. (.not. (x <= 3.15d+41))) then
tmp = z + (x * 3.0d0)
else
tmp = z + (y * 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.15e-30) || !(x <= 3.15e+41)) {
tmp = z + (x * 3.0);
} else {
tmp = z + (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.15e-30) or not (x <= 3.15e+41): tmp = z + (x * 3.0) else: tmp = z + (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.15e-30) || !(x <= 3.15e+41)) tmp = Float64(z + Float64(x * 3.0)); else tmp = Float64(z + Float64(y * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.15e-30) || ~((x <= 3.15e+41))) tmp = z + (x * 3.0); else tmp = z + (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.15e-30], N[Not[LessEqual[x, 3.15e+41]], $MachinePrecision]], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15 \cdot 10^{-30} \lor \neg \left(x \leq 3.15 \cdot 10^{+41}\right):\\
\;\;\;\;z + x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + y \cdot 2\\
\end{array}
\end{array}
if x < -2.14999999999999983e-30 or 3.1499999999999999e41 < x Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 82.9%
if -2.14999999999999983e-30 < x < 3.1499999999999999e41Initial program 99.9%
+-commutative99.9%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 91.6%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (<= z -1.75e+25) z (if (<= z 2.8e+113) (* y 2.0) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.75e+25) {
tmp = z;
} else if (z <= 2.8e+113) {
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 <= (-1.75d+25)) then
tmp = z
else if (z <= 2.8d+113) 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 <= -1.75e+25) {
tmp = z;
} else if (z <= 2.8e+113) {
tmp = y * 2.0;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.75e+25: tmp = z elif z <= 2.8e+113: tmp = y * 2.0 else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.75e+25) tmp = z; elseif (z <= 2.8e+113) tmp = Float64(y * 2.0); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.75e+25) tmp = z; elseif (z <= 2.8e+113) tmp = y * 2.0; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.75e+25], z, If[LessEqual[z, 2.8e+113], N[(y * 2.0), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.75 \cdot 10^{+25}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+113}:\\
\;\;\;\;y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -1.75e25 or 2.79999999999999998e113 < z Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in z around inf 73.4%
if -1.75e25 < z < 2.79999999999999998e113Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around inf 45.1%
Final simplification55.0%
(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%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 35.1%
Final simplification35.1%
herbie shell --seed 2024130
(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))