
(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}
\\
x \cdot \sin y + z \cdot \cos y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 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}
\\
x \cdot \sin y + z \cdot \cos y
\end{array}
(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}
\\
x \cdot \sin y + z \cdot \cos y
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.8e+131) (not (<= z 7.2e+37))) (* z (cos y)) (+ (* x (sin y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.8e+131) || !(z <= 7.2e+37)) {
tmp = z * cos(y);
} else {
tmp = (x * sin(y)) + 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 <= (-1.8d+131)) .or. (.not. (z <= 7.2d+37))) then
tmp = z * cos(y)
else
tmp = (x * sin(y)) + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.8e+131) || !(z <= 7.2e+37)) {
tmp = z * Math.cos(y);
} else {
tmp = (x * Math.sin(y)) + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.8e+131) or not (z <= 7.2e+37): tmp = z * math.cos(y) else: tmp = (x * math.sin(y)) + z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.8e+131) || !(z <= 7.2e+37)) tmp = Float64(z * cos(y)); else tmp = Float64(Float64(x * sin(y)) + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.8e+131) || ~((z <= 7.2e+37))) tmp = z * cos(y); else tmp = (x * sin(y)) + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.8e+131], N[Not[LessEqual[z, 7.2e+37]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+131} \lor \neg \left(z \leq 7.2 \cdot 10^{+37}\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \sin y + z\\
\end{array}
\end{array}
if z < -1.80000000000000016e131 or 7.19999999999999995e37 < z Initial program 99.8%
Taylor expanded in x around 0 88.3%
if -1.80000000000000016e131 < z < 7.19999999999999995e37Initial program 99.8%
Taylor expanded in y around 0 85.9%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.3e+33) (not (<= y 14.0))) (* x (sin y)) (+ z (* x y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.3e+33) || !(y <= 14.0)) {
tmp = x * sin(y);
} else {
tmp = z + (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 ((y <= (-4.3d+33)) .or. (.not. (y <= 14.0d0))) then
tmp = x * sin(y)
else
tmp = z + (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4.3e+33) || !(y <= 14.0)) {
tmp = x * Math.sin(y);
} else {
tmp = z + (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.3e+33) or not (y <= 14.0): tmp = x * math.sin(y) else: tmp = z + (x * y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.3e+33) || !(y <= 14.0)) tmp = Float64(x * sin(y)); else tmp = Float64(z + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.3e+33) || ~((y <= 14.0))) tmp = x * sin(y); else tmp = z + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.3e+33], N[Not[LessEqual[y, 14.0]], $MachinePrecision]], N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{+33} \lor \neg \left(y \leq 14\right):\\
\;\;\;\;x \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot y\\
\end{array}
\end{array}
if y < -4.30000000000000028e33 or 14 < y Initial program 99.6%
Taylor expanded in x around inf 48.7%
if -4.30000000000000028e33 < y < 14Initial program 100.0%
Taylor expanded in y around 0 96.7%
*-commutative96.7%
Simplified96.7%
Final simplification71.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -8e-129) (not (<= z 66000000000.0))) (* z (cos y)) (* x (sin y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8e-129) || !(z <= 66000000000.0)) {
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 <= (-8d-129)) .or. (.not. (z <= 66000000000.0d0))) 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 <= -8e-129) || !(z <= 66000000000.0)) {
tmp = z * Math.cos(y);
} else {
tmp = x * Math.sin(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8e-129) or not (z <= 66000000000.0): tmp = z * math.cos(y) else: tmp = x * math.sin(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8e-129) || !(z <= 66000000000.0)) 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 <= -8e-129) || ~((z <= 66000000000.0))) tmp = z * cos(y); else tmp = x * sin(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8e-129], N[Not[LessEqual[z, 66000000000.0]], $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 -8 \cdot 10^{-129} \lor \neg \left(z \leq 66000000000\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \sin y\\
\end{array}
\end{array}
if z < -7.9999999999999994e-129 or 6.6e10 < z Initial program 99.8%
Taylor expanded in x around 0 79.5%
if -7.9999999999999994e-129 < z < 6.6e10Initial program 99.8%
Taylor expanded in x around inf 70.9%
Final simplification76.1%
(FPCore (x y z) :precision binary64 (+ z (* x y)))
double code(double x, double y, double z) {
return z + (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 = z + (x * y)
end function
public static double code(double x, double y, double z) {
return z + (x * y);
}
def code(x, y, z): return z + (x * y)
function code(x, y, z) return Float64(z + Float64(x * y)) end
function tmp = code(x, y, z) tmp = z + (x * y); end
code[x_, y_, z_] := N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + x \cdot y
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 49.7%
*-commutative49.7%
Simplified49.7%
Final simplification49.7%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 60.2%
Taylor expanded in y around 0 35.6%
Final simplification35.6%
herbie shell --seed 2024077
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, B"
:precision binary64
(+ (* x (sin y)) (* z (cos y))))