
(FPCore (x y z t a b) :precision binary64 (* (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0))) (cos (/ (* (* (+ (* a 2.0) 1.0) b) t) 16.0))))
double code(double x, double y, double z, double t, double a, double b) {
return (x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (x * cos((((((y * 2.0d0) + 1.0d0) * z) * t) / 16.0d0))) * cos((((((a * 2.0d0) + 1.0d0) * b) * t) / 16.0d0))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (x * Math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * Math.cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
}
def code(x, y, z, t, a, b): return (x * math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * math.cos((((((a * 2.0) + 1.0) * b) * t) / 16.0))
function code(x, y, z, t, a, b) return Float64(Float64(x * cos(Float64(Float64(Float64(Float64(Float64(y * 2.0) + 1.0) * z) * t) / 16.0))) * cos(Float64(Float64(Float64(Float64(Float64(a * 2.0) + 1.0) * b) * t) / 16.0))) end
function tmp = code(x, y, z, t, a, b) tmp = (x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * t) / 16.0)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * N[Cos[N[(N[(N[(N[(N[(y * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(N[(N[(N[(a * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision] * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (* (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0))) (cos (/ (* (* (+ (* a 2.0) 1.0) b) t) 16.0))))
double code(double x, double y, double z, double t, double a, double b) {
return (x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (x * cos((((((y * 2.0d0) + 1.0d0) * z) * t) / 16.0d0))) * cos((((((a * 2.0d0) + 1.0d0) * b) * t) / 16.0d0))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (x * Math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * Math.cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
}
def code(x, y, z, t, a, b): return (x * math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * math.cos((((((a * 2.0) + 1.0) * b) * t) / 16.0))
function code(x, y, z, t, a, b) return Float64(Float64(x * cos(Float64(Float64(Float64(Float64(Float64(y * 2.0) + 1.0) * z) * t) / 16.0))) * cos(Float64(Float64(Float64(Float64(Float64(a * 2.0) + 1.0) * b) * t) / 16.0))) end
function tmp = code(x, y, z, t, a, b) tmp = (x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * t) / 16.0)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * N[Cos[N[(N[(N[(N[(N[(y * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(N[(N[(N[(a * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision] * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)
\end{array}
z_m = (fabs.f64 z)
t_m = (fabs.f64 t)
(FPCore (x y z_m t_m a b)
:precision binary64
(let* ((t_1 (cos (/ (* t_m (* (+ 1.0 (* 2.0 a)) b)) 16.0))))
(if (<=
(* (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z_m) t_m) 16.0))) t_1)
1e+271)
(*
t_1
(* x (cos (/ (pow (pow (* z_m t_m) 0.3333333333333333) 3.0) 16.0))))
x)))z_m = fabs(z);
t_m = fabs(t);
double code(double x, double y, double z_m, double t_m, double a, double b) {
double t_1 = cos(((t_m * ((1.0 + (2.0 * a)) * b)) / 16.0));
double tmp;
if (((x * cos((((((y * 2.0) + 1.0) * z_m) * t_m) / 16.0))) * t_1) <= 1e+271) {
tmp = t_1 * (x * cos((pow(pow((z_m * t_m), 0.3333333333333333), 3.0) / 16.0)));
} else {
tmp = x;
}
return tmp;
}
z_m = abs(z)
t_m = abs(t)
real(8) function code(x, y, z_m, t_m, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t_m
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = cos(((t_m * ((1.0d0 + (2.0d0 * a)) * b)) / 16.0d0))
if (((x * cos((((((y * 2.0d0) + 1.0d0) * z_m) * t_m) / 16.0d0))) * t_1) <= 1d+271) then
tmp = t_1 * (x * cos(((((z_m * t_m) ** 0.3333333333333333d0) ** 3.0d0) / 16.0d0)))
else
tmp = x
end if
code = tmp
end function
z_m = Math.abs(z);
t_m = Math.abs(t);
public static double code(double x, double y, double z_m, double t_m, double a, double b) {
double t_1 = Math.cos(((t_m * ((1.0 + (2.0 * a)) * b)) / 16.0));
double tmp;
if (((x * Math.cos((((((y * 2.0) + 1.0) * z_m) * t_m) / 16.0))) * t_1) <= 1e+271) {
tmp = t_1 * (x * Math.cos((Math.pow(Math.pow((z_m * t_m), 0.3333333333333333), 3.0) / 16.0)));
} else {
tmp = x;
}
return tmp;
}
z_m = math.fabs(z) t_m = math.fabs(t) def code(x, y, z_m, t_m, a, b): t_1 = math.cos(((t_m * ((1.0 + (2.0 * a)) * b)) / 16.0)) tmp = 0 if ((x * math.cos((((((y * 2.0) + 1.0) * z_m) * t_m) / 16.0))) * t_1) <= 1e+271: tmp = t_1 * (x * math.cos((math.pow(math.pow((z_m * t_m), 0.3333333333333333), 3.0) / 16.0))) else: tmp = x return tmp
z_m = abs(z) t_m = abs(t) function code(x, y, z_m, t_m, a, b) t_1 = cos(Float64(Float64(t_m * Float64(Float64(1.0 + Float64(2.0 * a)) * b)) / 16.0)) tmp = 0.0 if (Float64(Float64(x * cos(Float64(Float64(Float64(Float64(Float64(y * 2.0) + 1.0) * z_m) * t_m) / 16.0))) * t_1) <= 1e+271) tmp = Float64(t_1 * Float64(x * cos(Float64(((Float64(z_m * t_m) ^ 0.3333333333333333) ^ 3.0) / 16.0)))); else tmp = x; end return tmp end
z_m = abs(z); t_m = abs(t); function tmp_2 = code(x, y, z_m, t_m, a, b) t_1 = cos(((t_m * ((1.0 + (2.0 * a)) * b)) / 16.0)); tmp = 0.0; if (((x * cos((((((y * 2.0) + 1.0) * z_m) * t_m) / 16.0))) * t_1) <= 1e+271) tmp = t_1 * (x * cos(((((z_m * t_m) ^ 0.3333333333333333) ^ 3.0) / 16.0))); else tmp = x; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision]
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z$95$m_, t$95$m_, a_, b_] := Block[{t$95$1 = N[Cos[N[(N[(t$95$m * N[(N[(1.0 + N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(x * N[Cos[N[(N[(N[(N[(N[(y * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * z$95$m), $MachinePrecision] * t$95$m), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], 1e+271], N[(t$95$1 * N[(x * N[Cos[N[(N[Power[N[Power[N[(z$95$m * t$95$m), $MachinePrecision], 0.3333333333333333], $MachinePrecision], 3.0], $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
z_m = \left|z\right|
\\
t_m = \left|t\right|
\\
\begin{array}{l}
t_1 := \cos \left(\frac{t\_m \cdot \left(\left(1 + 2 \cdot a\right) \cdot b\right)}{16}\right)\\
\mathbf{if}\;\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\_m\right) \cdot t\_m}{16}\right)\right) \cdot t\_1 \leq 10^{+271}:\\
\;\;\;\;t\_1 \cdot \left(x \cdot \cos \left(\frac{{\left({\left(z\_m \cdot t\_m\right)}^{0.3333333333333333}\right)}^{3}}{16}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y 2) 1) z) t) 16))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a 2) 1) b) t) 16))) < 9.99999999999999953e270Initial program 49.7%
add-cube-cbrt50.2%
pow350.0%
*-commutative50.0%
fma-define50.0%
*-commutative50.0%
Applied egg-rr50.0%
Taylor expanded in y around 0 33.3%
if 9.99999999999999953e270 < (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y 2) 1) z) t) 16))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a 2) 1) b) t) 16))) Initial program 3.7%
Simplified5.5%
Taylor expanded in z around 0 7.5%
Taylor expanded in t around 0 13.6%
Final simplification26.2%
z_m = (fabs.f64 z)
t_m = (fabs.f64 t)
(FPCore (x y z_m t_m a b)
:precision binary64
(let* ((t_1
(*
(* x (cos (/ (* (* (+ (* y 2.0) 1.0) z_m) t_m) 16.0)))
(cos (/ (* t_m (* (+ 1.0 (* 2.0 a)) b)) 16.0)))))
(if (<= t_1 5e+199) t_1 x)))z_m = fabs(z);
t_m = fabs(t);
double code(double x, double y, double z_m, double t_m, double a, double b) {
double t_1 = (x * cos((((((y * 2.0) + 1.0) * z_m) * t_m) / 16.0))) * cos(((t_m * ((1.0 + (2.0 * a)) * b)) / 16.0));
double tmp;
if (t_1 <= 5e+199) {
tmp = t_1;
} else {
tmp = x;
}
return tmp;
}
z_m = abs(z)
t_m = abs(t)
real(8) function code(x, y, z_m, t_m, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t_m
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = (x * cos((((((y * 2.0d0) + 1.0d0) * z_m) * t_m) / 16.0d0))) * cos(((t_m * ((1.0d0 + (2.0d0 * a)) * b)) / 16.0d0))
if (t_1 <= 5d+199) then
tmp = t_1
else
tmp = x
end if
code = tmp
end function
z_m = Math.abs(z);
t_m = Math.abs(t);
public static double code(double x, double y, double z_m, double t_m, double a, double b) {
double t_1 = (x * Math.cos((((((y * 2.0) + 1.0) * z_m) * t_m) / 16.0))) * Math.cos(((t_m * ((1.0 + (2.0 * a)) * b)) / 16.0));
double tmp;
if (t_1 <= 5e+199) {
tmp = t_1;
} else {
tmp = x;
}
return tmp;
}
z_m = math.fabs(z) t_m = math.fabs(t) def code(x, y, z_m, t_m, a, b): t_1 = (x * math.cos((((((y * 2.0) + 1.0) * z_m) * t_m) / 16.0))) * math.cos(((t_m * ((1.0 + (2.0 * a)) * b)) / 16.0)) tmp = 0 if t_1 <= 5e+199: tmp = t_1 else: tmp = x return tmp
z_m = abs(z) t_m = abs(t) function code(x, y, z_m, t_m, a, b) t_1 = Float64(Float64(x * cos(Float64(Float64(Float64(Float64(Float64(y * 2.0) + 1.0) * z_m) * t_m) / 16.0))) * cos(Float64(Float64(t_m * Float64(Float64(1.0 + Float64(2.0 * a)) * b)) / 16.0))) tmp = 0.0 if (t_1 <= 5e+199) tmp = t_1; else tmp = x; end return tmp end
z_m = abs(z); t_m = abs(t); function tmp_2 = code(x, y, z_m, t_m, a, b) t_1 = (x * cos((((((y * 2.0) + 1.0) * z_m) * t_m) / 16.0))) * cos(((t_m * ((1.0 + (2.0 * a)) * b)) / 16.0)); tmp = 0.0; if (t_1 <= 5e+199) tmp = t_1; else tmp = x; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision]
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z$95$m_, t$95$m_, a_, b_] := Block[{t$95$1 = N[(N[(x * N[Cos[N[(N[(N[(N[(N[(y * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * z$95$m), $MachinePrecision] * t$95$m), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(t$95$m * N[(N[(1.0 + N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+199], t$95$1, x]]
\begin{array}{l}
z_m = \left|z\right|
\\
t_m = \left|t\right|
\\
\begin{array}{l}
t_1 := \left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\_m\right) \cdot t\_m}{16}\right)\right) \cdot \cos \left(\frac{t\_m \cdot \left(\left(1 + 2 \cdot a\right) \cdot b\right)}{16}\right)\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+199}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y 2) 1) z) t) 16))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a 2) 1) b) t) 16))) < 4.9999999999999998e199Initial program 51.9%
if 4.9999999999999998e199 < (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y 2) 1) z) t) 16))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a 2) 1) b) t) 16))) Initial program 5.3%
Simplified7.0%
Taylor expanded in z around 0 8.6%
Taylor expanded in t around 0 13.7%
Final simplification36.4%
z_m = (fabs.f64 z) t_m = (fabs.f64 t) (FPCore (x y z_m t_m a b) :precision binary64 (* x (cos (pow (cbrt (* 0.0625 (* t_m b))) 3.0))))
z_m = fabs(z);
t_m = fabs(t);
double code(double x, double y, double z_m, double t_m, double a, double b) {
return x * cos(pow(cbrt((0.0625 * (t_m * b))), 3.0));
}
z_m = Math.abs(z);
t_m = Math.abs(t);
public static double code(double x, double y, double z_m, double t_m, double a, double b) {
return x * Math.cos(Math.pow(Math.cbrt((0.0625 * (t_m * b))), 3.0));
}
z_m = abs(z) t_m = abs(t) function code(x, y, z_m, t_m, a, b) return Float64(x * cos((cbrt(Float64(0.0625 * Float64(t_m * b))) ^ 3.0))) end
z_m = N[Abs[z], $MachinePrecision] t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z$95$m_, t$95$m_, a_, b_] := N[(x * N[Cos[N[Power[N[Power[N[(0.0625 * N[(t$95$m * b), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
t_m = \left|t\right|
\\
x \cdot \cos \left({\left(\sqrt[3]{0.0625 \cdot \left(t\_m \cdot b\right)}\right)}^{3}\right)
\end{array}
Initial program 33.0%
Simplified33.4%
Taylor expanded in z around 0 34.3%
add-cube-cbrt34.2%
pow334.3%
associate-*r*34.7%
div-inv34.7%
metadata-eval34.7%
Applied egg-rr34.7%
Taylor expanded in a around 0 35.2%
Final simplification35.2%
z_m = (fabs.f64 z)
t_m = (fabs.f64 t)
(FPCore (x y z_m t_m a b)
:precision binary64
(if (<= t_m 1.7e+34)
(*
(* x (cos (/ (* z_m t_m) 16.0)))
(cos (* (* t_m b) (+ 0.0625 (* a 0.125)))))
x))z_m = fabs(z);
t_m = fabs(t);
double code(double x, double y, double z_m, double t_m, double a, double b) {
double tmp;
if (t_m <= 1.7e+34) {
tmp = (x * cos(((z_m * t_m) / 16.0))) * cos(((t_m * b) * (0.0625 + (a * 0.125))));
} else {
tmp = x;
}
return tmp;
}
z_m = abs(z)
t_m = abs(t)
real(8) function code(x, y, z_m, t_m, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t_m
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (t_m <= 1.7d+34) then
tmp = (x * cos(((z_m * t_m) / 16.0d0))) * cos(((t_m * b) * (0.0625d0 + (a * 0.125d0))))
else
tmp = x
end if
code = tmp
end function
z_m = Math.abs(z);
t_m = Math.abs(t);
public static double code(double x, double y, double z_m, double t_m, double a, double b) {
double tmp;
if (t_m <= 1.7e+34) {
tmp = (x * Math.cos(((z_m * t_m) / 16.0))) * Math.cos(((t_m * b) * (0.0625 + (a * 0.125))));
} else {
tmp = x;
}
return tmp;
}
z_m = math.fabs(z) t_m = math.fabs(t) def code(x, y, z_m, t_m, a, b): tmp = 0 if t_m <= 1.7e+34: tmp = (x * math.cos(((z_m * t_m) / 16.0))) * math.cos(((t_m * b) * (0.0625 + (a * 0.125)))) else: tmp = x return tmp
z_m = abs(z) t_m = abs(t) function code(x, y, z_m, t_m, a, b) tmp = 0.0 if (t_m <= 1.7e+34) tmp = Float64(Float64(x * cos(Float64(Float64(z_m * t_m) / 16.0))) * cos(Float64(Float64(t_m * b) * Float64(0.0625 + Float64(a * 0.125))))); else tmp = x; end return tmp end
z_m = abs(z); t_m = abs(t); function tmp_2 = code(x, y, z_m, t_m, a, b) tmp = 0.0; if (t_m <= 1.7e+34) tmp = (x * cos(((z_m * t_m) / 16.0))) * cos(((t_m * b) * (0.0625 + (a * 0.125)))); else tmp = x; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision] t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z$95$m_, t$95$m_, a_, b_] := If[LessEqual[t$95$m, 1.7e+34], N[(N[(x * N[Cos[N[(N[(z$95$m * t$95$m), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(t$95$m * b), $MachinePrecision] * N[(0.0625 + N[(a * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
z_m = \left|z\right|
\\
t_m = \left|t\right|
\\
\begin{array}{l}
\mathbf{if}\;t\_m \leq 1.7 \cdot 10^{+34}:\\
\;\;\;\;\left(x \cdot \cos \left(\frac{z\_m \cdot t\_m}{16}\right)\right) \cdot \cos \left(\left(t\_m \cdot b\right) \cdot \left(0.0625 + a \cdot 0.125\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < 1.7e34Initial program 38.8%
Taylor expanded in y around 0 39.9%
Taylor expanded in a around 0 40.3%
+-commutative40.3%
associate-*r*40.4%
*-commutative40.4%
*-commutative40.4%
distribute-rgt-out40.4%
*-commutative40.4%
*-commutative40.4%
Simplified40.4%
if 1.7e34 < t Initial program 9.0%
Simplified8.4%
Taylor expanded in z around 0 12.6%
Taylor expanded in t around 0 14.1%
Final simplification35.2%
z_m = (fabs.f64 z) t_m = (fabs.f64 t) (FPCore (x y z_m t_m a b) :precision binary64 (* x (cos (* (* t_m b) (+ 0.0625 (* a 0.125))))))
z_m = fabs(z);
t_m = fabs(t);
double code(double x, double y, double z_m, double t_m, double a, double b) {
return x * cos(((t_m * b) * (0.0625 + (a * 0.125))));
}
z_m = abs(z)
t_m = abs(t)
real(8) function code(x, y, z_m, t_m, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t_m
real(8), intent (in) :: a
real(8), intent (in) :: b
code = x * cos(((t_m * b) * (0.0625d0 + (a * 0.125d0))))
end function
z_m = Math.abs(z);
t_m = Math.abs(t);
public static double code(double x, double y, double z_m, double t_m, double a, double b) {
return x * Math.cos(((t_m * b) * (0.0625 + (a * 0.125))));
}
z_m = math.fabs(z) t_m = math.fabs(t) def code(x, y, z_m, t_m, a, b): return x * math.cos(((t_m * b) * (0.0625 + (a * 0.125))))
z_m = abs(z) t_m = abs(t) function code(x, y, z_m, t_m, a, b) return Float64(x * cos(Float64(Float64(t_m * b) * Float64(0.0625 + Float64(a * 0.125))))) end
z_m = abs(z); t_m = abs(t); function tmp = code(x, y, z_m, t_m, a, b) tmp = x * cos(((t_m * b) * (0.0625 + (a * 0.125)))); end
z_m = N[Abs[z], $MachinePrecision] t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z$95$m_, t$95$m_, a_, b_] := N[(x * N[Cos[N[(N[(t$95$m * b), $MachinePrecision] * N[(0.0625 + N[(a * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
t_m = \left|t\right|
\\
x \cdot \cos \left(\left(t\_m \cdot b\right) \cdot \left(0.0625 + a \cdot 0.125\right)\right)
\end{array}
Initial program 33.0%
Simplified33.4%
Taylor expanded in z around 0 34.3%
Taylor expanded in a around 0 34.6%
+-commutative34.6%
associate-*r*34.7%
distribute-rgt-out34.7%
*-commutative34.7%
*-commutative34.7%
Simplified34.7%
Final simplification34.7%
z_m = (fabs.f64 z) t_m = (fabs.f64 t) (FPCore (x y z_m t_m a b) :precision binary64 x)
z_m = fabs(z);
t_m = fabs(t);
double code(double x, double y, double z_m, double t_m, double a, double b) {
return x;
}
z_m = abs(z)
t_m = abs(t)
real(8) function code(x, y, z_m, t_m, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t_m
real(8), intent (in) :: a
real(8), intent (in) :: b
code = x
end function
z_m = Math.abs(z);
t_m = Math.abs(t);
public static double code(double x, double y, double z_m, double t_m, double a, double b) {
return x;
}
z_m = math.fabs(z) t_m = math.fabs(t) def code(x, y, z_m, t_m, a, b): return x
z_m = abs(z) t_m = abs(t) function code(x, y, z_m, t_m, a, b) return x end
z_m = abs(z); t_m = abs(t); function tmp = code(x, y, z_m, t_m, a, b) tmp = x; end
z_m = N[Abs[z], $MachinePrecision] t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z$95$m_, t$95$m_, a_, b_] := x
\begin{array}{l}
z_m = \left|z\right|
\\
t_m = \left|t\right|
\\
x
\end{array}
Initial program 33.0%
Simplified33.4%
Taylor expanded in z around 0 34.3%
Taylor expanded in t around 0 34.7%
Final simplification34.7%
(FPCore (x y z t a b) :precision binary64 (* x (cos (* (/ b 16.0) (/ t (+ (- 1.0 (* a 2.0)) (pow (* a 2.0) 2.0)))))))
double code(double x, double y, double z, double t, double a, double b) {
return x * cos(((b / 16.0) * (t / ((1.0 - (a * 2.0)) + pow((a * 2.0), 2.0)))));
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = x * cos(((b / 16.0d0) * (t / ((1.0d0 - (a * 2.0d0)) + ((a * 2.0d0) ** 2.0d0)))))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * Math.cos(((b / 16.0) * (t / ((1.0 - (a * 2.0)) + Math.pow((a * 2.0), 2.0)))));
}
def code(x, y, z, t, a, b): return x * math.cos(((b / 16.0) * (t / ((1.0 - (a * 2.0)) + math.pow((a * 2.0), 2.0)))))
function code(x, y, z, t, a, b) return Float64(x * cos(Float64(Float64(b / 16.0) * Float64(t / Float64(Float64(1.0 - Float64(a * 2.0)) + (Float64(a * 2.0) ^ 2.0)))))) end
function tmp = code(x, y, z, t, a, b) tmp = x * cos(((b / 16.0) * (t / ((1.0 - (a * 2.0)) + ((a * 2.0) ^ 2.0))))); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Cos[N[(N[(b / 16.0), $MachinePrecision] * N[(t / N[(N[(1.0 - N[(a * 2.0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(a * 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos \left(\frac{b}{16} \cdot \frac{t}{\left(1 - a \cdot 2\right) + {\left(a \cdot 2\right)}^{2}}\right)
\end{array}
herbie shell --seed 2024030
(FPCore (x y z t a b)
:name "Codec.Picture.Jpg.FastDct:referenceDct from JuicyPixels-3.2.6.1"
:precision binary64
:herbie-target
(* x (cos (* (/ b 16.0) (/ t (+ (- 1.0 (* a 2.0)) (pow (* a 2.0) 2.0))))))
(* (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0))) (cos (/ (* (* (+ (* a 2.0) 1.0) b) t) 16.0))))