(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))))
(FPCore (x y z t a b) :precision binary64 x)
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));
}
double code(double x, double y, double z, double t, double a, double b) {
return x;
}
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
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
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));
}
public static double code(double x, double y, double z, double t, double a, double b) {
return x;
}
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))
def code(x, y, z, t, a, b): return x
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 code(x, y, z, t, a, b) return x 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
function tmp = code(x, y, z, t, a, b) tmp = x; 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]
code[x_, y_, z_, t_, a_, b_] := x
\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)
x
Results
| Original | 46.3 |
|---|---|
| Target | 44.4 |
| Herbie | 44.1 |
Initial program 46.3
Simplified46.3
[Start]46.3 | \[ \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)
\] |
|---|---|
rational.json-simplify-49 [=>]46.3 | \[ \left(x \cdot \cos \color{blue}{\left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)}\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)
\] |
trig.json-simplify-24 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \color{blue}{\cos \left(-\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)}
\] |
trig.json-simplify-24 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \color{blue}{\cos \left(-\left(-\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right)}
\] |
rational.json-simplify-10 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \color{blue}{\left(\frac{-\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}}{-1}\right)}
\] |
rational.json-simplify-10 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \left(\frac{\color{blue}{\frac{\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}}{-1}}}{-1}\right)
\] |
rational.json-simplify-49 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \left(\frac{\frac{\color{blue}{t \cdot \frac{\left(a \cdot 2 + 1\right) \cdot b}{16}}}{-1}}{-1}\right)
\] |
rational.json-simplify-2 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \left(\frac{\frac{\color{blue}{\frac{\left(a \cdot 2 + 1\right) \cdot b}{16} \cdot t}}{-1}}{-1}\right)
\] |
rational.json-simplify-49 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \left(\frac{\color{blue}{t \cdot \frac{\frac{\left(a \cdot 2 + 1\right) \cdot b}{16}}{-1}}}{-1}\right)
\] |
rational.json-simplify-2 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \left(\frac{\color{blue}{\frac{\frac{\left(a \cdot 2 + 1\right) \cdot b}{16}}{-1} \cdot t}}{-1}\right)
\] |
rational.json-simplify-49 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \color{blue}{\left(t \cdot \frac{\frac{\frac{\left(a \cdot 2 + 1\right) \cdot b}{16}}{-1}}{-1}\right)}
\] |
rational.json-simplify-47 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \left(t \cdot \color{blue}{\frac{\frac{\left(a \cdot 2 + 1\right) \cdot b}{16}}{-1 \cdot -1}}\right)
\] |
metadata-eval [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \left(t \cdot \frac{\frac{\left(a \cdot 2 + 1\right) \cdot b}{16}}{\color{blue}{1}}\right)
\] |
rational.json-simplify-7 [=>]46.3 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \left(t \cdot \color{blue}{\frac{\left(a \cdot 2 + 1\right) \cdot b}{16}}\right)
\] |
Taylor expanded in a around 0 45.8
Simplified45.8
[Start]45.8 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \left(0.0625 \cdot \left(t \cdot b\right)\right)
\] |
|---|---|
rational.json-simplify-43 [=>]45.8 | \[ \left(x \cdot \cos \left(t \cdot \frac{\left(y \cdot 2 + 1\right) \cdot z}{16}\right)\right) \cdot \cos \color{blue}{\left(t \cdot \left(b \cdot 0.0625\right)\right)}
\] |
Taylor expanded in t around 0 44.8
Taylor expanded in t around 0 44.1
Final simplification44.1
herbie shell --seed 2023074
(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))))