
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.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 * (y + z)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
def code(x, y, z): return (x * (y + z)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (y + z)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + z\right) + z \cdot 5
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.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 * (y + z)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
def code(x, y, z): return (x * (y + z)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (y + z)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + z\right) + z \cdot 5
\end{array}
(FPCore (x y z) :precision binary64 (fma z 5.0 (* x (+ y z))))
double code(double x, double y, double z) {
return fma(z, 5.0, (x * (y + z)));
}
function code(x, y, z) return fma(z, 5.0, Float64(x * Float64(y + z))) end
code[x_, y_, z_] := N[(z * 5.0 + N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, 5, x \cdot \left(y + z\right)\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= x -4.8e+176)
(* x y)
(if (<= x -4.3e+48)
(* x z)
(if (<= x -1.55e-18)
(* x y)
(if (<= x 3.3e-13)
(* 5.0 z)
(if (<= x 1.08e+38)
(* x y)
(if (<= x 7.5e+158)
(* x z)
(if (<= x 1.3e+228) (* x y) (* x z)))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.8e+176) {
tmp = x * y;
} else if (x <= -4.3e+48) {
tmp = x * z;
} else if (x <= -1.55e-18) {
tmp = x * y;
} else if (x <= 3.3e-13) {
tmp = 5.0 * z;
} else if (x <= 1.08e+38) {
tmp = x * y;
} else if (x <= 7.5e+158) {
tmp = x * z;
} else if (x <= 1.3e+228) {
tmp = x * y;
} else {
tmp = x * 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 <= (-4.8d+176)) then
tmp = x * y
else if (x <= (-4.3d+48)) then
tmp = x * z
else if (x <= (-1.55d-18)) then
tmp = x * y
else if (x <= 3.3d-13) then
tmp = 5.0d0 * z
else if (x <= 1.08d+38) then
tmp = x * y
else if (x <= 7.5d+158) then
tmp = x * z
else if (x <= 1.3d+228) then
tmp = x * y
else
tmp = x * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -4.8e+176) {
tmp = x * y;
} else if (x <= -4.3e+48) {
tmp = x * z;
} else if (x <= -1.55e-18) {
tmp = x * y;
} else if (x <= 3.3e-13) {
tmp = 5.0 * z;
} else if (x <= 1.08e+38) {
tmp = x * y;
} else if (x <= 7.5e+158) {
tmp = x * z;
} else if (x <= 1.3e+228) {
tmp = x * y;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.8e+176: tmp = x * y elif x <= -4.3e+48: tmp = x * z elif x <= -1.55e-18: tmp = x * y elif x <= 3.3e-13: tmp = 5.0 * z elif x <= 1.08e+38: tmp = x * y elif x <= 7.5e+158: tmp = x * z elif x <= 1.3e+228: tmp = x * y else: tmp = x * z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.8e+176) tmp = Float64(x * y); elseif (x <= -4.3e+48) tmp = Float64(x * z); elseif (x <= -1.55e-18) tmp = Float64(x * y); elseif (x <= 3.3e-13) tmp = Float64(5.0 * z); elseif (x <= 1.08e+38) tmp = Float64(x * y); elseif (x <= 7.5e+158) tmp = Float64(x * z); elseif (x <= 1.3e+228) tmp = Float64(x * y); else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -4.8e+176) tmp = x * y; elseif (x <= -4.3e+48) tmp = x * z; elseif (x <= -1.55e-18) tmp = x * y; elseif (x <= 3.3e-13) tmp = 5.0 * z; elseif (x <= 1.08e+38) tmp = x * y; elseif (x <= 7.5e+158) tmp = x * z; elseif (x <= 1.3e+228) tmp = x * y; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.8e+176], N[(x * y), $MachinePrecision], If[LessEqual[x, -4.3e+48], N[(x * z), $MachinePrecision], If[LessEqual[x, -1.55e-18], N[(x * y), $MachinePrecision], If[LessEqual[x, 3.3e-13], N[(5.0 * z), $MachinePrecision], If[LessEqual[x, 1.08e+38], N[(x * y), $MachinePrecision], If[LessEqual[x, 7.5e+158], N[(x * z), $MachinePrecision], If[LessEqual[x, 1.3e+228], N[(x * y), $MachinePrecision], N[(x * z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+176}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq -4.3 \cdot 10^{+48}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-18}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-13}:\\
\;\;\;\;5 \cdot z\\
\mathbf{elif}\;x \leq 1.08 \cdot 10^{+38}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+158}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+228}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if x < -4.8000000000000003e176 or -4.29999999999999978e48 < x < -1.55000000000000003e-18 or 3.3000000000000001e-13 < x < 1.07999999999999995e38 or 7.5000000000000004e158 < x < 1.30000000000000004e228Initial program 100.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6477.2
Applied rewrites77.2%
if -4.8000000000000003e176 < x < -4.29999999999999978e48 or 1.07999999999999995e38 < x < 7.5000000000000004e158 or 1.30000000000000004e228 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in z around inf
Applied rewrites69.9%
if -1.55000000000000003e-18 < x < 3.3000000000000001e-13Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6477.3
Applied rewrites77.3%
Final simplification75.1%
(FPCore (x y z) :precision binary64 (if (<= x -1.05e+28) (* x (+ y z)) (if (<= x 0.00215) (fma z 5.0 (* x y)) (fma z x (* x y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.05e+28) {
tmp = x * (y + z);
} else if (x <= 0.00215) {
tmp = fma(z, 5.0, (x * y));
} else {
tmp = fma(z, x, (x * y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.05e+28) tmp = Float64(x * Float64(y + z)); elseif (x <= 0.00215) tmp = fma(z, 5.0, Float64(x * y)); else tmp = fma(z, x, Float64(x * y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.05e+28], N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.00215], N[(z * 5.0 + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(z * x + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+28}:\\
\;\;\;\;x \cdot \left(y + z\right)\\
\mathbf{elif}\;x \leq 0.00215:\\
\;\;\;\;\mathsf{fma}\left(z, 5, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x \cdot y\right)\\
\end{array}
\end{array}
if x < -1.04999999999999995e28Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
if -1.04999999999999995e28 < x < 0.00215Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-outN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.1%
if 0.00215 < x Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6498.9
Applied rewrites98.9%
Applied rewrites98.9%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (<= x -1.55e-18) (* x (+ y z)) (if (<= x 1.7e-7) (fma z 5.0 (* x z)) (fma z x (* x y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.55e-18) {
tmp = x * (y + z);
} else if (x <= 1.7e-7) {
tmp = fma(z, 5.0, (x * z));
} else {
tmp = fma(z, x, (x * y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.55e-18) tmp = Float64(x * Float64(y + z)); elseif (x <= 1.7e-7) tmp = fma(z, 5.0, Float64(x * z)); else tmp = fma(z, x, Float64(x * y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.55e-18], N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.7e-7], N[(z * 5.0 + N[(x * z), $MachinePrecision]), $MachinePrecision], N[(z * x + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{-18}:\\
\;\;\;\;x \cdot \left(y + z\right)\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(z, 5, x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x \cdot y\right)\\
\end{array}
\end{array}
if x < -1.55000000000000003e-18Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6497.1
Applied rewrites97.1%
if -1.55000000000000003e-18 < x < 1.69999999999999987e-7Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6477.6
Applied rewrites77.6%
if 1.69999999999999987e-7 < x Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6498.9
Applied rewrites98.9%
Applied rewrites98.9%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (<= x -1.55e-18) (* x (+ y z)) (if (<= x 1.7e-7) (* (- x -5.0) z) (fma z x (* x y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.55e-18) {
tmp = x * (y + z);
} else if (x <= 1.7e-7) {
tmp = (x - -5.0) * z;
} else {
tmp = fma(z, x, (x * y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.55e-18) tmp = Float64(x * Float64(y + z)); elseif (x <= 1.7e-7) tmp = Float64(Float64(x - -5.0) * z); else tmp = fma(z, x, Float64(x * y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.55e-18], N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.7e-7], N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision], N[(z * x + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{-18}:\\
\;\;\;\;x \cdot \left(y + z\right)\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-7}:\\
\;\;\;\;\left(x - -5\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x \cdot y\right)\\
\end{array}
\end{array}
if x < -1.55000000000000003e-18Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6497.1
Applied rewrites97.1%
if -1.55000000000000003e-18 < x < 1.69999999999999987e-7Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower--.f6477.5
Applied rewrites77.5%
if 1.69999999999999987e-7 < x Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6498.9
Applied rewrites98.9%
Applied rewrites98.9%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (+ y z)))) (if (<= x -1.55e-18) t_0 (if (<= x 1.7e-7) (* (- x -5.0) z) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -1.55e-18) {
tmp = t_0;
} else if (x <= 1.7e-7) {
tmp = (x - -5.0) * z;
} 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 + z)
if (x <= (-1.55d-18)) then
tmp = t_0
else if (x <= 1.7d-7) then
tmp = (x - (-5.0d0)) * z
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 + z);
double tmp;
if (x <= -1.55e-18) {
tmp = t_0;
} else if (x <= 1.7e-7) {
tmp = (x - -5.0) * z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y + z) tmp = 0 if x <= -1.55e-18: tmp = t_0 elif x <= 1.7e-7: tmp = (x - -5.0) * z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y + z)) tmp = 0.0 if (x <= -1.55e-18) tmp = t_0; elseif (x <= 1.7e-7) tmp = Float64(Float64(x - -5.0) * z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y + z); tmp = 0.0; if (x <= -1.55e-18) tmp = t_0; elseif (x <= 1.7e-7) tmp = (x - -5.0) * z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.55e-18], t$95$0, If[LessEqual[x, 1.7e-7], N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
\mathbf{if}\;x \leq -1.55 \cdot 10^{-18}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-7}:\\
\;\;\;\;\left(x - -5\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.55000000000000003e-18 or 1.69999999999999987e-7 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6498.0
Applied rewrites98.0%
if -1.55000000000000003e-18 < x < 1.69999999999999987e-7Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower--.f6477.5
Applied rewrites77.5%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (+ y z)))) (if (<= x -1.55e-18) t_0 (if (<= x 3.3e-13) (* 5.0 z) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -1.55e-18) {
tmp = t_0;
} else if (x <= 3.3e-13) {
tmp = 5.0 * z;
} 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 + z)
if (x <= (-1.55d-18)) then
tmp = t_0
else if (x <= 3.3d-13) then
tmp = 5.0d0 * z
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 + z);
double tmp;
if (x <= -1.55e-18) {
tmp = t_0;
} else if (x <= 3.3e-13) {
tmp = 5.0 * z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y + z) tmp = 0 if x <= -1.55e-18: tmp = t_0 elif x <= 3.3e-13: tmp = 5.0 * z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y + z)) tmp = 0.0 if (x <= -1.55e-18) tmp = t_0; elseif (x <= 3.3e-13) tmp = Float64(5.0 * z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y + z); tmp = 0.0; if (x <= -1.55e-18) tmp = t_0; elseif (x <= 3.3e-13) tmp = 5.0 * z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.55e-18], t$95$0, If[LessEqual[x, 3.3e-13], N[(5.0 * z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
\mathbf{if}\;x \leq -1.55 \cdot 10^{-18}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-13}:\\
\;\;\;\;5 \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.55000000000000003e-18 or 3.3000000000000001e-13 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6498.0
Applied rewrites98.0%
if -1.55000000000000003e-18 < x < 3.3000000000000001e-13Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6477.3
Applied rewrites77.3%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (if (<= x -1.05e+28) (* x z) (if (<= x 5.0) (* 5.0 z) (* x z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.05e+28) {
tmp = x * z;
} else if (x <= 5.0) {
tmp = 5.0 * z;
} else {
tmp = x * 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 <= (-1.05d+28)) then
tmp = x * z
else if (x <= 5.0d0) then
tmp = 5.0d0 * z
else
tmp = x * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.05e+28) {
tmp = x * z;
} else if (x <= 5.0) {
tmp = 5.0 * z;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.05e+28: tmp = x * z elif x <= 5.0: tmp = 5.0 * z else: tmp = x * z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.05e+28) tmp = Float64(x * z); elseif (x <= 5.0) tmp = Float64(5.0 * z); else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.05e+28) tmp = x * z; elseif (x <= 5.0) tmp = 5.0 * z; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.05e+28], N[(x * z), $MachinePrecision], If[LessEqual[x, 5.0], N[(5.0 * z), $MachinePrecision], N[(x * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+28}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;x \leq 5:\\
\;\;\;\;5 \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if x < -1.04999999999999995e28 or 5 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in z around inf
Applied rewrites54.4%
if -1.04999999999999995e28 < x < 5Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6472.4
Applied rewrites72.4%
Final simplification63.4%
(FPCore (x y z) :precision binary64 (* x z))
double code(double x, double y, double z) {
return 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 = x * z
end function
public static double code(double x, double y, double z) {
return x * z;
}
def code(x, y, z): return x * z
function code(x, y, z) return Float64(x * z) end
function tmp = code(x, y, z) tmp = x * z; end
code[x_, y_, z_] := N[(x * z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot z
\end{array}
Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6464.8
Applied rewrites64.8%
Taylor expanded in z around inf
Applied rewrites29.1%
Final simplification29.1%
(FPCore (x y z) :precision binary64 (+ (* (+ x 5.0) z) (* x y)))
double code(double x, double y, double z) {
return ((x + 5.0) * z) + (x * y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x + 5.0d0) * z) + (x * y)
end function
public static double code(double x, double y, double z) {
return ((x + 5.0) * z) + (x * y);
}
def code(x, y, z): return ((x + 5.0) * z) + (x * y)
function code(x, y, z) return Float64(Float64(Float64(x + 5.0) * z) + Float64(x * y)) end
function tmp = code(x, y, z) tmp = ((x + 5.0) * z) + (x * y); end
code[x_, y_, z_] := N[(N[(N[(x + 5.0), $MachinePrecision] * z), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + 5\right) \cdot z + x \cdot y
\end{array}
herbie shell --seed 2024259
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
:precision binary64
:alt
(! :herbie-platform default (+ (* (+ x 5) z) (* x y)))
(+ (* x (+ y z)) (* z 5.0)))