
(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 9 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 z (cos y) (+ x (sin y))))
double code(double x, double y, double z) {
return fma(z, cos(y), (x + sin(y)));
}
function code(x, y, z) return fma(z, cos(y), Float64(x + sin(y))) end
code[x_, y_, z_] := N[(z * N[Cos[y], $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, \cos y, x + \sin y\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Final simplification99.9%
(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}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.7e+110) (not (<= z 6e+54))) (* z (cos y)) (+ z (+ x (sin y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.7e+110) || !(z <= 6e+54)) {
tmp = z * cos(y);
} else {
tmp = z + (x + sin(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 ((z <= (-1.7d+110)) .or. (.not. (z <= 6d+54))) then
tmp = z * cos(y)
else
tmp = z + (x + sin(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.7e+110) || !(z <= 6e+54)) {
tmp = z * Math.cos(y);
} else {
tmp = z + (x + Math.sin(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.7e+110) or not (z <= 6e+54): tmp = z * math.cos(y) else: tmp = z + (x + math.sin(y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.7e+110) || !(z <= 6e+54)) tmp = Float64(z * cos(y)); else tmp = Float64(z + Float64(x + sin(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.7e+110) || ~((z <= 6e+54))) tmp = z * cos(y); else tmp = z + (x + sin(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.7e+110], N[Not[LessEqual[z, 6e+54]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{+110} \lor \neg \left(z \leq 6 \cdot 10^{+54}\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;z + \left(x + \sin y\right)\\
\end{array}
\end{array}
if z < -1.7000000000000001e110 or 5.9999999999999998e54 < z Initial program 99.8%
Taylor expanded in z around inf 92.7%
if -1.7000000000000001e110 < z < 5.9999999999999998e54Initial program 100.0%
Taylor expanded in y around 0 95.1%
Final simplification94.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -6e+109) (not (<= z 1.86e+73))) (* z (cos y)) (+ z x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6e+109) || !(z <= 1.86e+73)) {
tmp = z * cos(y);
} else {
tmp = z + 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 ((z <= (-6d+109)) .or. (.not. (z <= 1.86d+73))) then
tmp = z * cos(y)
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6e+109) || !(z <= 1.86e+73)) {
tmp = z * Math.cos(y);
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6e+109) or not (z <= 1.86e+73): tmp = z * math.cos(y) else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6e+109) || !(z <= 1.86e+73)) tmp = Float64(z * cos(y)); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6e+109) || ~((z <= 1.86e+73))) tmp = z * cos(y); else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6e+109], N[Not[LessEqual[z, 1.86e+73]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+109} \lor \neg \left(z \leq 1.86 \cdot 10^{+73}\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if z < -6.00000000000000031e109 or 1.8599999999999999e73 < z Initial program 99.8%
Taylor expanded in z around inf 92.7%
if -6.00000000000000031e109 < z < 1.8599999999999999e73Initial program 100.0%
Taylor expanded in y around 0 70.6%
+-commutative70.6%
Simplified70.6%
Final simplification77.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.4e+52) (not (<= z 9e+44))) (* z (cos y)) (+ x (sin y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.4e+52) || !(z <= 9e+44)) {
tmp = z * cos(y);
} else {
tmp = x + sin(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 ((z <= (-4.4d+52)) .or. (.not. (z <= 9d+44))) then
tmp = z * cos(y)
else
tmp = x + sin(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.4e+52) || !(z <= 9e+44)) {
tmp = z * Math.cos(y);
} else {
tmp = x + Math.sin(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.4e+52) or not (z <= 9e+44): tmp = z * math.cos(y) else: tmp = x + math.sin(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.4e+52) || !(z <= 9e+44)) tmp = Float64(z * cos(y)); else tmp = Float64(x + sin(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.4e+52) || ~((z <= 9e+44))) tmp = z * cos(y); else tmp = x + sin(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.4e+52], N[Not[LessEqual[z, 9e+44]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{+52} \lor \neg \left(z \leq 9 \cdot 10^{+44}\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x + \sin y\\
\end{array}
\end{array}
if z < -4.4e52 or 9e44 < z Initial program 99.8%
Taylor expanded in z around inf 90.7%
if -4.4e52 < z < 9e44Initial program 100.0%
Taylor expanded in z around 0 89.0%
+-commutative89.0%
Simplified89.0%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.9e+159) (not (<= y 4e+29))) (+ z x) (+ z (+ y x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.9e+159) || !(y <= 4e+29)) {
tmp = z + x;
} else {
tmp = z + (y + 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 ((y <= (-5.9d+159)) .or. (.not. (y <= 4d+29))) then
tmp = z + x
else
tmp = z + (y + x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.9e+159) || !(y <= 4e+29)) {
tmp = z + x;
} else {
tmp = z + (y + x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.9e+159) or not (y <= 4e+29): tmp = z + x else: tmp = z + (y + x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.9e+159) || !(y <= 4e+29)) tmp = Float64(z + x); else tmp = Float64(z + Float64(y + x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.9e+159) || ~((y <= 4e+29))) tmp = z + x; else tmp = z + (y + x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.9e+159], N[Not[LessEqual[y, 4e+29]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.9 \cdot 10^{+159} \lor \neg \left(y \leq 4 \cdot 10^{+29}\right):\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;z + \left(y + x\right)\\
\end{array}
\end{array}
if y < -5.89999999999999993e159 or 3.99999999999999966e29 < y Initial program 99.8%
Taylor expanded in y around 0 40.7%
+-commutative40.7%
Simplified40.7%
if -5.89999999999999993e159 < y < 3.99999999999999966e29Initial program 100.0%
Taylor expanded in y around 0 85.0%
+-commutative85.0%
+-commutative85.0%
associate-+l+85.0%
Simplified85.0%
Final simplification69.4%
(FPCore (x y z) :precision binary64 (if (<= z -6.5e+56) z (if (<= z 3.35e+81) x z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.5e+56) {
tmp = z;
} else if (z <= 3.35e+81) {
tmp = x;
} else {
tmp = 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 (z <= (-6.5d+56)) then
tmp = z
else if (z <= 3.35d+81) then
tmp = x
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -6.5e+56) {
tmp = z;
} else if (z <= 3.35e+81) {
tmp = x;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.5e+56: tmp = z elif z <= 3.35e+81: tmp = x else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.5e+56) tmp = z; elseif (z <= 3.35e+81) tmp = x; else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.5e+56) tmp = z; elseif (z <= 3.35e+81) tmp = x; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.5e+56], z, If[LessEqual[z, 3.35e+81], x, z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+56}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 3.35 \cdot 10^{+81}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -6.5000000000000001e56 or 3.34999999999999981e81 < z Initial program 99.8%
Taylor expanded in z around inf 90.6%
Taylor expanded in y around 0 48.1%
if -6.5000000000000001e56 < z < 3.34999999999999981e81Initial program 100.0%
Taylor expanded in x around inf 62.3%
Final simplification57.2%
(FPCore (x y z) :precision binary64 (+ z x))
double code(double x, double y, double z) {
return z + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z + x
end function
public static double code(double x, double y, double z) {
return z + x;
}
def code(x, y, z): return z + x
function code(x, y, z) return Float64(z + x) end
function tmp = code(x, y, z) tmp = z + x; end
code[x_, y_, z_] := N[(z + x), $MachinePrecision]
\begin{array}{l}
\\
z + x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 65.0%
+-commutative65.0%
Simplified65.0%
Final simplification65.0%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 43.9%
Final simplification43.9%
herbie shell --seed 2024034
(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))))