
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(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 + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(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 + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (fma (sin y) (- z) (+ x (cos y))))
double code(double x, double y, double z) {
return fma(sin(y), -z, (x + cos(y)));
}
function code(x, y, z) return fma(sin(y), Float64(-z), Float64(x + cos(y))) end
code[x_, y_, z_] := N[(N[Sin[y], $MachinePrecision] * (-z) + N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin y, -z, x + \cos y\right)
\end{array}
Initial program 99.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (cos y)))
(t_1 (* z (sin y)))
(t_2 (- t_0 t_1))
(t_3 (- (+ 1.0 x) t_1)))
(if (<= t_2 -5000.0) t_3 (if (<= t_2 0.99) (/ 1.0 (/ 1.0 t_0)) t_3))))
double code(double x, double y, double z) {
double t_0 = x + cos(y);
double t_1 = z * sin(y);
double t_2 = t_0 - t_1;
double t_3 = (1.0 + x) - t_1;
double tmp;
if (t_2 <= -5000.0) {
tmp = t_3;
} else if (t_2 <= 0.99) {
tmp = 1.0 / (1.0 / t_0);
} else {
tmp = t_3;
}
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) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = x + cos(y)
t_1 = z * sin(y)
t_2 = t_0 - t_1
t_3 = (1.0d0 + x) - t_1
if (t_2 <= (-5000.0d0)) then
tmp = t_3
else if (t_2 <= 0.99d0) then
tmp = 1.0d0 / (1.0d0 / t_0)
else
tmp = t_3
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x + Math.cos(y);
double t_1 = z * Math.sin(y);
double t_2 = t_0 - t_1;
double t_3 = (1.0 + x) - t_1;
double tmp;
if (t_2 <= -5000.0) {
tmp = t_3;
} else if (t_2 <= 0.99) {
tmp = 1.0 / (1.0 / t_0);
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y, z): t_0 = x + math.cos(y) t_1 = z * math.sin(y) t_2 = t_0 - t_1 t_3 = (1.0 + x) - t_1 tmp = 0 if t_2 <= -5000.0: tmp = t_3 elif t_2 <= 0.99: tmp = 1.0 / (1.0 / t_0) else: tmp = t_3 return tmp
function code(x, y, z) t_0 = Float64(x + cos(y)) t_1 = Float64(z * sin(y)) t_2 = Float64(t_0 - t_1) t_3 = Float64(Float64(1.0 + x) - t_1) tmp = 0.0 if (t_2 <= -5000.0) tmp = t_3; elseif (t_2 <= 0.99) tmp = Float64(1.0 / Float64(1.0 / t_0)); else tmp = t_3; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + cos(y); t_1 = z * sin(y); t_2 = t_0 - t_1; t_3 = (1.0 + x) - t_1; tmp = 0.0; if (t_2 <= -5000.0) tmp = t_3; elseif (t_2 <= 0.99) tmp = 1.0 / (1.0 / t_0); else tmp = t_3; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(1.0 + x), $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -5000.0], t$95$3, If[LessEqual[t$95$2, 0.99], N[(1.0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \cos y\\
t_1 := z \cdot \sin y\\
t_2 := t\_0 - t\_1\\
t_3 := \left(1 + x\right) - t\_1\\
\mathbf{if}\;t\_2 \leq -5000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 0.99:\\
\;\;\;\;\frac{1}{\frac{1}{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -5e3 or 0.98999999999999999 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites99.8%
if -5e3 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.98999999999999999Initial program 100.0%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
inv-powN/A
lower-pow.f6499.6
Applied rewrites99.6%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6497.5
Applied rewrites97.5%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (sin y)))
(t_1 (- (+ x (cos y)) t_0))
(t_2 (- (+ 1.0 x) t_0)))
(if (<= t_1 -500.0) t_2 (if (<= t_1 0.98) (- (cos y) (* z y)) t_2))))
double code(double x, double y, double z) {
double t_0 = z * sin(y);
double t_1 = (x + cos(y)) - t_0;
double t_2 = (1.0 + x) - t_0;
double tmp;
if (t_1 <= -500.0) {
tmp = t_2;
} else if (t_1 <= 0.98) {
tmp = cos(y) - (z * y);
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = z * sin(y)
t_1 = (x + cos(y)) - t_0
t_2 = (1.0d0 + x) - t_0
if (t_1 <= (-500.0d0)) then
tmp = t_2
else if (t_1 <= 0.98d0) then
tmp = cos(y) - (z * y)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.sin(y);
double t_1 = (x + Math.cos(y)) - t_0;
double t_2 = (1.0 + x) - t_0;
double tmp;
if (t_1 <= -500.0) {
tmp = t_2;
} else if (t_1 <= 0.98) {
tmp = Math.cos(y) - (z * y);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.sin(y) t_1 = (x + math.cos(y)) - t_0 t_2 = (1.0 + x) - t_0 tmp = 0 if t_1 <= -500.0: tmp = t_2 elif t_1 <= 0.98: tmp = math.cos(y) - (z * y) else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(z * sin(y)) t_1 = Float64(Float64(x + cos(y)) - t_0) t_2 = Float64(Float64(1.0 + x) - t_0) tmp = 0.0 if (t_1 <= -500.0) tmp = t_2; elseif (t_1 <= 0.98) tmp = Float64(cos(y) - Float64(z * y)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * sin(y); t_1 = (x + cos(y)) - t_0; t_2 = (1.0 + x) - t_0; tmp = 0.0; if (t_1 <= -500.0) tmp = t_2; elseif (t_1 <= 0.98) tmp = cos(y) - (z * y); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 + x), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -500.0], t$95$2, If[LessEqual[t$95$1, 0.98], N[(N[Cos[y], $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \sin y\\
t_1 := \left(x + \cos y\right) - t\_0\\
t_2 := \left(1 + x\right) - t\_0\\
\mathbf{if}\;t\_1 \leq -500:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0.98:\\
\;\;\;\;\cos y - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -500 or 0.97999999999999998 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites99.3%
if -500 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.97999999999999998Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f641.7
Applied rewrites1.7%
Taylor expanded in x around 0
lower-cos.f6444.6
Applied rewrites44.6%
Final simplification93.3%
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(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 + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Initial program 99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ 1.0 x) (* z (sin y)))))
(if (<= z -6.2e-207)
t_0
(if (<= z 1.25e-106) (- (+ x (cos y)) (* z y)) t_0))))
double code(double x, double y, double z) {
double t_0 = (1.0 + x) - (z * sin(y));
double tmp;
if (z <= -6.2e-207) {
tmp = t_0;
} else if (z <= 1.25e-106) {
tmp = (x + cos(y)) - (z * y);
} 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 = (1.0d0 + x) - (z * sin(y))
if (z <= (-6.2d-207)) then
tmp = t_0
else if (z <= 1.25d-106) then
tmp = (x + cos(y)) - (z * y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (1.0 + x) - (z * Math.sin(y));
double tmp;
if (z <= -6.2e-207) {
tmp = t_0;
} else if (z <= 1.25e-106) {
tmp = (x + Math.cos(y)) - (z * y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (1.0 + x) - (z * math.sin(y)) tmp = 0 if z <= -6.2e-207: tmp = t_0 elif z <= 1.25e-106: tmp = (x + math.cos(y)) - (z * y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(1.0 + x) - Float64(z * sin(y))) tmp = 0.0 if (z <= -6.2e-207) tmp = t_0; elseif (z <= 1.25e-106) tmp = Float64(Float64(x + cos(y)) - Float64(z * y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (1.0 + x) - (z * sin(y)); tmp = 0.0; if (z <= -6.2e-207) tmp = t_0; elseif (z <= 1.25e-106) tmp = (x + cos(y)) - (z * y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 + x), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.2e-207], t$95$0, If[LessEqual[z, 1.25e-106], N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + x\right) - z \cdot \sin y\\
\mathbf{if}\;z \leq -6.2 \cdot 10^{-207}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{-106}:\\
\;\;\;\;\left(x + \cos y\right) - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -6.2000000000000003e-207 or 1.24999999999999996e-106 < z Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites94.5%
if -6.2000000000000003e-207 < z < 1.24999999999999996e-106Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6492.1
Applied rewrites92.1%
Final simplification94.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- z) (sin y))))
(if (<= y -0.84)
t_0
(if (<= y 104.0)
(-
(+
(fma
(fma
(fma -0.001388888888888889 (* y y) 0.041666666666666664)
(* y y)
-0.5)
(* y y)
1.0)
x)
(* z y))
t_0))))
double code(double x, double y, double z) {
double t_0 = -z * sin(y);
double tmp;
if (y <= -0.84) {
tmp = t_0;
} else if (y <= 104.0) {
tmp = (fma(fma(fma(-0.001388888888888889, (y * y), 0.041666666666666664), (y * y), -0.5), (y * y), 1.0) + x) - (z * y);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-z) * sin(y)) tmp = 0.0 if (y <= -0.84) tmp = t_0; elseif (y <= 104.0) tmp = Float64(Float64(fma(fma(fma(-0.001388888888888889, Float64(y * y), 0.041666666666666664), Float64(y * y), -0.5), Float64(y * y), 1.0) + x) - Float64(z * y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.84], t$95$0, If[LessEqual[y, 104.0], N[(N[(N[(N[(N[(-0.001388888888888889 * N[(y * y), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(y * y), $MachinePrecision] + -0.5), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] + x), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-z\right) \cdot \sin y\\
\mathbf{if}\;y \leq -0.84:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 104:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, y \cdot y, 0.041666666666666664\right), y \cdot y, -0.5\right), y \cdot y, 1\right) + x\right) - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.839999999999999969 or 104 < y Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6447.7
Applied rewrites47.7%
if -0.839999999999999969 < y < 104Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification74.8%
(FPCore (x y z)
:precision binary64
(if (<= y -150000.0)
(+ 1.0 x)
(if (<= y 325000000000.0)
(-
(+
(fma
(fma
(fma -0.001388888888888889 (* y y) 0.041666666666666664)
(* y y)
-0.5)
(* y y)
1.0)
x)
(* z y))
(+ 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -150000.0) {
tmp = 1.0 + x;
} else if (y <= 325000000000.0) {
tmp = (fma(fma(fma(-0.001388888888888889, (y * y), 0.041666666666666664), (y * y), -0.5), (y * y), 1.0) + x) - (z * y);
} else {
tmp = 1.0 + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -150000.0) tmp = Float64(1.0 + x); elseif (y <= 325000000000.0) tmp = Float64(Float64(fma(fma(fma(-0.001388888888888889, Float64(y * y), 0.041666666666666664), Float64(y * y), -0.5), Float64(y * y), 1.0) + x) - Float64(z * y)); else tmp = Float64(1.0 + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -150000.0], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, 325000000000.0], N[(N[(N[(N[(N[(-0.001388888888888889 * N[(y * y), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(y * y), $MachinePrecision] + -0.5), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] + x), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -150000:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq 325000000000:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, y \cdot y, 0.041666666666666664\right), y \cdot y, -0.5\right), y \cdot y, 1\right) + x\right) - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if y < -1.5e5 or 3.25e11 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6435.4
Applied rewrites35.4%
if -1.5e5 < y < 3.25e11Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6497.4
Applied rewrites97.4%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.8
Applied rewrites96.8%
Final simplification68.5%
(FPCore (x y z)
:precision binary64
(if (<= y -45000000000.0)
(+ 1.0 x)
(if (<= y 95000000000.0)
(-
(+ (fma (fma 0.041666666666666664 (* y y) -0.5) (* y y) 1.0) x)
(* z y))
(+ 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -45000000000.0) {
tmp = 1.0 + x;
} else if (y <= 95000000000.0) {
tmp = (fma(fma(0.041666666666666664, (y * y), -0.5), (y * y), 1.0) + x) - (z * y);
} else {
tmp = 1.0 + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -45000000000.0) tmp = Float64(1.0 + x); elseif (y <= 95000000000.0) tmp = Float64(Float64(fma(fma(0.041666666666666664, Float64(y * y), -0.5), Float64(y * y), 1.0) + x) - Float64(z * y)); else tmp = Float64(1.0 + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -45000000000.0], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, 95000000000.0], N[(N[(N[(N[(0.041666666666666664 * N[(y * y), $MachinePrecision] + -0.5), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] + x), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -45000000000:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq 95000000000:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, y \cdot y, -0.5\right), y \cdot y, 1\right) + x\right) - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if y < -4.5e10 or 9.5e10 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6435.1
Applied rewrites35.1%
if -4.5e10 < y < 9.5e10Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6497.4
Applied rewrites97.4%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.4
Applied rewrites97.4%
Final simplification68.4%
(FPCore (x y z) :precision binary64 (if (<= y -66000000000.0) (+ 1.0 x) (if (<= y 325000000000.0) (fma (- (* -0.5 y) z) y (+ 1.0 x)) (+ 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -66000000000.0) {
tmp = 1.0 + x;
} else if (y <= 325000000000.0) {
tmp = fma(((-0.5 * y) - z), y, (1.0 + x));
} else {
tmp = 1.0 + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -66000000000.0) tmp = Float64(1.0 + x); elseif (y <= 325000000000.0) tmp = fma(Float64(Float64(-0.5 * y) - z), y, Float64(1.0 + x)); else tmp = Float64(1.0 + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -66000000000.0], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, 325000000000.0], N[(N[(N[(-0.5 * y), $MachinePrecision] - z), $MachinePrecision] * y + N[(1.0 + x), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -66000000000:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq 325000000000:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot y - z, y, 1 + x\right)\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if y < -6.6e10 or 3.25e11 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6435.4
Applied rewrites35.4%
if -6.6e10 < y < 3.25e11Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6496.6
Applied rewrites96.6%
(FPCore (x y z) :precision binary64 (if (<= y -4.7e+102) (+ 1.0 x) (if (<= y 2.3e+125) (fma (- z) y (+ 1.0 x)) (+ 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.7e+102) {
tmp = 1.0 + x;
} else if (y <= 2.3e+125) {
tmp = fma(-z, y, (1.0 + x));
} else {
tmp = 1.0 + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -4.7e+102) tmp = Float64(1.0 + x); elseif (y <= 2.3e+125) tmp = fma(Float64(-z), y, Float64(1.0 + x)); else tmp = Float64(1.0 + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -4.7e+102], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, 2.3e+125], N[((-z) * y + N[(1.0 + x), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+102}:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+125}:\\
\;\;\;\;\mathsf{fma}\left(-z, y, 1 + x\right)\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if y < -4.7000000000000003e102 or 2.30000000000000013e125 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6436.5
Applied rewrites36.5%
if -4.7000000000000003e102 < y < 2.30000000000000013e125Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6480.5
Applied rewrites80.5%
Taylor expanded in y around 0
Applied rewrites84.4%
(FPCore (x y z) :precision binary64 (if (<= y -4.7e+102) (+ 1.0 x) (if (<= y 2.3e+125) (- x (fma z y -1.0)) (+ 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.7e+102) {
tmp = 1.0 + x;
} else if (y <= 2.3e+125) {
tmp = x - fma(z, y, -1.0);
} else {
tmp = 1.0 + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -4.7e+102) tmp = Float64(1.0 + x); elseif (y <= 2.3e+125) tmp = Float64(x - fma(z, y, -1.0)); else tmp = Float64(1.0 + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -4.7e+102], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, 2.3e+125], N[(x - N[(z * y + -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+102}:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+125}:\\
\;\;\;\;x - \mathsf{fma}\left(z, y, -1\right)\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if y < -4.7000000000000003e102 or 2.30000000000000013e125 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6436.5
Applied rewrites36.5%
if -4.7000000000000003e102 < y < 2.30000000000000013e125Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
lower--.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6484.4
Applied rewrites84.4%
(FPCore (x y z) :precision binary64 (if (<= x -1.65e-162) (+ 1.0 x) (if (<= x 2.25e+17) (- 1.0 (* z y)) (+ 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.65e-162) {
tmp = 1.0 + x;
} else if (x <= 2.25e+17) {
tmp = 1.0 - (z * y);
} else {
tmp = 1.0 + 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 (x <= (-1.65d-162)) then
tmp = 1.0d0 + x
else if (x <= 2.25d+17) then
tmp = 1.0d0 - (z * y)
else
tmp = 1.0d0 + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.65e-162) {
tmp = 1.0 + x;
} else if (x <= 2.25e+17) {
tmp = 1.0 - (z * y);
} else {
tmp = 1.0 + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.65e-162: tmp = 1.0 + x elif x <= 2.25e+17: tmp = 1.0 - (z * y) else: tmp = 1.0 + x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.65e-162) tmp = Float64(1.0 + x); elseif (x <= 2.25e+17) tmp = Float64(1.0 - Float64(z * y)); else tmp = Float64(1.0 + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.65e-162) tmp = 1.0 + x; elseif (x <= 2.25e+17) tmp = 1.0 - (z * y); else tmp = 1.0 + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.65e-162], N[(1.0 + x), $MachinePrecision], If[LessEqual[x, 2.25e+17], N[(1.0 - N[(z * y), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.65 \cdot 10^{-162}:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{+17}:\\
\;\;\;\;1 - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if x < -1.65000000000000007e-162 or 2.25e17 < x Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6472.9
Applied rewrites72.9%
if -1.65000000000000007e-162 < x < 2.25e17Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6463.9
Applied rewrites63.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.1
Applied rewrites56.1%
Taylor expanded in x around 0
lower-cos.f6463.0
Applied rewrites63.0%
Taylor expanded in y around 0
Applied rewrites57.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- y) z))) (if (<= z -4.6e+139) t_0 (if (<= z 2.05e+208) (+ 1.0 x) t_0))))
double code(double x, double y, double z) {
double t_0 = -y * z;
double tmp;
if (z <= -4.6e+139) {
tmp = t_0;
} else if (z <= 2.05e+208) {
tmp = 1.0 + 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 = -y * z
if (z <= (-4.6d+139)) then
tmp = t_0
else if (z <= 2.05d+208) then
tmp = 1.0d0 + x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -y * z;
double tmp;
if (z <= -4.6e+139) {
tmp = t_0;
} else if (z <= 2.05e+208) {
tmp = 1.0 + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -y * z tmp = 0 if z <= -4.6e+139: tmp = t_0 elif z <= 2.05e+208: tmp = 1.0 + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-y) * z) tmp = 0.0 if (z <= -4.6e+139) tmp = t_0; elseif (z <= 2.05e+208) tmp = Float64(1.0 + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -y * z; tmp = 0.0; if (z <= -4.6e+139) tmp = t_0; elseif (z <= 2.05e+208) tmp = 1.0 + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-y) * z), $MachinePrecision]}, If[LessEqual[z, -4.6e+139], t$95$0, If[LessEqual[z, 2.05e+208], N[(1.0 + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-y\right) \cdot z\\
\mathbf{if}\;z \leq -4.6 \cdot 10^{+139}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.05 \cdot 10^{+208}:\\
\;\;\;\;1 + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.6e139 or 2.0499999999999999e208 < z Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
lower--.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6452.7
Applied rewrites52.7%
Taylor expanded in y around inf
Applied rewrites34.8%
if -4.6e139 < z < 2.0499999999999999e208Initial program 100.0%
Taylor expanded in y around 0
lower-+.f6468.4
Applied rewrites68.4%
(FPCore (x y z) :precision binary64 (+ 1.0 x))
double code(double x, double y, double z) {
return 1.0 + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + x
end function
public static double code(double x, double y, double z) {
return 1.0 + x;
}
def code(x, y, z): return 1.0 + x
function code(x, y, z) return Float64(1.0 + x) end
function tmp = code(x, y, z) tmp = 1.0 + x; end
code[x_, y_, z_] := N[(1.0 + x), $MachinePrecision]
\begin{array}{l}
\\
1 + x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6455.7
Applied rewrites55.7%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6455.7
Applied rewrites55.7%
Taylor expanded in x around 0
Applied rewrites19.4%
herbie shell --seed 2024294
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, B"
:precision binary64
(- (+ x (cos y)) (* z (sin y))))