
(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 (fma x 3.0 (fma y 2.0 z)))
double code(double x, double y, double z) {
return fma(x, 3.0, fma(y, 2.0, z));
}
function code(x, y, z) return fma(x, 3.0, fma(y, 2.0, z)) end
code[x_, y_, z_] := N[(x * 3.0 + N[(y * 2.0 + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, 3, \mathsf{fma}\left(y, 2, z\right)\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
count-299.9%
associate-+l+99.9%
associate-+r+99.9%
distribute-rgt1-in99.9%
*-commutative99.9%
fma-def100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
fma-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= z -1.25e+69)
z
(if (<= z -1e-131)
(* y 2.0)
(if (<= z 7.2e-298)
(* x 3.0)
(if (<= z 2.15e-284)
(* y 2.0)
(if (<= z 6.4e-235)
(* x 3.0)
(if (<= z 8.6e-94) (* y 2.0) (if (<= z 2.2e+46) (* x 3.0) z))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.25e+69) {
tmp = z;
} else if (z <= -1e-131) {
tmp = y * 2.0;
} else if (z <= 7.2e-298) {
tmp = x * 3.0;
} else if (z <= 2.15e-284) {
tmp = y * 2.0;
} else if (z <= 6.4e-235) {
tmp = x * 3.0;
} else if (z <= 8.6e-94) {
tmp = y * 2.0;
} else if (z <= 2.2e+46) {
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 (z <= (-1.25d+69)) then
tmp = z
else if (z <= (-1d-131)) then
tmp = y * 2.0d0
else if (z <= 7.2d-298) then
tmp = x * 3.0d0
else if (z <= 2.15d-284) then
tmp = y * 2.0d0
else if (z <= 6.4d-235) then
tmp = x * 3.0d0
else if (z <= 8.6d-94) then
tmp = y * 2.0d0
else if (z <= 2.2d+46) 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 (z <= -1.25e+69) {
tmp = z;
} else if (z <= -1e-131) {
tmp = y * 2.0;
} else if (z <= 7.2e-298) {
tmp = x * 3.0;
} else if (z <= 2.15e-284) {
tmp = y * 2.0;
} else if (z <= 6.4e-235) {
tmp = x * 3.0;
} else if (z <= 8.6e-94) {
tmp = y * 2.0;
} else if (z <= 2.2e+46) {
tmp = x * 3.0;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.25e+69: tmp = z elif z <= -1e-131: tmp = y * 2.0 elif z <= 7.2e-298: tmp = x * 3.0 elif z <= 2.15e-284: tmp = y * 2.0 elif z <= 6.4e-235: tmp = x * 3.0 elif z <= 8.6e-94: tmp = y * 2.0 elif z <= 2.2e+46: tmp = x * 3.0 else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.25e+69) tmp = z; elseif (z <= -1e-131) tmp = Float64(y * 2.0); elseif (z <= 7.2e-298) tmp = Float64(x * 3.0); elseif (z <= 2.15e-284) tmp = Float64(y * 2.0); elseif (z <= 6.4e-235) tmp = Float64(x * 3.0); elseif (z <= 8.6e-94) tmp = Float64(y * 2.0); elseif (z <= 2.2e+46) tmp = Float64(x * 3.0); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.25e+69) tmp = z; elseif (z <= -1e-131) tmp = y * 2.0; elseif (z <= 7.2e-298) tmp = x * 3.0; elseif (z <= 2.15e-284) tmp = y * 2.0; elseif (z <= 6.4e-235) tmp = x * 3.0; elseif (z <= 8.6e-94) tmp = y * 2.0; elseif (z <= 2.2e+46) tmp = x * 3.0; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.25e+69], z, If[LessEqual[z, -1e-131], N[(y * 2.0), $MachinePrecision], If[LessEqual[z, 7.2e-298], N[(x * 3.0), $MachinePrecision], If[LessEqual[z, 2.15e-284], N[(y * 2.0), $MachinePrecision], If[LessEqual[z, 6.4e-235], N[(x * 3.0), $MachinePrecision], If[LessEqual[z, 8.6e-94], N[(y * 2.0), $MachinePrecision], If[LessEqual[z, 2.2e+46], N[(x * 3.0), $MachinePrecision], z]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+69}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-131}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{-298}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;z \leq 2.15 \cdot 10^{-284}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;z \leq 6.4 \cdot 10^{-235}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;z \leq 8.6 \cdot 10^{-94}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{+46}:\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -1.25000000000000009e69 or 2.2e46 < z Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around inf 70.1%
if -1.25000000000000009e69 < z < -9.9999999999999999e-132 or 7.20000000000000005e-298 < z < 2.1500000000000001e-284 or 6.4000000000000003e-235 < z < 8.5999999999999997e-94Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around inf 63.3%
if -9.9999999999999999e-132 < z < 7.20000000000000005e-298 or 2.1500000000000001e-284 < z < 6.4000000000000003e-235 or 8.5999999999999997e-94 < z < 2.2e46Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around inf 62.2%
Final simplification65.4%
(FPCore (x y z) :precision binary64 (if (<= z -2.1e-57) (+ z (* y 2.0)) (if (<= z 1.12e+30) (+ x (* 2.0 (+ x y))) (+ z (* x 3.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e-57) {
tmp = z + (y * 2.0);
} else if (z <= 1.12e+30) {
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 <= (-2.1d-57)) then
tmp = z + (y * 2.0d0)
else if (z <= 1.12d+30) 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 <= -2.1e-57) {
tmp = z + (y * 2.0);
} else if (z <= 1.12e+30) {
tmp = x + (2.0 * (x + y));
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.1e-57: tmp = z + (y * 2.0) elif z <= 1.12e+30: tmp = x + (2.0 * (x + y)) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.1e-57) tmp = Float64(z + Float64(y * 2.0)); elseif (z <= 1.12e+30) 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 <= -2.1e-57) tmp = z + (y * 2.0); elseif (z <= 1.12e+30) tmp = x + (2.0 * (x + y)); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.1e-57], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.12e+30], 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 -2.1 \cdot 10^{-57}:\\
\;\;\;\;z + y \cdot 2\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{+30}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if z < -2.0999999999999999e-57Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around 0 83.2%
if -2.0999999999999999e-57 < z < 1.12e30Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around 0 93.4%
if 1.12e30 < z Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around 0 87.2%
+-commutative87.2%
associate-+l+87.3%
distribute-rgt1-in87.3%
metadata-eval87.3%
Simplified87.3%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.55e-50) (+ z (* y 2.0)) (if (<= z 2e+32) (+ (* x 3.0) (* y 2.0)) (+ z (* x 3.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.55e-50) {
tmp = z + (y * 2.0);
} else if (z <= 2e+32) {
tmp = (x * 3.0) + (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 (z <= (-1.55d-50)) then
tmp = z + (y * 2.0d0)
else if (z <= 2d+32) then
tmp = (x * 3.0d0) + (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 (z <= -1.55e-50) {
tmp = z + (y * 2.0);
} else if (z <= 2e+32) {
tmp = (x * 3.0) + (y * 2.0);
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.55e-50: tmp = z + (y * 2.0) elif z <= 2e+32: tmp = (x * 3.0) + (y * 2.0) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.55e-50) tmp = Float64(z + Float64(y * 2.0)); elseif (z <= 2e+32) tmp = Float64(Float64(x * 3.0) + 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 (z <= -1.55e-50) tmp = z + (y * 2.0); elseif (z <= 2e+32) tmp = (x * 3.0) + (y * 2.0); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.55e-50], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2e+32], N[(N[(x * 3.0), $MachinePrecision] + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{-50}:\\
\;\;\;\;z + y \cdot 2\\
\mathbf{elif}\;z \leq 2 \cdot 10^{+32}:\\
\;\;\;\;x \cdot 3 + y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if z < -1.5500000000000001e-50Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around 0 83.2%
if -1.5500000000000001e-50 < z < 2.00000000000000011e32Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
Taylor expanded in z around 0 93.4%
if 2.00000000000000011e32 < z Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around 0 87.2%
+-commutative87.2%
associate-+l+87.3%
distribute-rgt1-in87.3%
metadata-eval87.3%
Simplified87.3%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.25e+65) (not (<= x 2.9e+60))) (+ z (* x 3.0)) (+ z (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.25e+65) || !(x <= 2.9e+60)) {
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 <= (-1.25d+65)) .or. (.not. (x <= 2.9d+60))) 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 <= -1.25e+65) || !(x <= 2.9e+60)) {
tmp = z + (x * 3.0);
} else {
tmp = z + (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.25e+65) or not (x <= 2.9e+60): tmp = z + (x * 3.0) else: tmp = z + (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.25e+65) || !(x <= 2.9e+60)) 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 <= -1.25e+65) || ~((x <= 2.9e+60))) tmp = z + (x * 3.0); else tmp = z + (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.25e+65], N[Not[LessEqual[x, 2.9e+60]], $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 -1.25 \cdot 10^{+65} \lor \neg \left(x \leq 2.9 \cdot 10^{+60}\right):\\
\;\;\;\;z + x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + y \cdot 2\\
\end{array}
\end{array}
if x < -1.24999999999999993e65 or 2.9e60 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in y around 0 89.1%
+-commutative89.1%
associate-+l+89.1%
distribute-rgt1-in89.1%
metadata-eval89.1%
Simplified89.1%
if -1.24999999999999993e65 < x < 2.9e60Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 89.2%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (<= y -3.4e+138) (* y 2.0) (if (<= y 6.2e+64) (+ z (* x 3.0)) (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+138) {
tmp = y * 2.0;
} else if (y <= 6.2e+64) {
tmp = z + (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 <= (-3.4d+138)) then
tmp = y * 2.0d0
else if (y <= 6.2d+64) then
tmp = z + (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 <= -3.4e+138) {
tmp = y * 2.0;
} else if (y <= 6.2e+64) {
tmp = z + (x * 3.0);
} else {
tmp = y * 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.4e+138: tmp = y * 2.0 elif y <= 6.2e+64: tmp = z + (x * 3.0) else: tmp = y * 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.4e+138) tmp = Float64(y * 2.0); elseif (y <= 6.2e+64) tmp = Float64(z + 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 <= -3.4e+138) tmp = y * 2.0; elseif (y <= 6.2e+64) tmp = z + (x * 3.0); else tmp = y * 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.4e+138], N[(y * 2.0), $MachinePrecision], If[LessEqual[y, 6.2e+64], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision], N[(y * 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+138}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+64}:\\
\;\;\;\;z + x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;y \cdot 2\\
\end{array}
\end{array}
if y < -3.40000000000000011e138 or 6.1999999999999998e64 < y Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around inf 68.6%
if -3.40000000000000011e138 < y < 6.1999999999999998e64Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around 0 83.1%
+-commutative83.1%
associate-+l+83.1%
distribute-rgt1-in83.1%
metadata-eval83.1%
Simplified83.1%
Final simplification78.6%
(FPCore (x y z) :precision binary64 (+ x (+ z (* 2.0 (+ x y)))))
double code(double x, double y, double z) {
return x + (z + (2.0 * (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 + (z + (2.0d0 * (x + y)))
end function
public static double code(double x, double y, double z) {
return x + (z + (2.0 * (x + y)));
}
def code(x, y, z): return x + (z + (2.0 * (x + y)))
function code(x, y, z) return Float64(x + Float64(z + Float64(2.0 * Float64(x + y)))) end
function tmp = code(x, y, z) tmp = x + (z + (2.0 * (x + y))); end
code[x_, y_, z_] := N[(x + N[(z + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(z + 2 \cdot \left(x + y\right)\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (+ (* x 3.0) (+ z (* y 2.0))))
double code(double x, double y, double z) {
return (x * 3.0) + (z + (y * 2.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * 3.0d0) + (z + (y * 2.0d0))
end function
public static double code(double x, double y, double z) {
return (x * 3.0) + (z + (y * 2.0));
}
def code(x, y, z): return (x * 3.0) + (z + (y * 2.0))
function code(x, y, z) return Float64(Float64(x * 3.0) + Float64(z + Float64(y * 2.0))) end
function tmp = code(x, y, z) tmp = (x * 3.0) + (z + (y * 2.0)); end
code[x_, y_, z_] := N[(N[(x * 3.0), $MachinePrecision] + N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 3 + \left(z + y \cdot 2\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z -5e+67) z (if (<= z 6.2e+29) (* y 2.0) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -5e+67) {
tmp = z;
} else if (z <= 6.2e+29) {
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 <= (-5d+67)) then
tmp = z
else if (z <= 6.2d+29) 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 <= -5e+67) {
tmp = z;
} else if (z <= 6.2e+29) {
tmp = y * 2.0;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5e+67: tmp = z elif z <= 6.2e+29: tmp = y * 2.0 else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5e+67) tmp = z; elseif (z <= 6.2e+29) tmp = Float64(y * 2.0); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5e+67) tmp = z; elseif (z <= 6.2e+29) tmp = y * 2.0; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5e+67], z, If[LessEqual[z, 6.2e+29], N[(y * 2.0), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+67}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+29}:\\
\;\;\;\;y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -4.99999999999999976e67 or 6.1999999999999998e29 < z Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around inf 69.0%
if -4.99999999999999976e67 < z < 6.1999999999999998e29Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around inf 47.4%
Final simplification55.6%
(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%
count-299.9%
Simplified99.9%
Taylor expanded in z around inf 33.6%
Final simplification33.6%
herbie shell --seed 2023185
(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))