
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(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 + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(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 + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
(FPCore (x y z) :precision binary64 (fma (cos y) z (+ (sin y) x)))
double code(double x, double y, double z) {
return fma(cos(y), z, (sin(y) + x));
}
function code(x, y, z) return fma(cos(y), z, Float64(sin(y) + x)) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos y, z, \sin y + x\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (+ x (sin y)) (* z (cos y)))))
(if (<= t_0 -5000.0)
(+ z x)
(if (<= t_0 -0.05)
(sin y)
(if (<= t_0 1e-5)
(fma (fma (fma -0.16666666666666666 y (* -0.5 z)) y 1.0) y (+ z x))
(if (<= t_0 1.0) (sin y) (+ z x)))))))
double code(double x, double y, double z) {
double t_0 = (x + sin(y)) + (z * cos(y));
double tmp;
if (t_0 <= -5000.0) {
tmp = z + x;
} else if (t_0 <= -0.05) {
tmp = sin(y);
} else if (t_0 <= 1e-5) {
tmp = fma(fma(fma(-0.16666666666666666, y, (-0.5 * z)), y, 1.0), y, (z + x));
} else if (t_0 <= 1.0) {
tmp = sin(y);
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x + sin(y)) + Float64(z * cos(y))) tmp = 0.0 if (t_0 <= -5000.0) tmp = Float64(z + x); elseif (t_0 <= -0.05) tmp = sin(y); elseif (t_0 <= 1e-5) tmp = fma(fma(fma(-0.16666666666666666, y, Float64(-0.5 * z)), y, 1.0), y, Float64(z + x)); elseif (t_0 <= 1.0) tmp = sin(y); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5000.0], N[(z + x), $MachinePrecision], If[LessEqual[t$95$0, -0.05], N[Sin[y], $MachinePrecision], If[LessEqual[t$95$0, 1e-5], N[(N[(N[(-0.16666666666666666 * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[Sin[y], $MachinePrecision], N[(z + x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \sin y\right) + z \cdot \cos y\\
\mathbf{if}\;t\_0 \leq -5000:\\
\;\;\;\;z + x\\
\mathbf{elif}\;t\_0 \leq -0.05:\\
\;\;\;\;\sin y\\
\mathbf{elif}\;t\_0 \leq 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, z + x\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin y\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -5e3 or 1 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6473.6
Applied rewrites73.6%
if -5e3 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.050000000000000003 or 1.00000000000000008e-5 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 1Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f6496.5
Applied rewrites96.5%
Taylor expanded in y around 0
Applied rewrites2.6%
Taylor expanded in z around 0
Applied rewrites94.6%
if -0.050000000000000003 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 1.00000000000000008e-5Initial program 99.9%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.35e-7) (not (<= x 4.6e-7))) (fma 1.0 z (+ (sin y) x)) (fma (cos y) z (sin y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.35e-7) || !(x <= 4.6e-7)) {
tmp = fma(1.0, z, (sin(y) + x));
} else {
tmp = fma(cos(y), z, sin(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -1.35e-7) || !(x <= 4.6e-7)) tmp = fma(1.0, z, Float64(sin(y) + x)); else tmp = fma(cos(y), z, sin(y)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.35e-7], N[Not[LessEqual[x, 4.6e-7]], $MachinePrecision]], N[(1.0 * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z + N[Sin[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{-7} \lor \neg \left(x \leq 4.6 \cdot 10^{-7}\right):\\
\;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, \sin y\right)\\
\end{array}
\end{array}
if x < -1.35000000000000004e-7 or 4.5999999999999999e-7 < x Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites90.7%
if -1.35000000000000004e-7 < x < 4.5999999999999999e-7Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f6493.0
Applied rewrites93.0%
Final simplification92.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cos y) z)))
(if (<= z -1.26e+48)
t_0
(if (<= z -1.8e-10)
(+ z x)
(if (<= z 8.6e-71) (+ (sin y) x) (if (<= z 1.65e+30) (+ z x) t_0))))))
double code(double x, double y, double z) {
double t_0 = cos(y) * z;
double tmp;
if (z <= -1.26e+48) {
tmp = t_0;
} else if (z <= -1.8e-10) {
tmp = z + x;
} else if (z <= 8.6e-71) {
tmp = sin(y) + x;
} else if (z <= 1.65e+30) {
tmp = z + x;
} 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 = cos(y) * z
if (z <= (-1.26d+48)) then
tmp = t_0
else if (z <= (-1.8d-10)) then
tmp = z + x
else if (z <= 8.6d-71) then
tmp = sin(y) + x
else if (z <= 1.65d+30) then
tmp = z + x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.cos(y) * z;
double tmp;
if (z <= -1.26e+48) {
tmp = t_0;
} else if (z <= -1.8e-10) {
tmp = z + x;
} else if (z <= 8.6e-71) {
tmp = Math.sin(y) + x;
} else if (z <= 1.65e+30) {
tmp = z + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.cos(y) * z tmp = 0 if z <= -1.26e+48: tmp = t_0 elif z <= -1.8e-10: tmp = z + x elif z <= 8.6e-71: tmp = math.sin(y) + x elif z <= 1.65e+30: tmp = z + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(cos(y) * z) tmp = 0.0 if (z <= -1.26e+48) tmp = t_0; elseif (z <= -1.8e-10) tmp = Float64(z + x); elseif (z <= 8.6e-71) tmp = Float64(sin(y) + x); elseif (z <= 1.65e+30) tmp = Float64(z + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = cos(y) * z; tmp = 0.0; if (z <= -1.26e+48) tmp = t_0; elseif (z <= -1.8e-10) tmp = z + x; elseif (z <= 8.6e-71) tmp = sin(y) + x; elseif (z <= 1.65e+30) tmp = z + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.26e+48], t$95$0, If[LessEqual[z, -1.8e-10], N[(z + x), $MachinePrecision], If[LessEqual[z, 8.6e-71], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.65e+30], N[(z + x), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y \cdot z\\
\mathbf{if}\;z \leq -1.26 \cdot 10^{+48}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{-10}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 8.6 \cdot 10^{-71}:\\
\;\;\;\;\sin y + x\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+30}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.26000000000000001e48 or 1.65000000000000013e30 < z Initial program 99.9%
lift-+.f64N/A
flip-+N/A
div-invN/A
difference-of-squaresN/A
lift-+.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6481.0
Applied rewrites81.0%
if -1.26000000000000001e48 < z < -1.8e-10 or 8.5999999999999994e-71 < z < 1.65000000000000013e30Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6486.5
Applied rewrites86.5%
if -1.8e-10 < z < 8.5999999999999994e-71Initial program 100.0%
lift-+.f64N/A
flip-+N/A
div-invN/A
difference-of-squaresN/A
lift-+.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6494.6
Applied rewrites94.6%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.26e+48) (not (<= z 1.65e+30))) (* (cos y) z) (fma 1.0 z (+ (sin y) x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.26e+48) || !(z <= 1.65e+30)) {
tmp = cos(y) * z;
} else {
tmp = fma(1.0, z, (sin(y) + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -1.26e+48) || !(z <= 1.65e+30)) tmp = Float64(cos(y) * z); else tmp = fma(1.0, z, Float64(sin(y) + x)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.26e+48], N[Not[LessEqual[z, 1.65e+30]], $MachinePrecision]], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision], N[(1.0 * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.26 \cdot 10^{+48} \lor \neg \left(z \leq 1.65 \cdot 10^{+30}\right):\\
\;\;\;\;\cos y \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\
\end{array}
\end{array}
if z < -1.26000000000000001e48 or 1.65000000000000013e30 < z Initial program 99.9%
lift-+.f64N/A
flip-+N/A
div-invN/A
difference-of-squaresN/A
lift-+.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6481.0
Applied rewrites81.0%
if -1.26000000000000001e48 < z < 1.65000000000000013e30Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites97.7%
Final simplification91.2%
(FPCore (x y z) :precision binary64 (if (<= z -1.26e+48) (* (cos y) z) (if (<= z 1.26e+39) (fma 1.0 z (+ (sin y) x)) (fma (cos y) z (+ x y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.26e+48) {
tmp = cos(y) * z;
} else if (z <= 1.26e+39) {
tmp = fma(1.0, z, (sin(y) + x));
} else {
tmp = fma(cos(y), z, (x + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.26e+48) tmp = Float64(cos(y) * z); elseif (z <= 1.26e+39) tmp = fma(1.0, z, Float64(sin(y) + x)); else tmp = fma(cos(y), z, Float64(x + y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.26e+48], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 1.26e+39], N[(1.0 * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.26 \cdot 10^{+48}:\\
\;\;\;\;\cos y \cdot z\\
\mathbf{elif}\;z \leq 1.26 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, x + y\right)\\
\end{array}
\end{array}
if z < -1.26000000000000001e48Initial program 99.9%
lift-+.f64N/A
flip-+N/A
div-invN/A
difference-of-squaresN/A
lift-+.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6485.3
Applied rewrites85.3%
if -1.26000000000000001e48 < z < 1.26000000000000001e39Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites96.1%
if 1.26000000000000001e39 < z Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6482.3
Applied rewrites82.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6482.3
Applied rewrites82.3%
Final simplification91.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -380000000000.0) (not (<= y 3.5e+17))) (+ (sin y) x) (fma (fma (fma -0.16666666666666666 y (* -0.5 z)) y 1.0) y (+ z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -380000000000.0) || !(y <= 3.5e+17)) {
tmp = sin(y) + x;
} else {
tmp = fma(fma(fma(-0.16666666666666666, y, (-0.5 * z)), y, 1.0), y, (z + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -380000000000.0) || !(y <= 3.5e+17)) tmp = Float64(sin(y) + x); else tmp = fma(fma(fma(-0.16666666666666666, y, Float64(-0.5 * z)), y, 1.0), y, Float64(z + x)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -380000000000.0], N[Not[LessEqual[y, 3.5e+17]], $MachinePrecision]], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(-0.16666666666666666 * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -380000000000 \lor \neg \left(y \leq 3.5 \cdot 10^{+17}\right):\\
\;\;\;\;\sin y + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, z + x\right)\\
\end{array}
\end{array}
if y < -3.8e11 or 3.5e17 < y Initial program 99.9%
lift-+.f64N/A
flip-+N/A
div-invN/A
difference-of-squaresN/A
lift-+.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6463.3
Applied rewrites63.3%
if -3.8e11 < y < 3.5e17Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6497.7
Applied rewrites97.7%
Final simplification79.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -84000000000000.0) (not (<= y 3.2e+21))) (+ z x) (fma (fma (fma -0.16666666666666666 y (* -0.5 z)) y 1.0) y (+ z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -84000000000000.0) || !(y <= 3.2e+21)) {
tmp = z + x;
} else {
tmp = fma(fma(fma(-0.16666666666666666, y, (-0.5 * z)), y, 1.0), y, (z + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -84000000000000.0) || !(y <= 3.2e+21)) tmp = Float64(z + x); else tmp = fma(fma(fma(-0.16666666666666666, y, Float64(-0.5 * z)), y, 1.0), y, Float64(z + x)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -84000000000000.0], N[Not[LessEqual[y, 3.2e+21]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(N[(N[(-0.16666666666666666 * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -84000000000000 \lor \neg \left(y \leq 3.2 \cdot 10^{+21}\right):\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, z + x\right)\\
\end{array}
\end{array}
if y < -8.4e13 or 3.2e21 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6437.3
Applied rewrites37.3%
if -8.4e13 < y < 3.2e21Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6496.2
Applied rewrites96.2%
Final simplification65.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.05e+22) (not (<= y 1.05e+22))) (+ z x) (fma (fma (* -0.5 y) z 1.0) y (+ z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.05e+22) || !(y <= 1.05e+22)) {
tmp = z + x;
} else {
tmp = fma(fma((-0.5 * y), z, 1.0), y, (z + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -1.05e+22) || !(y <= 1.05e+22)) tmp = Float64(z + x); else tmp = fma(fma(Float64(-0.5 * y), z, 1.0), y, Float64(z + x)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.05e+22], N[Not[LessEqual[y, 1.05e+22]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(N[(N[(-0.5 * y), $MachinePrecision] * z + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+22} \lor \neg \left(y \leq 1.05 \cdot 10^{+22}\right):\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.5 \cdot y, z, 1\right), y, z + x\right)\\
\end{array}
\end{array}
if y < -1.0499999999999999e22 or 1.0499999999999999e22 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6437.6
Applied rewrites37.6%
if -1.0499999999999999e22 < y < 1.0499999999999999e22Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6495.3
Applied rewrites95.3%
Final simplification65.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -4e+22) (not (<= y 3.2))) (+ z x) (+ (+ y x) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4e+22) || !(y <= 3.2)) {
tmp = z + x;
} else {
tmp = (y + 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 ((y <= (-4d+22)) .or. (.not. (y <= 3.2d0))) then
tmp = z + x
else
tmp = (y + x) + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4e+22) || !(y <= 3.2)) {
tmp = z + x;
} else {
tmp = (y + x) + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4e+22) or not (y <= 3.2): tmp = z + x else: tmp = (y + x) + z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4e+22) || !(y <= 3.2)) tmp = Float64(z + x); else tmp = Float64(Float64(y + x) + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4e+22) || ~((y <= 3.2))) tmp = z + x; else tmp = (y + x) + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4e+22], N[Not[LessEqual[y, 3.2]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(N[(y + x), $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+22} \lor \neg \left(y \leq 3.2\right):\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) + z\\
\end{array}
\end{array}
if y < -4e22 or 3.2000000000000002 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6436.9
Applied rewrites36.9%
if -4e22 < y < 3.2000000000000002Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6496.5
Applied rewrites96.5%
Final simplification65.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -64000.0) (not (<= x 3e+44))) (+ x y) (+ z y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -64000.0) || !(x <= 3e+44)) {
tmp = x + y;
} else {
tmp = z + 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 ((x <= (-64000.0d0)) .or. (.not. (x <= 3d+44))) then
tmp = x + y
else
tmp = z + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -64000.0) || !(x <= 3e+44)) {
tmp = x + y;
} else {
tmp = z + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -64000.0) or not (x <= 3e+44): tmp = x + y else: tmp = z + y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -64000.0) || !(x <= 3e+44)) tmp = Float64(x + y); else tmp = Float64(z + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -64000.0) || ~((x <= 3e+44))) tmp = x + y; else tmp = z + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -64000.0], N[Not[LessEqual[x, 3e+44]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(z + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -64000 \lor \neg \left(x \leq 3 \cdot 10^{+44}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;z + y\\
\end{array}
\end{array}
if x < -64000 or 2.99999999999999987e44 < x Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6465.5
Applied rewrites65.5%
Taylor expanded in y around inf
Applied rewrites2.7%
Taylor expanded in z around 0
Applied rewrites71.4%
if -64000 < x < 2.99999999999999987e44Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f6489.6
Applied rewrites89.6%
Taylor expanded in y around 0
Applied rewrites38.6%
Final simplification51.3%
(FPCore (x y z) :precision binary64 (+ z x))
double code(double x, double y, double z) {
return 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 = z + x
end function
public static double code(double x, double y, double z) {
return z + x;
}
def code(x, y, z): return z + x
function code(x, y, z) return Float64(z + x) end
function tmp = code(x, y, z) tmp = z + x; end
code[x_, y_, z_] := N[(z + x), $MachinePrecision]
\begin{array}{l}
\\
z + x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6461.1
Applied rewrites61.1%
(FPCore (x y z) :precision binary64 (+ z y))
double code(double x, double y, double z) {
return z + y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z + y
end function
public static double code(double x, double y, double z) {
return z + y;
}
def code(x, y, z): return z + y
function code(x, y, z) return Float64(z + y) end
function tmp = code(x, y, z) tmp = z + y; end
code[x_, y_, z_] := N[(z + y), $MachinePrecision]
\begin{array}{l}
\\
z + y
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f6461.6
Applied rewrites61.6%
Taylor expanded in y around 0
Applied rewrites26.6%
herbie shell --seed 2024318
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
:precision binary64
(+ (+ x (sin y)) (* z (cos y))))