
(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 11 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 (+ x (sin y))))
double code(double x, double y, double z) {
return fma(cos(y), z, (x + sin(y)));
}
function code(x, y, z) return fma(cos(y), z, Float64(x + sin(y))) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos y, z, x + \sin y\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%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* z (cos y)) (+ x (sin y)))))
(if (<= t_0 -5000000.0)
(+ x z)
(if (<= t_0 -0.05)
(sin y)
(if (<= t_0 5e-21) (+ (+ x y) z) (if (<= t_0 1.0) (sin y) (+ x z)))))))
double code(double x, double y, double z) {
double t_0 = (z * cos(y)) + (x + sin(y));
double tmp;
if (t_0 <= -5000000.0) {
tmp = x + z;
} else if (t_0 <= -0.05) {
tmp = sin(y);
} else if (t_0 <= 5e-21) {
tmp = (x + y) + z;
} else if (t_0 <= 1.0) {
tmp = sin(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) :: t_0
real(8) :: tmp
t_0 = (z * cos(y)) + (x + sin(y))
if (t_0 <= (-5000000.0d0)) then
tmp = x + z
else if (t_0 <= (-0.05d0)) then
tmp = sin(y)
else if (t_0 <= 5d-21) then
tmp = (x + y) + z
else if (t_0 <= 1.0d0) then
tmp = sin(y)
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z * Math.cos(y)) + (x + Math.sin(y));
double tmp;
if (t_0 <= -5000000.0) {
tmp = x + z;
} else if (t_0 <= -0.05) {
tmp = Math.sin(y);
} else if (t_0 <= 5e-21) {
tmp = (x + y) + z;
} else if (t_0 <= 1.0) {
tmp = Math.sin(y);
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): t_0 = (z * math.cos(y)) + (x + math.sin(y)) tmp = 0 if t_0 <= -5000000.0: tmp = x + z elif t_0 <= -0.05: tmp = math.sin(y) elif t_0 <= 5e-21: tmp = (x + y) + z elif t_0 <= 1.0: tmp = math.sin(y) else: tmp = x + z return tmp
function code(x, y, z) t_0 = Float64(Float64(z * cos(y)) + Float64(x + sin(y))) tmp = 0.0 if (t_0 <= -5000000.0) tmp = Float64(x + z); elseif (t_0 <= -0.05) tmp = sin(y); elseif (t_0 <= 5e-21) tmp = Float64(Float64(x + y) + z); elseif (t_0 <= 1.0) tmp = sin(y); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * cos(y)) + (x + sin(y)); tmp = 0.0; if (t_0 <= -5000000.0) tmp = x + z; elseif (t_0 <= -0.05) tmp = sin(y); elseif (t_0 <= 5e-21) tmp = (x + y) + z; elseif (t_0 <= 1.0) tmp = sin(y); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5000000.0], N[(x + z), $MachinePrecision], If[LessEqual[t$95$0, -0.05], N[Sin[y], $MachinePrecision], If[LessEqual[t$95$0, 5e-21], N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[Sin[y], $MachinePrecision], N[(x + z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y + \left(x + \sin y\right)\\
\mathbf{if}\;t\_0 \leq -5000000:\\
\;\;\;\;x + z\\
\mathbf{elif}\;t\_0 \leq -0.05:\\
\;\;\;\;\sin y\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\left(x + y\right) + z\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin y\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -5e6 or 1 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6473.4
Applied rewrites73.4%
if -5e6 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.050000000000000003 or 4.99999999999999973e-21 < (+.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.f6497.7
Applied rewrites97.7%
Taylor expanded in z around 0
Applied rewrites96.6%
if -0.050000000000000003 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 4.99999999999999973e-21Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Final simplification78.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (* z (cos y)) (+ x (sin y))))) (if (<= t_0 -1e-45) (+ x z) (if (<= t_0 2e-111) (+ x y) (+ x z)))))
double code(double x, double y, double z) {
double t_0 = (z * cos(y)) + (x + sin(y));
double tmp;
if (t_0 <= -1e-45) {
tmp = x + z;
} else if (t_0 <= 2e-111) {
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) :: t_0
real(8) :: tmp
t_0 = (z * cos(y)) + (x + sin(y))
if (t_0 <= (-1d-45)) then
tmp = x + z
else if (t_0 <= 2d-111) 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 t_0 = (z * Math.cos(y)) + (x + Math.sin(y));
double tmp;
if (t_0 <= -1e-45) {
tmp = x + z;
} else if (t_0 <= 2e-111) {
tmp = x + y;
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): t_0 = (z * math.cos(y)) + (x + math.sin(y)) tmp = 0 if t_0 <= -1e-45: tmp = x + z elif t_0 <= 2e-111: tmp = x + y else: tmp = x + z return tmp
function code(x, y, z) t_0 = Float64(Float64(z * cos(y)) + Float64(x + sin(y))) tmp = 0.0 if (t_0 <= -1e-45) tmp = Float64(x + z); elseif (t_0 <= 2e-111) tmp = Float64(x + y); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * cos(y)) + (x + sin(y)); tmp = 0.0; if (t_0 <= -1e-45) tmp = x + z; elseif (t_0 <= 2e-111) tmp = x + y; else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-45], N[(x + z), $MachinePrecision], If[LessEqual[t$95$0, 2e-111], N[(x + y), $MachinePrecision], N[(x + z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y + \left(x + \sin y\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-45}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-111}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -9.99999999999999984e-46 or 2.00000000000000018e-111 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6465.9
Applied rewrites65.9%
if -9.99999999999999984e-46 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 2.00000000000000018e-111Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6487.2
Applied rewrites87.2%
Taylor expanded in y around 0
Applied rewrites87.2%
Final simplification67.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- (/ (* z (cos y)) x) -1.0) x))) (if (<= x -1.8e-43) t_0 (if (<= x 1.9e-21) (fma (cos y) z (sin y)) t_0))))
double code(double x, double y, double z) {
double t_0 = (((z * cos(y)) / x) - -1.0) * x;
double tmp;
if (x <= -1.8e-43) {
tmp = t_0;
} else if (x <= 1.9e-21) {
tmp = fma(cos(y), z, sin(y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(z * cos(y)) / x) - -1.0) * x) tmp = 0.0 if (x <= -1.8e-43) tmp = t_0; elseif (x <= 1.9e-21) tmp = fma(cos(y), z, sin(y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - -1.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -1.8e-43], t$95$0, If[LessEqual[x, 1.9e-21], N[(N[Cos[y], $MachinePrecision] * z + N[Sin[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{z \cdot \cos y}{x} - -1\right) \cdot x\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{-43}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, \sin y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.7999999999999999e-43 or 1.8999999999999999e-21 < x Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6469.2
Applied rewrites69.2%
Taylor expanded in y around 0
Applied rewrites52.7%
Taylor expanded in x around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
Applied rewrites98.5%
if -1.7999999999999999e-43 < x < 1.8999999999999999e-21Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f6495.8
Applied rewrites95.8%
Final simplification97.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -5.4e+17)
t_0
(if (<= z 2e-94) (+ x (sin y)) (if (<= z 3e+129) (+ x z) t_0)))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -5.4e+17) {
tmp = t_0;
} else if (z <= 2e-94) {
tmp = x + sin(y);
} else if (z <= 3e+129) {
tmp = x + 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 = z * cos(y)
if (z <= (-5.4d+17)) then
tmp = t_0
else if (z <= 2d-94) then
tmp = x + sin(y)
else if (z <= 3d+129) then
tmp = x + z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.cos(y);
double tmp;
if (z <= -5.4e+17) {
tmp = t_0;
} else if (z <= 2e-94) {
tmp = x + Math.sin(y);
} else if (z <= 3e+129) {
tmp = x + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -5.4e+17: tmp = t_0 elif z <= 2e-94: tmp = x + math.sin(y) elif z <= 3e+129: tmp = x + z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -5.4e+17) tmp = t_0; elseif (z <= 2e-94) tmp = Float64(x + sin(y)); elseif (z <= 3e+129) tmp = Float64(x + z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -5.4e+17) tmp = t_0; elseif (z <= 2e-94) tmp = x + sin(y); elseif (z <= 3e+129) tmp = x + z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.4e+17], t$95$0, If[LessEqual[z, 2e-94], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3e+129], N[(x + z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -5.4 \cdot 10^{+17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-94}:\\
\;\;\;\;x + \sin y\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+129}:\\
\;\;\;\;x + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -5.4e17 or 3.0000000000000003e129 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6485.1
Applied rewrites85.1%
if -5.4e17 < z < 1.9999999999999999e-94Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
if 1.9999999999999999e-94 < z < 3.0000000000000003e129Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6480.0
Applied rewrites80.0%
Final simplification87.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -1.95e+19)
t_0
(if (<= z 3e+129) (+ (* 1.0 z) (+ x (sin y))) t_0))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -1.95e+19) {
tmp = t_0;
} else if (z <= 3e+129) {
tmp = (1.0 * z) + (x + sin(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 = z * cos(y)
if (z <= (-1.95d+19)) then
tmp = t_0
else if (z <= 3d+129) then
tmp = (1.0d0 * z) + (x + sin(y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.cos(y);
double tmp;
if (z <= -1.95e+19) {
tmp = t_0;
} else if (z <= 3e+129) {
tmp = (1.0 * z) + (x + Math.sin(y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -1.95e+19: tmp = t_0 elif z <= 3e+129: tmp = (1.0 * z) + (x + math.sin(y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -1.95e+19) tmp = t_0; elseif (z <= 3e+129) tmp = Float64(Float64(1.0 * z) + Float64(x + sin(y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -1.95e+19) tmp = t_0; elseif (z <= 3e+129) tmp = (1.0 * z) + (x + sin(y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.95e+19], t$95$0, If[LessEqual[z, 3e+129], N[(N[(1.0 * z), $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -1.95 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+129}:\\
\;\;\;\;1 \cdot z + \left(x + \sin y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.95e19 or 3.0000000000000003e129 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6485.4
Applied rewrites85.4%
if -1.95e19 < z < 3.0000000000000003e129Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites95.2%
Final simplification91.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ x (sin y)))) (if (<= y -48000000.0) t_0 (if (<= y 25500.0) (+ (+ x y) z) t_0))))
double code(double x, double y, double z) {
double t_0 = x + sin(y);
double tmp;
if (y <= -48000000.0) {
tmp = t_0;
} else if (y <= 25500.0) {
tmp = (x + y) + 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 + sin(y)
if (y <= (-48000000.0d0)) then
tmp = t_0
else if (y <= 25500.0d0) then
tmp = (x + y) + 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 + Math.sin(y);
double tmp;
if (y <= -48000000.0) {
tmp = t_0;
} else if (y <= 25500.0) {
tmp = (x + y) + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x + math.sin(y) tmp = 0 if y <= -48000000.0: tmp = t_0 elif y <= 25500.0: tmp = (x + y) + z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x + sin(y)) tmp = 0.0 if (y <= -48000000.0) tmp = t_0; elseif (y <= 25500.0) tmp = Float64(Float64(x + y) + z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + sin(y); tmp = 0.0; if (y <= -48000000.0) tmp = t_0; elseif (y <= 25500.0) tmp = (x + y) + z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -48000000.0], t$95$0, If[LessEqual[y, 25500.0], N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \sin y\\
\mathbf{if}\;y \leq -48000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 25500:\\
\;\;\;\;\left(x + y\right) + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.8e7 or 25500 < y Initial program 99.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6458.1
Applied rewrites58.1%
if -4.8e7 < y < 25500Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6497.3
Applied rewrites97.3%
Final simplification78.2%
(FPCore (x y z) :precision binary64 (if (<= y -22000000.0) (+ x z) (if (<= y 280.0) (fma (fma (* -0.5 y) z 1.0) y (+ x z)) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -22000000.0) {
tmp = x + z;
} else if (y <= 280.0) {
tmp = fma(fma((-0.5 * y), z, 1.0), y, (x + z));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -22000000.0) tmp = Float64(x + z); elseif (y <= 280.0) tmp = fma(fma(Float64(-0.5 * y), z, 1.0), y, Float64(x + z)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -22000000.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 280.0], N[(N[(N[(-0.5 * y), $MachinePrecision] * z + 1.0), $MachinePrecision] * y + N[(x + z), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -22000000:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 280:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.5 \cdot y, z, 1\right), y, x + z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -2.2e7 or 280 < y Initial program 99.7%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6437.2
Applied rewrites37.2%
if -2.2e7 < y < 280Initial 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-+.f6499.3
Applied rewrites99.3%
Final simplification68.3%
(FPCore (x y z) :precision binary64 (if (<= y -27000000.0) (+ x z) (if (<= y 1.3e+67) (+ (+ x y) z) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -27000000.0) {
tmp = x + z;
} else if (y <= 1.3e+67) {
tmp = (x + y) + 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 (y <= (-27000000.0d0)) then
tmp = x + z
else if (y <= 1.3d+67) then
tmp = (x + y) + z
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -27000000.0) {
tmp = x + z;
} else if (y <= 1.3e+67) {
tmp = (x + y) + z;
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -27000000.0: tmp = x + z elif y <= 1.3e+67: tmp = (x + y) + z else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -27000000.0) tmp = Float64(x + z); elseif (y <= 1.3e+67) tmp = Float64(Float64(x + y) + z); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -27000000.0) tmp = x + z; elseif (y <= 1.3e+67) tmp = (x + y) + z; else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -27000000.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 1.3e+67], N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -27000000:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+67}:\\
\;\;\;\;\left(x + y\right) + z\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -2.7e7 or 1.3e67 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6436.2
Applied rewrites36.2%
if -2.7e7 < y < 1.3e67Initial program 99.9%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6494.8
Applied rewrites94.8%
Final simplification68.2%
(FPCore (x y z) :precision binary64 (if (<= x -1.7e+149) (+ x y) (if (<= x 1.5e-22) (+ z y) (+ x y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.7e+149) {
tmp = x + y;
} else if (x <= 1.5e-22) {
tmp = z + y;
} else {
tmp = x + 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 <= (-1.7d+149)) then
tmp = x + y
else if (x <= 1.5d-22) then
tmp = z + y
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.7e+149) {
tmp = x + y;
} else if (x <= 1.5e-22) {
tmp = z + y;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.7e+149: tmp = x + y elif x <= 1.5e-22: tmp = z + y else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.7e+149) tmp = Float64(x + y); elseif (x <= 1.5e-22) tmp = Float64(z + y); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.7e+149) tmp = x + y; elseif (x <= 1.5e-22) tmp = z + y; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.7e+149], N[(x + y), $MachinePrecision], If[LessEqual[x, 1.5e-22], N[(z + y), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+149}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-22}:\\
\;\;\;\;z + y\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if x < -1.6999999999999999e149 or 1.5e-22 < x Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6479.1
Applied rewrites79.1%
Taylor expanded in y around 0
Applied rewrites64.4%
if -1.6999999999999999e149 < x < 1.5e-22Initial program 99.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f6487.3
Applied rewrites87.3%
Taylor expanded in y around 0
Applied rewrites41.3%
Final simplification50.8%
(FPCore (x y z) :precision binary64 (+ x y))
double code(double x, double y, double z) {
return 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 + y
end function
public static double code(double x, double y, double z) {
return x + y;
}
def code(x, y, z): return x + y
function code(x, y, z) return Float64(x + y) end
function tmp = code(x, y, z) tmp = x + y; end
code[x_, y_, z_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6456.1
Applied rewrites56.1%
Taylor expanded in y around 0
Applied rewrites36.2%
Final simplification36.2%
herbie shell --seed 2024243
(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))))