
(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}
\\
x \cdot \cos y - z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 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}
\\
x \cdot \cos y - z \cdot \sin y
\end{array}
(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}
\\
x \cdot \cos y - z \cdot \sin y
\end{array}
Initial program 99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (sin y) (- 0.0 z))))
(if (<= y -1.6e+178)
(* x (cos y))
(if (<= y -0.12)
t_0
(if (<= y 435.0)
(+ x (* y (- (* y (+ (* x -0.5) (* z (* y 0.16666666666666666)))) z)))
t_0)))))
double code(double x, double y, double z) {
double t_0 = sin(y) * (0.0 - z);
double tmp;
if (y <= -1.6e+178) {
tmp = x * cos(y);
} else if (y <= -0.12) {
tmp = t_0;
} else if (y <= 435.0) {
tmp = x + (y * ((y * ((x * -0.5) + (z * (y * 0.16666666666666666)))) - 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 = sin(y) * (0.0d0 - z)
if (y <= (-1.6d+178)) then
tmp = x * cos(y)
else if (y <= (-0.12d0)) then
tmp = t_0
else if (y <= 435.0d0) then
tmp = x + (y * ((y * ((x * (-0.5d0)) + (z * (y * 0.16666666666666666d0)))) - z))
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) * (0.0 - z);
double tmp;
if (y <= -1.6e+178) {
tmp = x * Math.cos(y);
} else if (y <= -0.12) {
tmp = t_0;
} else if (y <= 435.0) {
tmp = x + (y * ((y * ((x * -0.5) + (z * (y * 0.16666666666666666)))) - z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) * (0.0 - z) tmp = 0 if y <= -1.6e+178: tmp = x * math.cos(y) elif y <= -0.12: tmp = t_0 elif y <= 435.0: tmp = x + (y * ((y * ((x * -0.5) + (z * (y * 0.16666666666666666)))) - z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(sin(y) * Float64(0.0 - z)) tmp = 0.0 if (y <= -1.6e+178) tmp = Float64(x * cos(y)); elseif (y <= -0.12) tmp = t_0; elseif (y <= 435.0) tmp = Float64(x + Float64(y * Float64(Float64(y * Float64(Float64(x * -0.5) + Float64(z * Float64(y * 0.16666666666666666)))) - z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) * (0.0 - z); tmp = 0.0; if (y <= -1.6e+178) tmp = x * cos(y); elseif (y <= -0.12) tmp = t_0; elseif (y <= 435.0) tmp = x + (y * ((y * ((x * -0.5) + (z * (y * 0.16666666666666666)))) - z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] * N[(0.0 - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.6e+178], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -0.12], t$95$0, If[LessEqual[y, 435.0], N[(x + N[(y * N[(N[(y * N[(N[(x * -0.5), $MachinePrecision] + N[(z * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin y \cdot \left(0 - z\right)\\
\mathbf{if}\;y \leq -1.6 \cdot 10^{+178}:\\
\;\;\;\;x \cdot \cos y\\
\mathbf{elif}\;y \leq -0.12:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 435:\\
\;\;\;\;x + y \cdot \left(y \cdot \left(x \cdot -0.5 + z \cdot \left(y \cdot 0.16666666666666666\right)\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.6e178Initial program 99.8%
Taylor expanded in x around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6465.9%
Simplified65.9%
if -1.6e178 < y < -0.12 or 435 < y Initial program 99.7%
Taylor expanded in x around 0
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
neg-sub0N/A
--lowering--.f6459.3%
Simplified59.3%
if -0.12 < y < 435Initial program 100.0%
Taylor expanded in y around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6498.6%
Simplified98.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (cos y)))) (if (<= x -8e+127) t_0 (if (<= x 2.55e+85) (- x (* z (sin y))) t_0))))
double code(double x, double y, double z) {
double t_0 = x * cos(y);
double tmp;
if (x <= -8e+127) {
tmp = t_0;
} else if (x <= 2.55e+85) {
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 = x * cos(y)
if (x <= (-8d+127)) then
tmp = t_0
else if (x <= 2.55d+85) 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 = x * Math.cos(y);
double tmp;
if (x <= -8e+127) {
tmp = t_0;
} else if (x <= 2.55e+85) {
tmp = x - (z * Math.sin(y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.cos(y) tmp = 0 if x <= -8e+127: tmp = t_0 elif x <= 2.55e+85: tmp = x - (z * math.sin(y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * cos(y)) tmp = 0.0 if (x <= -8e+127) tmp = t_0; elseif (x <= 2.55e+85) tmp = Float64(x - Float64(z * sin(y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * cos(y); tmp = 0.0; if (x <= -8e+127) tmp = t_0; elseif (x <= 2.55e+85) tmp = x - (z * sin(y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8e+127], t$95$0, If[LessEqual[x, 2.55e+85], N[(x - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \cos y\\
\mathbf{if}\;x \leq -8 \cdot 10^{+127}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{+85}:\\
\;\;\;\;x - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -7.99999999999999964e127 or 2.5499999999999999e85 < x Initial program 99.8%
Taylor expanded in x around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6492.1%
Simplified92.1%
if -7.99999999999999964e127 < x < 2.5499999999999999e85Initial program 99.9%
Taylor expanded in y around 0
Simplified88.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (cos y))))
(if (<= y -0.02)
t_0
(if (<= y 0.205)
(+ x (* y (- (* y (+ (* x -0.5) (* z (* y 0.16666666666666666)))) z)))
t_0))))
double code(double x, double y, double z) {
double t_0 = x * cos(y);
double tmp;
if (y <= -0.02) {
tmp = t_0;
} else if (y <= 0.205) {
tmp = x + (y * ((y * ((x * -0.5) + (z * (y * 0.16666666666666666)))) - 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 = x * cos(y)
if (y <= (-0.02d0)) then
tmp = t_0
else if (y <= 0.205d0) then
tmp = x + (y * ((y * ((x * (-0.5d0)) + (z * (y * 0.16666666666666666d0)))) - z))
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.cos(y);
double tmp;
if (y <= -0.02) {
tmp = t_0;
} else if (y <= 0.205) {
tmp = x + (y * ((y * ((x * -0.5) + (z * (y * 0.16666666666666666)))) - z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.cos(y) tmp = 0 if y <= -0.02: tmp = t_0 elif y <= 0.205: tmp = x + (y * ((y * ((x * -0.5) + (z * (y * 0.16666666666666666)))) - z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * cos(y)) tmp = 0.0 if (y <= -0.02) tmp = t_0; elseif (y <= 0.205) tmp = Float64(x + Float64(y * Float64(Float64(y * Float64(Float64(x * -0.5) + Float64(z * Float64(y * 0.16666666666666666)))) - z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * cos(y); tmp = 0.0; if (y <= -0.02) tmp = t_0; elseif (y <= 0.205) tmp = x + (y * ((y * ((x * -0.5) + (z * (y * 0.16666666666666666)))) - z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.02], t$95$0, If[LessEqual[y, 0.205], N[(x + N[(y * N[(N[(y * N[(N[(x * -0.5), $MachinePrecision] + N[(z * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \cos y\\
\mathbf{if}\;y \leq -0.02:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.205:\\
\;\;\;\;x + y \cdot \left(y \cdot \left(x \cdot -0.5 + z \cdot \left(y \cdot 0.16666666666666666\right)\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.0200000000000000004 or 0.204999999999999988 < y Initial program 99.7%
Taylor expanded in x around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6447.7%
Simplified47.7%
if -0.0200000000000000004 < y < 0.204999999999999988Initial program 100.0%
Taylor expanded in y around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64100.0%
Simplified100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- 0.0 (* y z)))) (if (<= z -52000000000000.0) t_0 (if (<= z 3e+168) x t_0))))
double code(double x, double y, double z) {
double t_0 = 0.0 - (y * z);
double tmp;
if (z <= -52000000000000.0) {
tmp = t_0;
} else if (z <= 3e+168) {
tmp = x;
} 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 = 0.0d0 - (y * z)
if (z <= (-52000000000000.0d0)) then
tmp = t_0
else if (z <= 3d+168) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 0.0 - (y * z);
double tmp;
if (z <= -52000000000000.0) {
tmp = t_0;
} else if (z <= 3e+168) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 0.0 - (y * z) tmp = 0 if z <= -52000000000000.0: tmp = t_0 elif z <= 3e+168: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(0.0 - Float64(y * z)) tmp = 0.0 if (z <= -52000000000000.0) tmp = t_0; elseif (z <= 3e+168) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 0.0 - (y * z); tmp = 0.0; if (z <= -52000000000000.0) tmp = t_0; elseif (z <= 3e+168) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -52000000000000.0], t$95$0, If[LessEqual[z, 3e+168], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0 - y \cdot z\\
\mathbf{if}\;z \leq -52000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+168}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -5.2e13 or 2.9999999999999998e168 < z Initial program 99.7%
Taylor expanded in y around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f6451.7%
Simplified51.7%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f6435.4%
Simplified35.4%
sub0-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f6435.4%
Applied egg-rr35.4%
if -5.2e13 < z < 2.9999999999999998e168Initial program 99.9%
Taylor expanded in y around 0
Simplified50.1%
Final simplification44.2%
(FPCore (x y z) :precision binary64 (- x (* y z)))
double code(double x, double y, double z) {
return x - (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 - (y * z)
end function
public static double code(double x, double y, double z) {
return x - (y * z);
}
def code(x, y, z): return x - (y * z)
function code(x, y, z) return Float64(x - Float64(y * z)) end
function tmp = code(x, y, z) tmp = x - (y * z); end
code[x_, y_, z_] := N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - y \cdot z
\end{array}
Initial program 99.8%
Taylor expanded in y around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f6452.6%
Simplified52.6%
Final simplification52.6%
(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.8%
Taylor expanded in y around 0
Simplified37.5%
herbie shell --seed 2024161
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, A"
:precision binary64
(- (* x (cos y)) (* z (sin y))))