Diagrams.TwoD.Path.Metafont.Internal:hobbyF from diagrams-contrib-1.3.0.5

Percentage Accurate: 99.3% → 99.3%
Time: 1.8min
Alternatives: 4
Speedup: N/A×

Specification

?
\[\begin{array}{l} \\ \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \end{array} \]
(FPCore (x y)
 :precision binary64
 (/
  (+
   2.0
   (*
    (*
     (* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0)))
     (- (sin y) (/ (sin x) 16.0)))
    (- (cos x) (cos y))))
  (*
   3.0
   (+
    (+ 1.0 (* (/ (- (sqrt 5.0) 1.0) 2.0) (cos x)))
    (* (/ (- 3.0 (sqrt 5.0)) 2.0) (cos y))))))
double code(double x, double y) {
	return (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / (3.0 * ((1.0 + (((sqrt(5.0) - 1.0) / 2.0) * cos(x))) + (((3.0 - sqrt(5.0)) / 2.0) * cos(y))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (2.0d0 + (((sqrt(2.0d0) * (sin(x) - (sin(y) / 16.0d0))) * (sin(y) - (sin(x) / 16.0d0))) * (cos(x) - cos(y)))) / (3.0d0 * ((1.0d0 + (((sqrt(5.0d0) - 1.0d0) / 2.0d0) * cos(x))) + (((3.0d0 - sqrt(5.0d0)) / 2.0d0) * cos(y))))
end function
public static double code(double x, double y) {
	return (2.0 + (((Math.sqrt(2.0) * (Math.sin(x) - (Math.sin(y) / 16.0))) * (Math.sin(y) - (Math.sin(x) / 16.0))) * (Math.cos(x) - Math.cos(y)))) / (3.0 * ((1.0 + (((Math.sqrt(5.0) - 1.0) / 2.0) * Math.cos(x))) + (((3.0 - Math.sqrt(5.0)) / 2.0) * Math.cos(y))));
}
def code(x, y):
	return (2.0 + (((math.sqrt(2.0) * (math.sin(x) - (math.sin(y) / 16.0))) * (math.sin(y) - (math.sin(x) / 16.0))) * (math.cos(x) - math.cos(y)))) / (3.0 * ((1.0 + (((math.sqrt(5.0) - 1.0) / 2.0) * math.cos(x))) + (((3.0 - math.sqrt(5.0)) / 2.0) * math.cos(y))))
function code(x, y)
	return Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(sin(y) / 16.0))) * Float64(sin(y) - Float64(sin(x) / 16.0))) * Float64(cos(x) - cos(y)))) / Float64(3.0 * Float64(Float64(1.0 + Float64(Float64(Float64(sqrt(5.0) - 1.0) / 2.0) * cos(x))) + Float64(Float64(Float64(3.0 - sqrt(5.0)) / 2.0) * cos(y)))))
end
function tmp = code(x, y)
	tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / (3.0 * ((1.0 + (((sqrt(5.0) - 1.0) / 2.0) * cos(x))) + (((3.0 - sqrt(5.0)) / 2.0) * cos(y))));
end
code[x_, y_] := N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(N[(1.0 + N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision] / 2.0), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)}
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \end{array} \]
(FPCore (x y)
 :precision binary64
 (/
  (+
   2.0
   (*
    (*
     (* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0)))
     (- (sin y) (/ (sin x) 16.0)))
    (- (cos x) (cos y))))
  (*
   3.0
   (+
    (+ 1.0 (* (/ (- (sqrt 5.0) 1.0) 2.0) (cos x)))
    (* (/ (- 3.0 (sqrt 5.0)) 2.0) (cos y))))))
double code(double x, double y) {
	return (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / (3.0 * ((1.0 + (((sqrt(5.0) - 1.0) / 2.0) * cos(x))) + (((3.0 - sqrt(5.0)) / 2.0) * cos(y))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (2.0d0 + (((sqrt(2.0d0) * (sin(x) - (sin(y) / 16.0d0))) * (sin(y) - (sin(x) / 16.0d0))) * (cos(x) - cos(y)))) / (3.0d0 * ((1.0d0 + (((sqrt(5.0d0) - 1.0d0) / 2.0d0) * cos(x))) + (((3.0d0 - sqrt(5.0d0)) / 2.0d0) * cos(y))))
end function
public static double code(double x, double y) {
	return (2.0 + (((Math.sqrt(2.0) * (Math.sin(x) - (Math.sin(y) / 16.0))) * (Math.sin(y) - (Math.sin(x) / 16.0))) * (Math.cos(x) - Math.cos(y)))) / (3.0 * ((1.0 + (((Math.sqrt(5.0) - 1.0) / 2.0) * Math.cos(x))) + (((3.0 - Math.sqrt(5.0)) / 2.0) * Math.cos(y))));
}
def code(x, y):
	return (2.0 + (((math.sqrt(2.0) * (math.sin(x) - (math.sin(y) / 16.0))) * (math.sin(y) - (math.sin(x) / 16.0))) * (math.cos(x) - math.cos(y)))) / (3.0 * ((1.0 + (((math.sqrt(5.0) - 1.0) / 2.0) * math.cos(x))) + (((3.0 - math.sqrt(5.0)) / 2.0) * math.cos(y))))
function code(x, y)
	return Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(sin(y) / 16.0))) * Float64(sin(y) - Float64(sin(x) / 16.0))) * Float64(cos(x) - cos(y)))) / Float64(3.0 * Float64(Float64(1.0 + Float64(Float64(Float64(sqrt(5.0) - 1.0) / 2.0) * cos(x))) + Float64(Float64(Float64(3.0 - sqrt(5.0)) / 2.0) * cos(y)))))
end
function tmp = code(x, y)
	tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / (3.0 * ((1.0 + (((sqrt(5.0) - 1.0) / 2.0) * cos(x))) + (((3.0 - sqrt(5.0)) / 2.0) * cos(y))));
end
code[x_, y_] := N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(N[(1.0 + N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision] / 2.0), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)}
\end{array}

Alternative 1: 99.3% accurate, N/A× speedup?

\[\begin{array}{l} \\ \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos x, \frac{\mathsf{expm1}\left(\log 5 \cdot 0.5\right)}{2}, 1\right), 3, \left(\cos y \cdot \frac{3 - {5}^{0.5}}{2}\right) \cdot 3\right)} \end{array} \]
(FPCore (x y)
 :precision binary64
 (/
  (+
   2.0
   (*
    (*
     (* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0)))
     (- (sin y) (/ (sin x) 16.0)))
    (- (cos x) (cos y))))
  (fma
   (fma (cos x) (/ (expm1 (* (log 5.0) 0.5)) 2.0) 1.0)
   3.0
   (* (* (cos y) (/ (- 3.0 (pow 5.0 0.5)) 2.0)) 3.0))))
double code(double x, double y) {
	return (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / fma(fma(cos(x), (expm1((log(5.0) * 0.5)) / 2.0), 1.0), 3.0, ((cos(y) * ((3.0 - pow(5.0, 0.5)) / 2.0)) * 3.0));
}
function code(x, y)
	return Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(sin(y) / 16.0))) * Float64(sin(y) - Float64(sin(x) / 16.0))) * Float64(cos(x) - cos(y)))) / fma(fma(cos(x), Float64(expm1(Float64(log(5.0) * 0.5)) / 2.0), 1.0), 3.0, Float64(Float64(cos(y) * Float64(Float64(3.0 - (5.0 ^ 0.5)) / 2.0)) * 3.0)))
end
code[x_, y_] := N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(Exp[N[(N[Log[5.0], $MachinePrecision] * 0.5), $MachinePrecision]] - 1), $MachinePrecision] / 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * 3.0 + N[(N[(N[Cos[y], $MachinePrecision] * N[(N[(3.0 - N[Power[5.0, 0.5], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos x, \frac{\mathsf{expm1}\left(\log 5 \cdot 0.5\right)}{2}, 1\right), 3, \left(\cos y \cdot \frac{3 - {5}^{0.5}}{2}\right) \cdot 3\right)}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\color{blue}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)}} \]
    2. lift-+.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \color{blue}{\left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)}} \]
    3. lift-+.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\color{blue}{\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right)} + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \color{blue}{\frac{\sqrt{5} - 1}{2} \cdot \cos x}\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \]
    5. lift-/.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \color{blue}{\frac{\sqrt{5} - 1}{2}} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \]
    6. lift--.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\color{blue}{\sqrt{5} - 1}}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \]
    7. lift-sqrt.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\color{blue}{\sqrt{5}} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \]
    8. lift-cos.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \color{blue}{\cos x}\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \]
    9. lift-*.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \color{blue}{\frac{3 - \sqrt{5}}{2} \cdot \cos y}\right)} \]
    10. lift-/.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \color{blue}{\frac{3 - \sqrt{5}}{2}} \cdot \cos y\right)} \]
    11. lift--.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{\color{blue}{3 - \sqrt{5}}}{2} \cdot \cos y\right)} \]
    12. lift-sqrt.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \color{blue}{\sqrt{5}}}{2} \cdot \cos y\right)} \]
    13. lift-cos.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \color{blue}{\cos y}\right)} \]
  3. Applied rewrites99.3%

    \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\cos x, \frac{{5}^{0.5} - 1}{2}, 1\right), 3, \left(\cos y \cdot \frac{3 - {5}^{0.5}}{2}\right) \cdot 3\right)}} \]
  4. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos x, \frac{\color{blue}{{5}^{\frac{1}{2}} - 1}}{2}, 1\right), 3, \left(\cos y \cdot \frac{3 - {5}^{\frac{1}{2}}}{2}\right) \cdot 3\right)} \]
    2. lift-pow.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos x, \frac{\color{blue}{{5}^{\frac{1}{2}}} - 1}{2}, 1\right), 3, \left(\cos y \cdot \frac{3 - {5}^{\frac{1}{2}}}{2}\right) \cdot 3\right)} \]
    3. pow-to-expN/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos x, \frac{\color{blue}{e^{\log 5 \cdot \frac{1}{2}}} - 1}{2}, 1\right), 3, \left(\cos y \cdot \frac{3 - {5}^{\frac{1}{2}}}{2}\right) \cdot 3\right)} \]
    4. lower-expm1.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos x, \frac{\color{blue}{\mathsf{expm1}\left(\log 5 \cdot \frac{1}{2}\right)}}{2}, 1\right), 3, \left(\cos y \cdot \frac{3 - {5}^{\frac{1}{2}}}{2}\right) \cdot 3\right)} \]
    5. lower-*.f64N/A

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos x, \frac{\mathsf{expm1}\left(\color{blue}{\log 5 \cdot \frac{1}{2}}\right)}{2}, 1\right), 3, \left(\cos y \cdot \frac{3 - {5}^{\frac{1}{2}}}{2}\right) \cdot 3\right)} \]
    6. lower-log.f6499.3

      \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos x, \frac{\mathsf{expm1}\left(\color{blue}{\log 5} \cdot 0.5\right)}{2}, 1\right), 3, \left(\cos y \cdot \frac{3 - {5}^{0.5}}{2}\right) \cdot 3\right)} \]
  5. Applied rewrites99.3%

    \[\leadsto \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos x, \frac{\color{blue}{\mathsf{expm1}\left(\log 5 \cdot 0.5\right)}}{2}, 1\right), 3, \left(\cos y \cdot \frac{3 - {5}^{0.5}}{2}\right) \cdot 3\right)} \]
  6. Add Preprocessing

Alternative 2: 99.3% accurate, N/A× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left({2}^{0.5} \cdot \left(\cos x - \cos y\right), \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left(\mathsf{expm1}\left(\log 5 \cdot 0.5\right), \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} \cdot 0.3333333333333333 \end{array} \]
(FPCore (x y)
 :precision binary64
 (*
  (/
   (fma
    (* (pow 2.0 0.5) (- (cos x) (cos y)))
    (* (- (sin y) (* 0.0625 (sin x))) (- (sin x) (* 0.0625 (sin y))))
    2.0)
   (fma
    0.5
    (fma (expm1 (* (log 5.0) 0.5)) (cos x) (* (- 3.0 (pow 5.0 0.5)) (cos y)))
    1.0))
  0.3333333333333333))
double code(double x, double y) {
	return (fma((pow(2.0, 0.5) * (cos(x) - cos(y))), ((sin(y) - (0.0625 * sin(x))) * (sin(x) - (0.0625 * sin(y)))), 2.0) / fma(0.5, fma(expm1((log(5.0) * 0.5)), cos(x), ((3.0 - pow(5.0, 0.5)) * cos(y))), 1.0)) * 0.3333333333333333;
}
function code(x, y)
	return Float64(Float64(fma(Float64((2.0 ^ 0.5) * Float64(cos(x) - cos(y))), Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(sin(x) - Float64(0.0625 * sin(y)))), 2.0) / fma(0.5, fma(expm1(Float64(log(5.0) * 0.5)), cos(x), Float64(Float64(3.0 - (5.0 ^ 0.5)) * cos(y))), 1.0)) * 0.3333333333333333)
end
code[x_, y_] := N[(N[(N[(N[(N[Power[2.0, 0.5], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] / N[(0.5 * N[(N[(Exp[N[(N[Log[5.0], $MachinePrecision] * 0.5), $MachinePrecision]] - 1), $MachinePrecision] * N[Cos[x], $MachinePrecision] + N[(N[(3.0 - N[Power[5.0, 0.5], $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]
\begin{array}{l}

\\
\frac{\mathsf{fma}\left({2}^{0.5} \cdot \left(\cos x - \cos y\right), \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left(\mathsf{expm1}\left(\log 5 \cdot 0.5\right), \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} \cdot 0.3333333333333333
\end{array}
Derivation
  1. Initial program 99.3%

    \[\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \]
  2. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{2 + \sqrt{2} \cdot \left(\left(\cos x - \cos y\right) \cdot \left(\left(\sin x - \frac{1}{16} \cdot \sin y\right) \cdot \left(\sin y - \frac{1}{16} \cdot \sin x\right)\right)\right)}{1 + \left(\frac{1}{2} \cdot \left(\cos x \cdot \left(\sqrt{5} - 1\right)\right) + \frac{1}{2} \cdot \left(\cos y \cdot \left(3 - \sqrt{5}\right)\right)\right)}} \]
  3. Applied rewrites99.2%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({2}^{0.5} \cdot \left(\cos x - \cos y\right), \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} \cdot 0.3333333333333333} \]
  4. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left({2}^{\frac{1}{2}} \cdot \left(\cos x - \cos y\right), \left(\sin y - \frac{1}{16} \cdot \sin x\right) \cdot \left(\sin x - \frac{1}{16} \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left({5}^{\frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)} \cdot \frac{1}{3} \]
    2. lift-pow.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left({2}^{\frac{1}{2}} \cdot \left(\cos x - \cos y\right), \left(\sin y - \frac{1}{16} \cdot \sin x\right) \cdot \left(\sin x - \frac{1}{16} \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left({5}^{\frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)} \cdot \frac{1}{3} \]
    3. pow-to-expN/A

      \[\leadsto \frac{\mathsf{fma}\left({2}^{\frac{1}{2}} \cdot \left(\cos x - \cos y\right), \left(\sin y - \frac{1}{16} \cdot \sin x\right) \cdot \left(\sin x - \frac{1}{16} \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left(e^{\log 5 \cdot \frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)} \cdot \frac{1}{3} \]
    4. lower-expm1.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left({2}^{\frac{1}{2}} \cdot \left(\cos x - \cos y\right), \left(\sin y - \frac{1}{16} \cdot \sin x\right) \cdot \left(\sin x - \frac{1}{16} \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left(\mathsf{expm1}\left(\log 5 \cdot \frac{1}{2}\right), \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)} \cdot \frac{1}{3} \]
    5. lower-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left({2}^{\frac{1}{2}} \cdot \left(\cos x - \cos y\right), \left(\sin y - \frac{1}{16} \cdot \sin x\right) \cdot \left(\sin x - \frac{1}{16} \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left(\mathsf{expm1}\left(\log 5 \cdot \frac{1}{2}\right), \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)} \cdot \frac{1}{3} \]
    6. lower-log.f6499.3

      \[\leadsto \frac{\mathsf{fma}\left({2}^{0.5} \cdot \left(\cos x - \cos y\right), \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left(\mathsf{expm1}\left(\log 5 \cdot 0.5\right), \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} \cdot 0.3333333333333333 \]
  5. Applied rewrites99.3%

    \[\leadsto \frac{\mathsf{fma}\left({2}^{0.5} \cdot \left(\cos x - \cos y\right), \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left(\mathsf{expm1}\left(\log 5 \cdot 0.5\right), \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} \cdot 0.3333333333333333 \]
  6. Add Preprocessing

Alternative 3: 99.2% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(3 - {5}^{0.5}\right) \cdot \cos y\\ \left(\frac{\left({2}^{0.5} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right)\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({\left(e^{\log 5}\right)}^{0.5} - 1, \cos x, t\_0\right), 1\right)} + \frac{2}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, t\_0\right), 1\right)}\right) \cdot 0.3333333333333333 \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (- 3.0 (pow 5.0 0.5)) (cos y))))
   (*
    (+
     (/
      (*
       (* (pow 2.0 0.5) (- (cos x) (cos y)))
       (* (- (sin y) (* 0.0625 (sin x))) (- (sin x) (* 0.0625 (sin y)))))
      (fma 0.5 (fma (- (pow (exp (log 5.0)) 0.5) 1.0) (cos x) t_0) 1.0))
     (/ 2.0 (fma 0.5 (fma (- (pow 5.0 0.5) 1.0) (cos x) t_0) 1.0)))
    0.3333333333333333)))
double code(double x, double y) {
	double t_0 = (3.0 - pow(5.0, 0.5)) * cos(y);
	return ((((pow(2.0, 0.5) * (cos(x) - cos(y))) * ((sin(y) - (0.0625 * sin(x))) * (sin(x) - (0.0625 * sin(y))))) / fma(0.5, fma((pow(exp(log(5.0)), 0.5) - 1.0), cos(x), t_0), 1.0)) + (2.0 / fma(0.5, fma((pow(5.0, 0.5) - 1.0), cos(x), t_0), 1.0))) * 0.3333333333333333;
}
function code(x, y)
	t_0 = Float64(Float64(3.0 - (5.0 ^ 0.5)) * cos(y))
	return Float64(Float64(Float64(Float64(Float64((2.0 ^ 0.5) * Float64(cos(x) - cos(y))) * Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(sin(x) - Float64(0.0625 * sin(y))))) / fma(0.5, fma(Float64((exp(log(5.0)) ^ 0.5) - 1.0), cos(x), t_0), 1.0)) + Float64(2.0 / fma(0.5, fma(Float64((5.0 ^ 0.5) - 1.0), cos(x), t_0), 1.0))) * 0.3333333333333333)
end
code[x_, y_] := Block[{t$95$0 = N[(N[(3.0 - N[Power[5.0, 0.5], $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[Power[2.0, 0.5], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(0.5 * N[(N[(N[Power[N[Exp[N[Log[5.0], $MachinePrecision]], $MachinePrecision], 0.5], $MachinePrecision] - 1.0), $MachinePrecision] * N[Cos[x], $MachinePrecision] + t$95$0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(2.0 / N[(0.5 * N[(N[(N[Power[5.0, 0.5], $MachinePrecision] - 1.0), $MachinePrecision] * N[Cos[x], $MachinePrecision] + t$95$0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(3 - {5}^{0.5}\right) \cdot \cos y\\
\left(\frac{\left({2}^{0.5} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right)\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({\left(e^{\log 5}\right)}^{0.5} - 1, \cos x, t\_0\right), 1\right)} + \frac{2}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, t\_0\right), 1\right)}\right) \cdot 0.3333333333333333
\end{array}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \]
  2. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{2 + \sqrt{2} \cdot \left(\left(\cos x - \cos y\right) \cdot \left(\left(\sin x - \frac{1}{16} \cdot \sin y\right) \cdot \left(\sin y - \frac{1}{16} \cdot \sin x\right)\right)\right)}{1 + \left(\frac{1}{2} \cdot \left(\cos x \cdot \left(\sqrt{5} - 1\right)\right) + \frac{1}{2} \cdot \left(\cos y \cdot \left(3 - \sqrt{5}\right)\right)\right)}} \]
  3. Applied rewrites99.2%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({2}^{0.5} \cdot \left(\cos x - \cos y\right), \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} \cdot 0.3333333333333333} \]
  4. Applied rewrites99.2%

    \[\leadsto \left(\frac{\left({2}^{0.5} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right)\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} + \frac{2}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)}\right) \cdot 0.3333333333333333 \]
  5. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto \left(\frac{\left({2}^{\frac{1}{2}} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - \frac{1}{16} \cdot \sin x\right) \cdot \left(\sin x - \frac{1}{16} \cdot \sin y\right)\right)}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left({5}^{\frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)} + \frac{2}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left({5}^{\frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)}\right) \cdot \frac{1}{3} \]
    2. pow-to-expN/A

      \[\leadsto \left(\frac{\left({2}^{\frac{1}{2}} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - \frac{1}{16} \cdot \sin x\right) \cdot \left(\sin x - \frac{1}{16} \cdot \sin y\right)\right)}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left(e^{\log 5 \cdot \frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)} + \frac{2}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left({5}^{\frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)}\right) \cdot \frac{1}{3} \]
    3. lift-log.f64N/A

      \[\leadsto \left(\frac{\left({2}^{\frac{1}{2}} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - \frac{1}{16} \cdot \sin x\right) \cdot \left(\sin x - \frac{1}{16} \cdot \sin y\right)\right)}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left(e^{\log 5 \cdot \frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)} + \frac{2}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left({5}^{\frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)}\right) \cdot \frac{1}{3} \]
    4. exp-prodN/A

      \[\leadsto \left(\frac{\left({2}^{\frac{1}{2}} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - \frac{1}{16} \cdot \sin x\right) \cdot \left(\sin x - \frac{1}{16} \cdot \sin y\right)\right)}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left({\left(e^{\log 5}\right)}^{\frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)} + \frac{2}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left({5}^{\frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)}\right) \cdot \frac{1}{3} \]
    5. lower-pow.f64N/A

      \[\leadsto \left(\frac{\left({2}^{\frac{1}{2}} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - \frac{1}{16} \cdot \sin x\right) \cdot \left(\sin x - \frac{1}{16} \cdot \sin y\right)\right)}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left({\left(e^{\log 5}\right)}^{\frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)} + \frac{2}{\mathsf{fma}\left(\frac{1}{2}, \mathsf{fma}\left({5}^{\frac{1}{2}} - 1, \cos x, \left(3 - {5}^{\frac{1}{2}}\right) \cdot \cos y\right), 1\right)}\right) \cdot \frac{1}{3} \]
    6. lower-exp.f6499.2

      \[\leadsto \left(\frac{\left({2}^{0.5} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right)\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({\left(e^{\log 5}\right)}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} + \frac{2}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)}\right) \cdot 0.3333333333333333 \]
  6. Applied rewrites99.2%

    \[\leadsto \left(\frac{\left({2}^{0.5} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right)\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({\left(e^{\log 5}\right)}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} + \frac{2}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)}\right) \cdot 0.3333333333333333 \]
  7. Add Preprocessing

Alternative 4: 99.2% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)\\ \left(\frac{\left({2}^{0.5} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right)\right)}{t\_0} + \frac{2}{t\_0}\right) \cdot 0.3333333333333333 \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0
         (fma
          0.5
          (fma (- (pow 5.0 0.5) 1.0) (cos x) (* (- 3.0 (pow 5.0 0.5)) (cos y)))
          1.0)))
   (*
    (+
     (/
      (*
       (* (pow 2.0 0.5) (- (cos x) (cos y)))
       (* (- (sin y) (* 0.0625 (sin x))) (- (sin x) (* 0.0625 (sin y)))))
      t_0)
     (/ 2.0 t_0))
    0.3333333333333333)))
double code(double x, double y) {
	double t_0 = fma(0.5, fma((pow(5.0, 0.5) - 1.0), cos(x), ((3.0 - pow(5.0, 0.5)) * cos(y))), 1.0);
	return ((((pow(2.0, 0.5) * (cos(x) - cos(y))) * ((sin(y) - (0.0625 * sin(x))) * (sin(x) - (0.0625 * sin(y))))) / t_0) + (2.0 / t_0)) * 0.3333333333333333;
}
function code(x, y)
	t_0 = fma(0.5, fma(Float64((5.0 ^ 0.5) - 1.0), cos(x), Float64(Float64(3.0 - (5.0 ^ 0.5)) * cos(y))), 1.0)
	return Float64(Float64(Float64(Float64(Float64((2.0 ^ 0.5) * Float64(cos(x) - cos(y))) * Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(sin(x) - Float64(0.0625 * sin(y))))) / t_0) + Float64(2.0 / t_0)) * 0.3333333333333333)
end
code[x_, y_] := Block[{t$95$0 = N[(0.5 * N[(N[(N[Power[5.0, 0.5], $MachinePrecision] - 1.0), $MachinePrecision] * N[Cos[x], $MachinePrecision] + N[(N[(3.0 - N[Power[5.0, 0.5], $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, N[(N[(N[(N[(N[(N[Power[2.0, 0.5], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(2.0 / t$95$0), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)\\
\left(\frac{\left({2}^{0.5} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right)\right)}{t\_0} + \frac{2}{t\_0}\right) \cdot 0.3333333333333333
\end{array}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)} \]
  2. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{2 + \sqrt{2} \cdot \left(\left(\cos x - \cos y\right) \cdot \left(\left(\sin x - \frac{1}{16} \cdot \sin y\right) \cdot \left(\sin y - \frac{1}{16} \cdot \sin x\right)\right)\right)}{1 + \left(\frac{1}{2} \cdot \left(\cos x \cdot \left(\sqrt{5} - 1\right)\right) + \frac{1}{2} \cdot \left(\cos y \cdot \left(3 - \sqrt{5}\right)\right)\right)}} \]
  3. Applied rewrites99.2%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({2}^{0.5} \cdot \left(\cos x - \cos y\right), \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right), 2\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} \cdot 0.3333333333333333} \]
  4. Applied rewrites99.2%

    \[\leadsto \left(\frac{\left({2}^{0.5} \cdot \left(\cos x - \cos y\right)\right) \cdot \left(\left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right)\right)}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)} + \frac{2}{\mathsf{fma}\left(0.5, \mathsf{fma}\left({5}^{0.5} - 1, \cos x, \left(3 - {5}^{0.5}\right) \cdot \cos y\right), 1\right)}\right) \cdot 0.3333333333333333 \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2025093 
(FPCore (x y)
  :name "Diagrams.TwoD.Path.Metafont.Internal:hobbyF from diagrams-contrib-1.3.0.5"
  :precision binary64
  (/ (+ 2.0 (* (* (* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0))) (- (sin y) (/ (sin x) 16.0))) (- (cos x) (cos y)))) (* 3.0 (+ (+ 1.0 (* (/ (- (sqrt 5.0) 1.0) 2.0) (cos x))) (* (/ (- 3.0 (sqrt 5.0)) 2.0) (cos y))))))