
(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 (+ (sin y) (fma (cos y) z x)))
double code(double x, double y, double z) {
return sin(y) + fma(cos(y), z, x);
}
function code(x, y, z) return Float64(sin(y) + fma(cos(y), z, x)) end
code[x_, y_, z_] := N[(N[Sin[y], $MachinePrecision] + N[(N[Cos[y], $MachinePrecision] * z + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin y + \mathsf{fma}\left(\cos y, z, x\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* z (cos y)) (+ (sin y) x))))
(if (<= t_0 -5e+16)
(+ x z)
(if (<= t_0 -0.02)
(sin y)
(if (<= t_0 5e-20) (+ (+ 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)) + (sin(y) + x);
double tmp;
if (t_0 <= -5e+16) {
tmp = x + z;
} else if (t_0 <= -0.02) {
tmp = sin(y);
} else if (t_0 <= 5e-20) {
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)) + (sin(y) + x)
if (t_0 <= (-5d+16)) then
tmp = x + z
else if (t_0 <= (-0.02d0)) then
tmp = sin(y)
else if (t_0 <= 5d-20) 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)) + (Math.sin(y) + x);
double tmp;
if (t_0 <= -5e+16) {
tmp = x + z;
} else if (t_0 <= -0.02) {
tmp = Math.sin(y);
} else if (t_0 <= 5e-20) {
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)) + (math.sin(y) + x) tmp = 0 if t_0 <= -5e+16: tmp = x + z elif t_0 <= -0.02: tmp = math.sin(y) elif t_0 <= 5e-20: 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(sin(y) + x)) tmp = 0.0 if (t_0 <= -5e+16) tmp = Float64(x + z); elseif (t_0 <= -0.02) tmp = sin(y); elseif (t_0 <= 5e-20) 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)) + (sin(y) + x); tmp = 0.0; if (t_0 <= -5e+16) tmp = x + z; elseif (t_0 <= -0.02) tmp = sin(y); elseif (t_0 <= 5e-20) 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[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+16], N[(x + z), $MachinePrecision], If[LessEqual[t$95$0, -0.02], N[Sin[y], $MachinePrecision], If[LessEqual[t$95$0, 5e-20], 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(\sin y + x\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+16}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;t\_0 \leq -0.02:\\
\;\;\;\;\sin y\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-20}:\\
\;\;\;\;\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))) < -5e16 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-+.f6481.5
Applied rewrites81.5%
if -5e16 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.0200000000000000004 or 4.9999999999999999e-20 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 1Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f6493.6
Applied rewrites93.6%
Taylor expanded in z around 0
Applied rewrites91.4%
if -0.0200000000000000004 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 4.9999999999999999e-20Initial 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 simplification85.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* z (cos y)) (+ (sin y) x))))
(if (<= t_0 -0.1)
(+ x z)
(if (<= t_0 0.15)
(fma
1.0
z
(fma
(fma
(fma (* y y) 0.008333333333333333 -0.16666666666666666)
(* y y)
1.0)
y
x))
(+ x z)))))
double code(double x, double y, double z) {
double t_0 = (z * cos(y)) + (sin(y) + x);
double tmp;
if (t_0 <= -0.1) {
tmp = x + z;
} else if (t_0 <= 0.15) {
tmp = fma(1.0, z, fma(fma(fma((y * y), 0.008333333333333333, -0.16666666666666666), (y * y), 1.0), y, x));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z * cos(y)) + Float64(sin(y) + x)) tmp = 0.0 if (t_0 <= -0.1) tmp = Float64(x + z); elseif (t_0 <= 0.15) tmp = fma(1.0, z, fma(fma(fma(Float64(y * y), 0.008333333333333333, -0.16666666666666666), Float64(y * y), 1.0), y, x)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.1], N[(x + z), $MachinePrecision], If[LessEqual[t$95$0, 0.15], N[(1.0 * z + N[(N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * y + x), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y + \left(\sin y + x\right)\\
\mathbf{if}\;t\_0 \leq -0.1:\\
\;\;\;\;x + z\\
\mathbf{elif}\;t\_0 \leq 0.15:\\
\;\;\;\;\mathsf{fma}\left(1, z, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, -0.16666666666666666\right), y \cdot y, 1\right), y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.10000000000000001 or 0.149999999999999994 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6468.8
Applied rewrites68.8%
if -0.10000000000000001 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 0.149999999999999994Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-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-*.f6493.5
Applied rewrites93.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6493.5
Applied rewrites93.5%
Final simplification71.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* z (cos y)) (+ (sin y) x))))
(if (<= t_0 -0.5)
(+ x z)
(if (<= t_0 0.15) (fma (fma (* -0.5 y) z 1.0) y (+ x z)) (+ x z)))))
double code(double x, double y, double z) {
double t_0 = (z * cos(y)) + (sin(y) + x);
double tmp;
if (t_0 <= -0.5) {
tmp = x + z;
} else if (t_0 <= 0.15) {
tmp = fma(fma((-0.5 * y), z, 1.0), y, (x + z));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z * cos(y)) + Float64(sin(y) + x)) tmp = 0.0 if (t_0 <= -0.5) tmp = Float64(x + z); elseif (t_0 <= 0.15) 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_] := Block[{t$95$0 = N[(N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.5], N[(x + z), $MachinePrecision], If[LessEqual[t$95$0, 0.15], 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}
t_0 := z \cdot \cos y + \left(\sin y + x\right)\\
\mathbf{if}\;t\_0 \leq -0.5:\\
\;\;\;\;x + z\\
\mathbf{elif}\;t\_0 \leq 0.15:\\
\;\;\;\;\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 (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.5 or 0.149999999999999994 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6470.6
Applied rewrites70.6%
if -0.5 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 0.149999999999999994Initial 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-+.f6478.1
Applied rewrites78.1%
Final simplification71.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (* z (cos y)) (+ (sin y) x)))) (if (<= t_0 -0.16) (+ x z) (if (<= t_0 0.15) (+ (+ x y) z) (+ x z)))))
double code(double x, double y, double z) {
double t_0 = (z * cos(y)) + (sin(y) + x);
double tmp;
if (t_0 <= -0.16) {
tmp = x + z;
} else if (t_0 <= 0.15) {
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) :: t_0
real(8) :: tmp
t_0 = (z * cos(y)) + (sin(y) + x)
if (t_0 <= (-0.16d0)) then
tmp = x + z
else if (t_0 <= 0.15d0) 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 t_0 = (z * Math.cos(y)) + (Math.sin(y) + x);
double tmp;
if (t_0 <= -0.16) {
tmp = x + z;
} else if (t_0 <= 0.15) {
tmp = (x + y) + z;
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): t_0 = (z * math.cos(y)) + (math.sin(y) + x) tmp = 0 if t_0 <= -0.16: tmp = x + z elif t_0 <= 0.15: tmp = (x + y) + z else: tmp = x + z return tmp
function code(x, y, z) t_0 = Float64(Float64(z * cos(y)) + Float64(sin(y) + x)) tmp = 0.0 if (t_0 <= -0.16) tmp = Float64(x + z); elseif (t_0 <= 0.15) tmp = Float64(Float64(x + y) + z); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * cos(y)) + (sin(y) + x); tmp = 0.0; if (t_0 <= -0.16) tmp = x + z; elseif (t_0 <= 0.15) tmp = (x + y) + z; 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[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.16], N[(x + z), $MachinePrecision], If[LessEqual[t$95$0, 0.15], N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision], N[(x + z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y + \left(\sin y + x\right)\\
\mathbf{if}\;t\_0 \leq -0.16:\\
\;\;\;\;x + z\\
\mathbf{elif}\;t\_0 \leq 0.15:\\
\;\;\;\;\left(x + y\right) + z\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.160000000000000003 or 0.149999999999999994 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6469.1
Applied rewrites69.1%
if -0.160000000000000003 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 0.149999999999999994Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6489.5
Applied rewrites89.5%
Final simplification71.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -1e+207)
t_0
(if (<= z -1.32e-33)
(+ x z)
(if (<= z 1.35e-28) (+ (sin y) x) (if (<= z 8.2e+151) (+ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -1e+207) {
tmp = t_0;
} else if (z <= -1.32e-33) {
tmp = x + z;
} else if (z <= 1.35e-28) {
tmp = sin(y) + x;
} else if (z <= 8.2e+151) {
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 <= (-1d+207)) then
tmp = t_0
else if (z <= (-1.32d-33)) then
tmp = x + z
else if (z <= 1.35d-28) then
tmp = sin(y) + x
else if (z <= 8.2d+151) 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 <= -1e+207) {
tmp = t_0;
} else if (z <= -1.32e-33) {
tmp = x + z;
} else if (z <= 1.35e-28) {
tmp = Math.sin(y) + x;
} else if (z <= 8.2e+151) {
tmp = x + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -1e+207: tmp = t_0 elif z <= -1.32e-33: tmp = x + z elif z <= 1.35e-28: tmp = math.sin(y) + x elif z <= 8.2e+151: 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 <= -1e+207) tmp = t_0; elseif (z <= -1.32e-33) tmp = Float64(x + z); elseif (z <= 1.35e-28) tmp = Float64(sin(y) + x); elseif (z <= 8.2e+151) 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 <= -1e+207) tmp = t_0; elseif (z <= -1.32e-33) tmp = x + z; elseif (z <= 1.35e-28) tmp = sin(y) + x; elseif (z <= 8.2e+151) 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, -1e+207], t$95$0, If[LessEqual[z, -1.32e-33], N[(x + z), $MachinePrecision], If[LessEqual[z, 1.35e-28], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 8.2e+151], N[(x + z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -1 \cdot 10^{+207}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.32 \cdot 10^{-33}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-28}:\\
\;\;\;\;\sin y + x\\
\mathbf{elif}\;z \leq 8.2 \cdot 10^{+151}:\\
\;\;\;\;x + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1e207 or 8.1999999999999996e151 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6494.2
Applied rewrites94.2%
if -1e207 < z < -1.31999999999999993e-33 or 1.3499999999999999e-28 < z < 8.1999999999999996e151Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6483.4
Applied rewrites83.4%
if -1.31999999999999993e-33 < z < 1.3499999999999999e-28Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6495.2
Applied rewrites95.2%
Final simplification90.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (cos y)))) (if (<= z -1e+207) t_0 (if (<= z 8.2e+151) (+ (+ x z) (sin y)) t_0))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -1e+207) {
tmp = t_0;
} else if (z <= 8.2e+151) {
tmp = (x + z) + 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 <= (-1d+207)) then
tmp = t_0
else if (z <= 8.2d+151) then
tmp = (x + z) + 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 <= -1e+207) {
tmp = t_0;
} else if (z <= 8.2e+151) {
tmp = (x + z) + Math.sin(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -1e+207: tmp = t_0 elif z <= 8.2e+151: tmp = (x + z) + 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 <= -1e+207) tmp = t_0; elseif (z <= 8.2e+151) tmp = Float64(Float64(x + z) + 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 <= -1e+207) tmp = t_0; elseif (z <= 8.2e+151) tmp = (x + z) + 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, -1e+207], t$95$0, If[LessEqual[z, 8.2e+151], N[(N[(x + z), $MachinePrecision] + N[Sin[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -1 \cdot 10^{+207}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 8.2 \cdot 10^{+151}:\\
\;\;\;\;\left(x + z\right) + \sin y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1e207 or 8.1999999999999996e151 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6494.2
Applied rewrites94.2%
if -1e207 < z < 8.1999999999999996e151Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
Final simplification93.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (sin y) x)))
(if (<= y -6e+26)
t_0
(if (<= y 55000000.0)
(fma
1.0
z
(fma
(fma
(fma (* y y) 0.008333333333333333 -0.16666666666666666)
(* y y)
1.0)
y
x))
t_0))))
double code(double x, double y, double z) {
double t_0 = sin(y) + x;
double tmp;
if (y <= -6e+26) {
tmp = t_0;
} else if (y <= 55000000.0) {
tmp = fma(1.0, z, fma(fma(fma((y * y), 0.008333333333333333, -0.16666666666666666), (y * y), 1.0), y, x));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(sin(y) + x) tmp = 0.0 if (y <= -6e+26) tmp = t_0; elseif (y <= 55000000.0) tmp = fma(1.0, z, fma(fma(fma(Float64(y * y), 0.008333333333333333, -0.16666666666666666), Float64(y * y), 1.0), y, x)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -6e+26], t$95$0, If[LessEqual[y, 55000000.0], N[(1.0 * z + N[(N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * y + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin y + x\\
\mathbf{if}\;y \leq -6 \cdot 10^{+26}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 55000000:\\
\;\;\;\;\mathsf{fma}\left(1, z, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, -0.16666666666666666\right), y \cdot y, 1\right), y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.99999999999999994e26 or 5.5e7 < y Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6469.6
Applied rewrites69.6%
if -5.99999999999999994e26 < y < 5.5e7Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites98.2%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-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-*.f6498.1
Applied rewrites98.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6498.1
Applied rewrites98.1%
(FPCore (x y z)
:precision binary64
(if (<= y -4200000000.0)
(+ x z)
(if (<= y 4.8e+18)
(fma
1.0
z
(+
(*
(fma
(fma
(fma (* y y) -0.0001984126984126984 0.008333333333333333)
(* y y)
-0.16666666666666666)
(* y y)
1.0)
y)
x))
(+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4200000000.0) {
tmp = x + z;
} else if (y <= 4.8e+18) {
tmp = fma(1.0, z, ((fma(fma(fma((y * y), -0.0001984126984126984, 0.008333333333333333), (y * y), -0.16666666666666666), (y * y), 1.0) * y) + x));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -4200000000.0) tmp = Float64(x + z); elseif (y <= 4.8e+18) tmp = fma(1.0, z, Float64(Float64(fma(fma(fma(Float64(y * y), -0.0001984126984126984, 0.008333333333333333), Float64(y * y), -0.16666666666666666), Float64(y * y), 1.0) * y) + x)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -4200000000.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 4.8e+18], N[(1.0 * z + N[(N[(N[(N[(N[(N[(y * y), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(y * y), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4200000000:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(1, z, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, -0.0001984126984126984, 0.008333333333333333\right), y \cdot y, -0.16666666666666666\right), y \cdot y, 1\right) \cdot y + x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -4.2e9 or 4.8e18 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6443.1
Applied rewrites43.1%
if -4.2e9 < y < 4.8e18Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites99.4%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-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-*.f6498.7
Applied rewrites98.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6498.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.7
Applied rewrites98.7%
Final simplification72.0%
(FPCore (x y z)
:precision binary64
(if (<= y -460000.0)
(+ x z)
(if (<= y 7.5e-25)
(fma (fma (fma -0.16666666666666666 y (* -0.5 z)) y 1.0) y (+ x z))
(+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -460000.0) {
tmp = x + z;
} else if (y <= 7.5e-25) {
tmp = fma(fma(fma(-0.16666666666666666, y, (-0.5 * z)), y, 1.0), y, (x + z));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -460000.0) tmp = Float64(x + z); elseif (y <= 7.5e-25) tmp = fma(fma(fma(-0.16666666666666666, y, Float64(-0.5 * z)), y, 1.0), y, Float64(x + z)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -460000.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 7.5e-25], N[(N[(N[(-0.16666666666666666 * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(x + z), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -460000:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-25}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, x + z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -4.6e5 or 7.49999999999999989e-25 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6444.8
Applied rewrites44.8%
if -4.6e5 < y < 7.49999999999999989e-25Initial 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-+.f6499.7
Applied rewrites99.7%
Final simplification71.8%
(FPCore (x y z) :precision binary64 (+ x z))
double code(double x, double y, double z) {
return x + z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + z
end function
public static double code(double x, double y, double z) {
return x + z;
}
def code(x, y, z): return x + z
function code(x, y, z) return Float64(x + z) end
function tmp = code(x, y, z) tmp = x + z; end
code[x_, y_, z_] := N[(x + z), $MachinePrecision]
\begin{array}{l}
\\
x + z
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6467.9
Applied rewrites67.9%
Final simplification67.9%
herbie shell --seed 2024235
(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))))