
(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 17 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%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f64N/A
+-lowering-+.f64N/A
cos-lowering-cos.f6499.9
Applied egg-rr99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ x (cos y)) (* (sin y) z))) (t_1 (- x (fma y z -1.0))))
(if (<= t_0 -1000.0)
t_1
(if (<= t_0 0.9999999999999998)
(cos y)
(if (<= t_0 1e+202) t_1 (+ x 1.0))))))
double code(double x, double y, double z) {
double t_0 = (x + cos(y)) - (sin(y) * z);
double t_1 = x - fma(y, z, -1.0);
double tmp;
if (t_0 <= -1000.0) {
tmp = t_1;
} else if (t_0 <= 0.9999999999999998) {
tmp = cos(y);
} else if (t_0 <= 1e+202) {
tmp = t_1;
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x + cos(y)) - Float64(sin(y) * z)) t_1 = Float64(x - fma(y, z, -1.0)) tmp = 0.0 if (t_0 <= -1000.0) tmp = t_1; elseif (t_0 <= 0.9999999999999998) tmp = cos(y); elseif (t_0 <= 1e+202) tmp = t_1; else tmp = Float64(x + 1.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x - N[(y * z + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1000.0], t$95$1, If[LessEqual[t$95$0, 0.9999999999999998], N[Cos[y], $MachinePrecision], If[LessEqual[t$95$0, 1e+202], t$95$1, N[(x + 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \cos y\right) - \sin y \cdot z\\
t_1 := x - \mathsf{fma}\left(y, z, -1\right)\\
\mathbf{if}\;t\_0 \leq -1000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.9999999999999998:\\
\;\;\;\;\cos y\\
\mathbf{elif}\;t\_0 \leq 10^{+202}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -1e3 or 0.99999999999999978 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 9.999999999999999e201Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
--lowering--.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f6478.1
Simplified78.1%
if -1e3 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.99999999999999978Initial program 99.9%
Taylor expanded in x around 0
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f6497.0
Simplified97.0%
Taylor expanded in z around 0
cos-lowering-cos.f6494.9
Simplified94.9%
if 9.999999999999999e201 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-lowering-+.f6472.1
Simplified72.1%
Final simplification80.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (sin y) z))
(t_1 (- (+ x (cos y)) t_0))
(t_2 (- (+ x 1.0) t_0)))
(if (<= t_1 -4000000000000.0)
t_2
(if (<= t_1 0.9999999999999998) (fma (sin y) (- z) (cos y)) t_2))))
double code(double x, double y, double z) {
double t_0 = sin(y) * z;
double t_1 = (x + cos(y)) - t_0;
double t_2 = (x + 1.0) - t_0;
double tmp;
if (t_1 <= -4000000000000.0) {
tmp = t_2;
} else if (t_1 <= 0.9999999999999998) {
tmp = fma(sin(y), -z, cos(y));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(sin(y) * z) t_1 = Float64(Float64(x + cos(y)) - t_0) t_2 = Float64(Float64(x + 1.0) - t_0) tmp = 0.0 if (t_1 <= -4000000000000.0) tmp = t_2; elseif (t_1 <= 0.9999999999999998) tmp = fma(sin(y), Float64(-z), cos(y)); else tmp = t_2; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -4000000000000.0], t$95$2, If[LessEqual[t$95$1, 0.9999999999999998], N[(N[Sin[y], $MachinePrecision] * (-z) + N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin y \cdot z\\
t_1 := \left(x + \cos y\right) - t\_0\\
t_2 := \left(x + 1\right) - t\_0\\
\mathbf{if}\;t\_1 \leq -4000000000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0.9999999999999998:\\
\;\;\;\;\mathsf{fma}\left(\sin y, -z, \cos y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -4e12 or 0.99999999999999978 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
+-lowering-+.f6499.9
Simplified99.9%
if -4e12 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.99999999999999978Initial program 99.9%
Taylor expanded in x around 0
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f6497.2
Simplified97.2%
cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f64N/A
cos-lowering-cos.f6497.2
Applied egg-rr97.2%
Final simplification99.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (sin y) z))
(t_1 (- (+ x (cos y)) t_0))
(t_2 (- (+ x 1.0) t_0)))
(if (<= t_1 -4000000000000.0)
t_2
(if (<= t_1 0.9999999999999998) (- (cos y) t_0) t_2))))
double code(double x, double y, double z) {
double t_0 = sin(y) * z;
double t_1 = (x + cos(y)) - t_0;
double t_2 = (x + 1.0) - t_0;
double tmp;
if (t_1 <= -4000000000000.0) {
tmp = t_2;
} else if (t_1 <= 0.9999999999999998) {
tmp = cos(y) - t_0;
} 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 = sin(y) * z
t_1 = (x + cos(y)) - t_0
t_2 = (x + 1.0d0) - t_0
if (t_1 <= (-4000000000000.0d0)) then
tmp = t_2
else if (t_1 <= 0.9999999999999998d0) then
tmp = cos(y) - t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.sin(y) * z;
double t_1 = (x + Math.cos(y)) - t_0;
double t_2 = (x + 1.0) - t_0;
double tmp;
if (t_1 <= -4000000000000.0) {
tmp = t_2;
} else if (t_1 <= 0.9999999999999998) {
tmp = Math.cos(y) - t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) * z t_1 = (x + math.cos(y)) - t_0 t_2 = (x + 1.0) - t_0 tmp = 0 if t_1 <= -4000000000000.0: tmp = t_2 elif t_1 <= 0.9999999999999998: tmp = math.cos(y) - t_0 else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(sin(y) * z) t_1 = Float64(Float64(x + cos(y)) - t_0) t_2 = Float64(Float64(x + 1.0) - t_0) tmp = 0.0 if (t_1 <= -4000000000000.0) tmp = t_2; elseif (t_1 <= 0.9999999999999998) tmp = Float64(cos(y) - t_0); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) * z; t_1 = (x + cos(y)) - t_0; t_2 = (x + 1.0) - t_0; tmp = 0.0; if (t_1 <= -4000000000000.0) tmp = t_2; elseif (t_1 <= 0.9999999999999998) tmp = cos(y) - t_0; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -4000000000000.0], t$95$2, If[LessEqual[t$95$1, 0.9999999999999998], N[(N[Cos[y], $MachinePrecision] - t$95$0), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin y \cdot z\\
t_1 := \left(x + \cos y\right) - t\_0\\
t_2 := \left(x + 1\right) - t\_0\\
\mathbf{if}\;t\_1 \leq -4000000000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0.9999999999999998:\\
\;\;\;\;\cos y - t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -4e12 or 0.99999999999999978 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
+-lowering-+.f6499.9
Simplified99.9%
if -4e12 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.99999999999999978Initial program 99.9%
Taylor expanded in x around 0
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f6497.2
Simplified97.2%
Final simplification99.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (cos y)))
(t_1 (* (sin y) z))
(t_2 (- t_0 t_1))
(t_3 (- (+ x 1.0) t_1)))
(if (<= t_2 -1000.0) t_3 (if (<= t_2 0.9999999999999998) t_0 t_3))))
double code(double x, double y, double z) {
double t_0 = x + cos(y);
double t_1 = sin(y) * z;
double t_2 = t_0 - t_1;
double t_3 = (x + 1.0) - t_1;
double tmp;
if (t_2 <= -1000.0) {
tmp = t_3;
} else if (t_2 <= 0.9999999999999998) {
tmp = 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 = sin(y) * z
t_2 = t_0 - t_1
t_3 = (x + 1.0d0) - t_1
if (t_2 <= (-1000.0d0)) then
tmp = t_3
else if (t_2 <= 0.9999999999999998d0) then
tmp = 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 = Math.sin(y) * z;
double t_2 = t_0 - t_1;
double t_3 = (x + 1.0) - t_1;
double tmp;
if (t_2 <= -1000.0) {
tmp = t_3;
} else if (t_2 <= 0.9999999999999998) {
tmp = t_0;
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y, z): t_0 = x + math.cos(y) t_1 = math.sin(y) * z t_2 = t_0 - t_1 t_3 = (x + 1.0) - t_1 tmp = 0 if t_2 <= -1000.0: tmp = t_3 elif t_2 <= 0.9999999999999998: tmp = t_0 else: tmp = t_3 return tmp
function code(x, y, z) t_0 = Float64(x + cos(y)) t_1 = Float64(sin(y) * z) t_2 = Float64(t_0 - t_1) t_3 = Float64(Float64(x + 1.0) - t_1) tmp = 0.0 if (t_2 <= -1000.0) tmp = t_3; elseif (t_2 <= 0.9999999999999998) tmp = t_0; else tmp = t_3; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + cos(y); t_1 = sin(y) * z; t_2 = t_0 - t_1; t_3 = (x + 1.0) - t_1; tmp = 0.0; if (t_2 <= -1000.0) tmp = t_3; elseif (t_2 <= 0.9999999999999998) tmp = 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[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x + 1.0), $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -1000.0], t$95$3, If[LessEqual[t$95$2, 0.9999999999999998], t$95$0, t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \cos y\\
t_1 := \sin y \cdot z\\
t_2 := t\_0 - t\_1\\
t_3 := \left(x + 1\right) - t\_1\\
\mathbf{if}\;t\_2 \leq -1000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 0.9999999999999998:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -1e3 or 0.99999999999999978 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
+-lowering-+.f6499.5
Simplified99.5%
if -1e3 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.99999999999999978Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
+-lowering-+.f64N/A
cos-lowering-cos.f6497.8
Simplified97.8%
Final simplification99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (cos y)))
(t_1 (* (sin y) z))
(t_2 (- t_0 t_1))
(t_3 (- x t_1)))
(if (<= t_2 -1000.0) t_3 (if (<= t_2 400000.0) t_0 t_3))))
double code(double x, double y, double z) {
double t_0 = x + cos(y);
double t_1 = sin(y) * z;
double t_2 = t_0 - t_1;
double t_3 = x - t_1;
double tmp;
if (t_2 <= -1000.0) {
tmp = t_3;
} else if (t_2 <= 400000.0) {
tmp = 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 = sin(y) * z
t_2 = t_0 - t_1
t_3 = x - t_1
if (t_2 <= (-1000.0d0)) then
tmp = t_3
else if (t_2 <= 400000.0d0) then
tmp = 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 = Math.sin(y) * z;
double t_2 = t_0 - t_1;
double t_3 = x - t_1;
double tmp;
if (t_2 <= -1000.0) {
tmp = t_3;
} else if (t_2 <= 400000.0) {
tmp = t_0;
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y, z): t_0 = x + math.cos(y) t_1 = math.sin(y) * z t_2 = t_0 - t_1 t_3 = x - t_1 tmp = 0 if t_2 <= -1000.0: tmp = t_3 elif t_2 <= 400000.0: tmp = t_0 else: tmp = t_3 return tmp
function code(x, y, z) t_0 = Float64(x + cos(y)) t_1 = Float64(sin(y) * z) t_2 = Float64(t_0 - t_1) t_3 = Float64(x - t_1) tmp = 0.0 if (t_2 <= -1000.0) tmp = t_3; elseif (t_2 <= 400000.0) tmp = t_0; else tmp = t_3; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + cos(y); t_1 = sin(y) * z; t_2 = t_0 - t_1; t_3 = x - t_1; tmp = 0.0; if (t_2 <= -1000.0) tmp = t_3; elseif (t_2 <= 400000.0) tmp = 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[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(x - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -1000.0], t$95$3, If[LessEqual[t$95$2, 400000.0], t$95$0, t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \cos y\\
t_1 := \sin y \cdot z\\
t_2 := t\_0 - t\_1\\
t_3 := x - t\_1\\
\mathbf{if}\;t\_2 \leq -1000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 400000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -1e3 or 4e5 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in x around inf
Simplified98.8%
if -1e3 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 4e5Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
+-lowering-+.f64N/A
cos-lowering-cos.f6498.1
Simplified98.1%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (+ x (cos y)) (* (sin y) z)))) (if (<= t_0 -0.01) x (if (<= t_0 1000.0) 1.0 x))))
double code(double x, double y, double z) {
double t_0 = (x + cos(y)) - (sin(y) * z);
double tmp;
if (t_0 <= -0.01) {
tmp = x;
} else if (t_0 <= 1000.0) {
tmp = 1.0;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = (x + cos(y)) - (sin(y) * z)
if (t_0 <= (-0.01d0)) then
tmp = x
else if (t_0 <= 1000.0d0) then
tmp = 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + Math.cos(y)) - (Math.sin(y) * z);
double tmp;
if (t_0 <= -0.01) {
tmp = x;
} else if (t_0 <= 1000.0) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): t_0 = (x + math.cos(y)) - (math.sin(y) * z) tmp = 0 if t_0 <= -0.01: tmp = x elif t_0 <= 1000.0: tmp = 1.0 else: tmp = x return tmp
function code(x, y, z) t_0 = Float64(Float64(x + cos(y)) - Float64(sin(y) * z)) tmp = 0.0 if (t_0 <= -0.01) tmp = x; elseif (t_0 <= 1000.0) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + cos(y)) - (sin(y) * z); tmp = 0.0; if (t_0 <= -0.01) tmp = x; elseif (t_0 <= 1000.0) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.01], x, If[LessEqual[t$95$0, 1000.0], 1.0, x]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \cos y\right) - \sin y \cdot z\\
\mathbf{if}\;t\_0 \leq -0.01:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_0 \leq 1000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -0.0100000000000000002 or 1e3 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in x around inf
Simplified56.4%
if -0.0100000000000000002 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 1e3Initial program 100.0%
Taylor expanded in x around 0
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f6497.4
Simplified97.4%
Taylor expanded in y around 0
Simplified75.9%
Final simplification61.9%
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* (sin y) z)))
double code(double x, double y, double z) {
return (x + cos(y)) - (sin(y) * 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 + cos(y)) - (sin(y) * z)
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (Math.sin(y) * z);
}
def code(x, y, z): return (x + math.cos(y)) - (math.sin(y) * z)
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(sin(y) * z)) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (sin(y) * z); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - \sin y \cdot z
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (sin y) z)))
(if (<= z -2.9e+87)
(- 1.0 t_0)
(if (<= z 1.6e+193) (+ x (cos y)) (- t_0)))))
double code(double x, double y, double z) {
double t_0 = sin(y) * z;
double tmp;
if (z <= -2.9e+87) {
tmp = 1.0 - t_0;
} else if (z <= 1.6e+193) {
tmp = x + cos(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 = sin(y) * z
if (z <= (-2.9d+87)) then
tmp = 1.0d0 - t_0
else if (z <= 1.6d+193) then
tmp = x + cos(y)
else
tmp = -t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.sin(y) * z;
double tmp;
if (z <= -2.9e+87) {
tmp = 1.0 - t_0;
} else if (z <= 1.6e+193) {
tmp = x + Math.cos(y);
} else {
tmp = -t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) * z tmp = 0 if z <= -2.9e+87: tmp = 1.0 - t_0 elif z <= 1.6e+193: tmp = x + math.cos(y) else: tmp = -t_0 return tmp
function code(x, y, z) t_0 = Float64(sin(y) * z) tmp = 0.0 if (z <= -2.9e+87) tmp = Float64(1.0 - t_0); elseif (z <= 1.6e+193) tmp = Float64(x + cos(y)); else tmp = Float64(-t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) * z; tmp = 0.0; if (z <= -2.9e+87) tmp = 1.0 - t_0; elseif (z <= 1.6e+193) tmp = x + cos(y); else tmp = -t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -2.9e+87], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[z, 1.6e+193], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], (-t$95$0)]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin y \cdot z\\
\mathbf{if}\;z \leq -2.9 \cdot 10^{+87}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+193}:\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;-t\_0\\
\end{array}
\end{array}
if z < -2.8999999999999998e87Initial program 99.8%
Taylor expanded in x around 0
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f6486.3
Simplified86.3%
Taylor expanded in y around 0
Simplified86.3%
if -2.8999999999999998e87 < z < 1.60000000000000007e193Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
+-lowering-+.f64N/A
cos-lowering-cos.f6492.9
Simplified92.9%
if 1.60000000000000007e193 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f6469.7
Simplified69.7%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (* (sin y) z)))) (if (<= z -6.2e+93) t_0 (if (<= z 2.1e+193) (+ x (cos y)) t_0))))
double code(double x, double y, double z) {
double t_0 = -(sin(y) * z);
double tmp;
if (z <= -6.2e+93) {
tmp = t_0;
} else if (z <= 2.1e+193) {
tmp = x + cos(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 = -(sin(y) * z)
if (z <= (-6.2d+93)) then
tmp = t_0
else if (z <= 2.1d+193) then
tmp = x + cos(y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -(Math.sin(y) * z);
double tmp;
if (z <= -6.2e+93) {
tmp = t_0;
} else if (z <= 2.1e+193) {
tmp = x + Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -(math.sin(y) * z) tmp = 0 if z <= -6.2e+93: tmp = t_0 elif z <= 2.1e+193: tmp = x + math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-Float64(sin(y) * z)) tmp = 0.0 if (z <= -6.2e+93) tmp = t_0; elseif (z <= 2.1e+193) tmp = Float64(x + cos(y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -(sin(y) * z); tmp = 0.0; if (z <= -6.2e+93) tmp = t_0; elseif (z <= 2.1e+193) tmp = x + cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision])}, If[LessEqual[z, -6.2e+93], t$95$0, If[LessEqual[z, 2.1e+193], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin y \cdot z\\
\mathbf{if}\;z \leq -6.2 \cdot 10^{+93}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{+193}:\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -6.20000000000000038e93 or 2.1e193 < z Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f6475.8
Simplified75.8%
if -6.20000000000000038e93 < z < 2.1e193Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
+-lowering-+.f64N/A
cos-lowering-cos.f6492.9
Simplified92.9%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ x (cos y)))) (if (<= y -2.2e-8) t_0 (if (<= y 3.4e-21) (- x (fma y z -1.0)) t_0))))
double code(double x, double y, double z) {
double t_0 = x + cos(y);
double tmp;
if (y <= -2.2e-8) {
tmp = t_0;
} else if (y <= 3.4e-21) {
tmp = x - fma(y, z, -1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x + cos(y)) tmp = 0.0 if (y <= -2.2e-8) tmp = t_0; elseif (y <= 3.4e-21) tmp = Float64(x - fma(y, z, -1.0)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.2e-8], t$95$0, If[LessEqual[y, 3.4e-21], N[(x - N[(y * z + -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \cos y\\
\mathbf{if}\;y \leq -2.2 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-21}:\\
\;\;\;\;x - \mathsf{fma}\left(y, z, -1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.1999999999999998e-8 or 3.4e-21 < y Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
+-lowering-+.f64N/A
cos-lowering-cos.f6469.0
Simplified69.0%
if -2.1999999999999998e-8 < y < 3.4e-21Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
--lowering--.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
Final simplification83.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.56e+32) (+ x 1.0) (if (<= y 1.02e+32) (fma y (- (* y -0.5) z) (+ x 1.0)) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.56e+32) {
tmp = x + 1.0;
} else if (y <= 1.02e+32) {
tmp = fma(y, ((y * -0.5) - z), (x + 1.0));
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.56e+32) tmp = Float64(x + 1.0); elseif (y <= 1.02e+32) tmp = fma(y, Float64(Float64(y * -0.5) - z), Float64(x + 1.0)); else tmp = Float64(x + 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.56e+32], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 1.02e+32], N[(y * N[(N[(y * -0.5), $MachinePrecision] - z), $MachinePrecision] + N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.56 \cdot 10^{+32}:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(y, y \cdot -0.5 - z, x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -1.56e32 or 1.0199999999999999e32 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
+-lowering-+.f6440.5
Simplified40.5%
if -1.56e32 < y < 1.0199999999999999e32Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f6492.9
Simplified92.9%
(FPCore (x y z) :precision binary64 (if (<= y -6.8e+55) (+ x 1.0) (if (<= y 4.4e+55) (- x (fma y z -1.0)) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.8e+55) {
tmp = x + 1.0;
} else if (y <= 4.4e+55) {
tmp = x - fma(y, z, -1.0);
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -6.8e+55) tmp = Float64(x + 1.0); elseif (y <= 4.4e+55) tmp = Float64(x - fma(y, z, -1.0)); else tmp = Float64(x + 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -6.8e+55], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 4.4e+55], N[(x - N[(y * z + -1.0), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{+55}:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+55}:\\
\;\;\;\;x - \mathsf{fma}\left(y, z, -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -6.7999999999999996e55 or 4.40000000000000021e55 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
+-lowering-+.f6438.0
Simplified38.0%
if -6.7999999999999996e55 < y < 4.40000000000000021e55Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
--lowering--.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f6490.8
Simplified90.8%
(FPCore (x y z) :precision binary64 (if (<= x -5.2e+36) x (if (<= x 1.75e-38) (- 1.0 (* y z)) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.2e+36) {
tmp = x;
} else if (x <= 1.75e-38) {
tmp = 1.0 - (y * z);
} else {
tmp = x + 1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-5.2d+36)) then
tmp = x
else if (x <= 1.75d-38) then
tmp = 1.0d0 - (y * z)
else
tmp = x + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -5.2e+36) {
tmp = x;
} else if (x <= 1.75e-38) {
tmp = 1.0 - (y * z);
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.2e+36: tmp = x elif x <= 1.75e-38: tmp = 1.0 - (y * z) else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.2e+36) tmp = x; elseif (x <= 1.75e-38) tmp = Float64(1.0 - Float64(y * z)); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5.2e+36) tmp = x; elseif (x <= 1.75e-38) tmp = 1.0 - (y * z); else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.2e+36], x, If[LessEqual[x, 1.75e-38], N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+36}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-38}:\\
\;\;\;\;1 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if x < -5.2000000000000003e36Initial program 100.0%
Taylor expanded in x around inf
Simplified91.6%
if -5.2000000000000003e36 < x < 1.7500000000000001e-38Initial program 99.9%
Taylor expanded in x around 0
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f6498.5
Simplified98.5%
Taylor expanded in y around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
*-lowering-*.f6451.6
Simplified51.6%
if 1.7500000000000001e-38 < x Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
+-lowering-+.f6481.9
Simplified81.9%
(FPCore (x y z) :precision binary64 (if (<= z -2e+135) (* y (- z)) (+ x 1.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e+135) {
tmp = y * -z;
} else {
tmp = x + 1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-2d+135)) then
tmp = y * -z
else
tmp = x + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2e+135) {
tmp = y * -z;
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2e+135: tmp = y * -z else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2e+135) tmp = Float64(y * Float64(-z)); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2e+135) tmp = y * -z; else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2e+135], N[(y * (-z)), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+135}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if z < -1.99999999999999992e135Initial program 99.7%
Taylor expanded in z around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f6485.7
Simplified85.7%
Taylor expanded in y around 0
Simplified33.8%
if -1.99999999999999992e135 < z Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
+-lowering-+.f6469.3
Simplified69.3%
(FPCore (x y z) :precision binary64 (+ x 1.0))
double code(double x, double y, double z) {
return x + 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 = x + 1.0d0
end function
public static double code(double x, double y, double z) {
return x + 1.0;
}
def code(x, y, z): return x + 1.0
function code(x, y, z) return Float64(x + 1.0) end
function tmp = code(x, y, z) tmp = x + 1.0; end
code[x_, y_, z_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
x + 1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
+-lowering-+.f6462.4
Simplified62.4%
(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 x around 0
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f6460.5
Simplified60.5%
Taylor expanded in y around 0
Simplified23.8%
herbie shell --seed 2024204
(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))))