
(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 7 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%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (cos y)))) (if (<= z -1.8e+131) t_0 (if (<= z 7.2e+37) (+ (* x (sin y)) z) t_0))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -1.8e+131) {
tmp = t_0;
} else if (z <= 7.2e+37) {
tmp = (x * sin(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 = z * cos(y)
if (z <= (-1.8d+131)) then
tmp = t_0
else if (z <= 7.2d+37) then
tmp = (x * sin(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 = z * Math.cos(y);
double tmp;
if (z <= -1.8e+131) {
tmp = t_0;
} else if (z <= 7.2e+37) {
tmp = (x * Math.sin(y)) + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -1.8e+131: tmp = t_0 elif z <= 7.2e+37: tmp = (x * math.sin(y)) + z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -1.8e+131) tmp = t_0; elseif (z <= 7.2e+37) tmp = Float64(Float64(x * sin(y)) + 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 <= -1.8e+131) tmp = t_0; elseif (z <= 7.2e+37) tmp = (x * sin(y)) + 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, -1.8e+131], t$95$0, If[LessEqual[z, 7.2e+37], N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -1.8 \cdot 10^{+131}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{+37}:\\
\;\;\;\;x \cdot \sin y + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (sin y)))) (if (<= y -4.3e+33) t_0 (if (<= y 14.0) (+ z (* x y)) t_0))))
double code(double x, double y, double z) {
double t_0 = x * sin(y);
double tmp;
if (y <= -4.3e+33) {
tmp = t_0;
} else if (y <= 14.0) {
tmp = z + (x * 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 = x * sin(y)
if (y <= (-4.3d+33)) then
tmp = t_0
else if (y <= 14.0d0) then
tmp = z + (x * y)
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 <= -4.3e+33) {
tmp = t_0;
} else if (y <= 14.0) {
tmp = z + (x * y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.sin(y) tmp = 0 if y <= -4.3e+33: tmp = t_0 elif y <= 14.0: tmp = z + (x * y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * sin(y)) tmp = 0.0 if (y <= -4.3e+33) tmp = t_0; elseif (y <= 14.0) tmp = Float64(z + Float64(x * y)); 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 <= -4.3e+33) tmp = t_0; elseif (y <= 14.0) tmp = z + (x * y); 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, -4.3e+33], t$95$0, If[LessEqual[y, 14.0], N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \sin y\\
\mathbf{if}\;y \leq -4.3 \cdot 10^{+33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 14:\\
\;\;\;\;z + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (cos y)))) (if (<= z -8e-129) t_0 (if (<= z 66000000000.0) (* x (sin y)) t_0))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -8e-129) {
tmp = t_0;
} else if (z <= 66000000000.0) {
tmp = 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 <= (-8d-129)) then
tmp = t_0
else if (z <= 66000000000.0d0) then
tmp = 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 <= -8e-129) {
tmp = t_0;
} else if (z <= 66000000000.0) {
tmp = 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 <= -8e-129: tmp = t_0 elif z <= 66000000000.0: tmp = 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 <= -8e-129) tmp = t_0; elseif (z <= 66000000000.0) tmp = 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 <= -8e-129) tmp = t_0; elseif (z <= 66000000000.0) tmp = 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, -8e-129], t$95$0, If[LessEqual[z, 66000000000.0], N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -8 \cdot 10^{-129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 66000000000:\\
\;\;\;\;x \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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%
(FPCore (x y z) :precision binary64 (if (<= x -1.4e+202) (* x y) (if (<= x 3.3e+140) z (* x y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.4e+202) {
tmp = x * y;
} else if (x <= 3.3e+140) {
tmp = z;
} 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.4d+202)) then
tmp = x * y
else if (x <= 3.3d+140) then
tmp = z
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.4e+202) {
tmp = x * y;
} else if (x <= 3.3e+140) {
tmp = z;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.4e+202: tmp = x * y elif x <= 3.3e+140: tmp = z else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.4e+202) tmp = Float64(x * y); elseif (x <= 3.3e+140) tmp = z; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.4e+202) tmp = x * y; elseif (x <= 3.3e+140) tmp = z; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.4e+202], N[(x * y), $MachinePrecision], If[LessEqual[x, 3.3e+140], z, N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+202}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+140}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if x < -1.40000000000000008e202 or 3.3000000000000002e140 < x Initial program 99.8%
Taylor expanded in x around inf 76.1%
Taylor expanded in y around 0 41.5%
if -1.40000000000000008e202 < x < 3.3000000000000002e140Initial program 99.8%
Taylor expanded in y around 0 42.0%
(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%
(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 y around 0 35.6%
herbie shell --seed 2024077 -o generate:simplify
(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))))