Trigonometry A

Percentage Accurate: 99.8% → 99.8%
Time: 10.1s
Alternatives: 11
Speedup: N/A×

Specification

?
\[0 \leq e \land e \leq 1\]
\[\begin{array}{l} \\ \frac{e \cdot \sin v}{1 + e \cdot \cos v} \end{array} \]
(FPCore (e v) :precision binary64 (/ (* e (sin v)) (+ 1.0 (* e (cos v)))))
double code(double e, double v) {
	return (e * sin(v)) / (1.0 + (e * cos(v)));
}
real(8) function code(e, v)
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = (e * sin(v)) / (1.0d0 + (e * cos(v)))
end function
public static double code(double e, double v) {
	return (e * Math.sin(v)) / (1.0 + (e * Math.cos(v)));
}
def code(e, v):
	return (e * math.sin(v)) / (1.0 + (e * math.cos(v)))
function code(e, v)
	return Float64(Float64(e * sin(v)) / Float64(1.0 + Float64(e * cos(v))))
end
function tmp = code(e, v)
	tmp = (e * sin(v)) / (1.0 + (e * cos(v)));
end
code[e_, v_] := N[(N[(e * N[Sin[v], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(e * N[Cos[v], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{e \cdot \sin v}{1 + e \cdot \cos v}
\end{array}

Sampling outcomes in binary64 precision:

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 11 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.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{e \cdot \sin v}{1 + e \cdot \cos v} \end{array} \]
(FPCore (e v) :precision binary64 (/ (* e (sin v)) (+ 1.0 (* e (cos v)))))
double code(double e, double v) {
	return (e * sin(v)) / (1.0 + (e * cos(v)));
}
real(8) function code(e, v)
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = (e * sin(v)) / (1.0d0 + (e * cos(v)))
end function
public static double code(double e, double v) {
	return (e * Math.sin(v)) / (1.0 + (e * Math.cos(v)));
}
def code(e, v):
	return (e * math.sin(v)) / (1.0 + (e * math.cos(v)))
function code(e, v)
	return Float64(Float64(e * sin(v)) / Float64(1.0 + Float64(e * cos(v))))
end
function tmp = code(e, v)
	tmp = (e * sin(v)) / (1.0 + (e * cos(v)));
end
code[e_, v_] := N[(N[(e * N[Sin[v], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(e * N[Cos[v], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{e \cdot \sin v}{1 + e \cdot \cos v}
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ e \cdot \frac{\sin v}{\mathsf{fma}\left(e, \cos v, 1\right)} \end{array} \]
(FPCore (e v) :precision binary64 (* e (/ (sin v) (fma e (cos v) 1.0))))
double code(double e, double v) {
	return e * (sin(v) / fma(e, cos(v), 1.0));
}
function code(e, v)
	return Float64(e * Float64(sin(v) / fma(e, cos(v), 1.0)))
end
code[e_, v_] := N[(e * N[(N[Sin[v], $MachinePrecision] / N[(e * N[Cos[v], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
e \cdot \frac{\sin v}{\mathsf{fma}\left(e, \cos v, 1\right)}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/l*N/A

      \[\leadsto \color{blue}{e \cdot \frac{\sin v}{1 + e \cdot \cos v}} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\frac{\sin v}{1 + e \cdot \cos v} \cdot e} \]
    3. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\frac{\sin v}{1 + e \cdot \cos v} \cdot e} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{\sin v}{1 + e \cdot \cos v}} \cdot e \]
    5. sin-lowering-sin.f64N/A

      \[\leadsto \frac{\color{blue}{\sin v}}{1 + e \cdot \cos v} \cdot e \]
    6. +-commutativeN/A

      \[\leadsto \frac{\sin v}{\color{blue}{e \cdot \cos v + 1}} \cdot e \]
    7. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{\sin v}{\color{blue}{\mathsf{fma}\left(e, \cos v, 1\right)}} \cdot e \]
    8. cos-lowering-cos.f6499.8

      \[\leadsto \frac{\sin v}{\mathsf{fma}\left(e, \color{blue}{\cos v}, 1\right)} \cdot e \]
  4. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\frac{\sin v}{\mathsf{fma}\left(e, \cos v, 1\right)} \cdot e} \]
  5. Final simplification99.8%

    \[\leadsto e \cdot \frac{\sin v}{\mathsf{fma}\left(e, \cos v, 1\right)} \]
  6. Add Preprocessing

Alternative 2: 98.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \sin v \cdot \frac{e}{e + 1} \end{array} \]
(FPCore (e v) :precision binary64 (* (sin v) (/ e (+ e 1.0))))
double code(double e, double v) {
	return sin(v) * (e / (e + 1.0));
}
real(8) function code(e, v)
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = sin(v) * (e / (e + 1.0d0))
end function
public static double code(double e, double v) {
	return Math.sin(v) * (e / (e + 1.0));
}
def code(e, v):
	return math.sin(v) * (e / (e + 1.0))
function code(e, v)
	return Float64(sin(v) * Float64(e / Float64(e + 1.0)))
end
function tmp = code(e, v)
	tmp = sin(v) * (e / (e + 1.0));
end
code[e_, v_] := N[(N[Sin[v], $MachinePrecision] * N[(e / N[(e + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin v \cdot \frac{e}{e + 1}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{1 + e \cdot \cos v}{e \cdot \sin v}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{1 + e \cdot \cos v}{e \cdot \sin v}}} \]
    3. /-lowering-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1 + e \cdot \cos v}{e \cdot \sin v}}} \]
    4. +-commutativeN/A

      \[\leadsto \frac{1}{\frac{\color{blue}{e \cdot \cos v + 1}}{e \cdot \sin v}} \]
    5. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(e, \cos v, 1\right)}}{e \cdot \sin v}} \]
    6. cos-lowering-cos.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(e, \color{blue}{\cos v}, 1\right)}{e \cdot \sin v}} \]
    7. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{\color{blue}{e \cdot \sin v}}} \]
    8. sin-lowering-sin.f6498.5

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{e \cdot \color{blue}{\sin v}}} \]
  4. Applied egg-rr98.5%

    \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{e \cdot \sin v}}} \]
  5. Step-by-step derivation
    1. associate-/r*N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{e \cdot \cos v + 1}{e}}{\sin v}}} \]
    2. clear-numN/A

      \[\leadsto \color{blue}{\frac{\sin v}{\frac{e \cdot \cos v + 1}{e}}} \]
    3. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{\sin v}{\frac{e \cdot \cos v + 1}{e}}} \]
    4. sin-lowering-sin.f64N/A

      \[\leadsto \frac{\color{blue}{\sin v}}{\frac{e \cdot \cos v + 1}{e}} \]
    5. /-lowering-/.f64N/A

      \[\leadsto \frac{\sin v}{\color{blue}{\frac{e \cdot \cos v + 1}{e}}} \]
    6. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{\sin v}{\frac{\color{blue}{\mathsf{fma}\left(e, \cos v, 1\right)}}{e}} \]
    7. cos-lowering-cos.f6499.7

      \[\leadsto \frac{\sin v}{\frac{\mathsf{fma}\left(e, \color{blue}{\cos v}, 1\right)}{e}} \]
  6. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\frac{\sin v}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{e}}} \]
  7. Taylor expanded in v around 0

    \[\leadsto \frac{\sin v}{\color{blue}{\frac{1 + e}{e}}} \]
  8. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \frac{\sin v}{\color{blue}{\frac{1 + e}{e}}} \]
    2. +-commutativeN/A

      \[\leadsto \frac{\sin v}{\frac{\color{blue}{e + 1}}{e}} \]
    3. +-lowering-+.f6499.0

      \[\leadsto \frac{\sin v}{\frac{\color{blue}{e + 1}}{e}} \]
  9. Simplified99.0%

    \[\leadsto \frac{\sin v}{\color{blue}{\frac{e + 1}{e}}} \]
  10. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{e + 1}{e}}{\sin v}}} \]
    2. associate-/r/N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{e + 1}{e}} \cdot \sin v} \]
    3. clear-numN/A

      \[\leadsto \color{blue}{\frac{e}{e + 1}} \cdot \sin v \]
    4. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\frac{e}{e + 1} \cdot \sin v} \]
    5. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{e}{e + 1}} \cdot \sin v \]
    6. +-lowering-+.f64N/A

      \[\leadsto \frac{e}{\color{blue}{e + 1}} \cdot \sin v \]
    7. sin-lowering-sin.f6499.2

      \[\leadsto \frac{e}{e + 1} \cdot \color{blue}{\sin v} \]
  11. Applied egg-rr99.2%

    \[\leadsto \color{blue}{\frac{e}{e + 1} \cdot \sin v} \]
  12. Final simplification99.2%

    \[\leadsto \sin v \cdot \frac{e}{e + 1} \]
  13. Add Preprocessing

Alternative 3: 98.1% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \left(1 - e\right) \cdot \left(\sin v \cdot e\right) \end{array} \]
(FPCore (e v) :precision binary64 (* (- 1.0 e) (* (sin v) e)))
double code(double e, double v) {
	return (1.0 - e) * (sin(v) * e);
}
real(8) function code(e, v)
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = (1.0d0 - e) * (sin(v) * e)
end function
public static double code(double e, double v) {
	return (1.0 - e) * (Math.sin(v) * e);
}
def code(e, v):
	return (1.0 - e) * (math.sin(v) * e)
function code(e, v)
	return Float64(Float64(1.0 - e) * Float64(sin(v) * e))
end
function tmp = code(e, v)
	tmp = (1.0 - e) * (sin(v) * e);
end
code[e_, v_] := N[(N[(1.0 - e), $MachinePrecision] * N[(N[Sin[v], $MachinePrecision] * e), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(1 - e\right) \cdot \left(\sin v \cdot e\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. Taylor expanded in e around 0

    \[\leadsto \color{blue}{e \cdot \left(\sin v + -1 \cdot \left(e \cdot \left(\cos v \cdot \sin v\right)\right)\right)} \]
  4. Step-by-step derivation
    1. distribute-lft-inN/A

      \[\leadsto \color{blue}{e \cdot \sin v + e \cdot \left(-1 \cdot \left(e \cdot \left(\cos v \cdot \sin v\right)\right)\right)} \]
    2. mul-1-negN/A

      \[\leadsto e \cdot \sin v + e \cdot \color{blue}{\left(\mathsf{neg}\left(e \cdot \left(\cos v \cdot \sin v\right)\right)\right)} \]
    3. distribute-rgt-neg-outN/A

      \[\leadsto e \cdot \sin v + \color{blue}{\left(\mathsf{neg}\left(e \cdot \left(e \cdot \left(\cos v \cdot \sin v\right)\right)\right)\right)} \]
    4. associate-*r*N/A

      \[\leadsto e \cdot \sin v + \left(\mathsf{neg}\left(e \cdot \color{blue}{\left(\left(e \cdot \cos v\right) \cdot \sin v\right)}\right)\right) \]
    5. *-commutativeN/A

      \[\leadsto e \cdot \sin v + \left(\mathsf{neg}\left(e \cdot \left(\color{blue}{\left(\cos v \cdot e\right)} \cdot \sin v\right)\right)\right) \]
    6. associate-*l*N/A

      \[\leadsto e \cdot \sin v + \left(\mathsf{neg}\left(e \cdot \color{blue}{\left(\cos v \cdot \left(e \cdot \sin v\right)\right)}\right)\right) \]
    7. associate-*r*N/A

      \[\leadsto e \cdot \sin v + \left(\mathsf{neg}\left(\color{blue}{\left(e \cdot \cos v\right) \cdot \left(e \cdot \sin v\right)}\right)\right) \]
    8. distribute-lft-neg-inN/A

      \[\leadsto e \cdot \sin v + \color{blue}{\left(\mathsf{neg}\left(e \cdot \cos v\right)\right) \cdot \left(e \cdot \sin v\right)} \]
    9. distribute-rgt1-inN/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(e \cdot \cos v\right)\right) + 1\right) \cdot \left(e \cdot \sin v\right)} \]
    10. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(e \cdot \cos v\right)\right) + 1\right) \cdot \left(e \cdot \sin v\right)} \]
    11. distribute-rgt-neg-inN/A

      \[\leadsto \left(\color{blue}{e \cdot \left(\mathsf{neg}\left(\cos v\right)\right)} + 1\right) \cdot \left(e \cdot \sin v\right) \]
    12. mul-1-negN/A

      \[\leadsto \left(e \cdot \color{blue}{\left(-1 \cdot \cos v\right)} + 1\right) \cdot \left(e \cdot \sin v\right) \]
    13. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(e, -1 \cdot \cos v, 1\right)} \cdot \left(e \cdot \sin v\right) \]
    14. mul-1-negN/A

      \[\leadsto \mathsf{fma}\left(e, \color{blue}{\mathsf{neg}\left(\cos v\right)}, 1\right) \cdot \left(e \cdot \sin v\right) \]
    15. neg-sub0N/A

      \[\leadsto \mathsf{fma}\left(e, \color{blue}{0 - \cos v}, 1\right) \cdot \left(e \cdot \sin v\right) \]
    16. --lowering--.f64N/A

      \[\leadsto \mathsf{fma}\left(e, \color{blue}{0 - \cos v}, 1\right) \cdot \left(e \cdot \sin v\right) \]
    17. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{fma}\left(e, 0 - \color{blue}{\cos v}, 1\right) \cdot \left(e \cdot \sin v\right) \]
    18. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma}\left(e, 0 - \cos v, 1\right) \cdot \color{blue}{\left(e \cdot \sin v\right)} \]
  5. Simplified98.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(e, 0 - \cos v, 1\right) \cdot \left(e \cdot \sin v\right)} \]
  6. Taylor expanded in v around 0

    \[\leadsto \color{blue}{\left(1 + -1 \cdot e\right)} \cdot \left(e \cdot \sin v\right) \]
  7. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \left(1 + \color{blue}{\left(\mathsf{neg}\left(e\right)\right)}\right) \cdot \left(e \cdot \sin v\right) \]
    2. unsub-negN/A

      \[\leadsto \color{blue}{\left(1 - e\right)} \cdot \left(e \cdot \sin v\right) \]
    3. --lowering--.f6498.2

      \[\leadsto \color{blue}{\left(1 - e\right)} \cdot \left(e \cdot \sin v\right) \]
  8. Simplified98.2%

    \[\leadsto \color{blue}{\left(1 - e\right)} \cdot \left(e \cdot \sin v\right) \]
  9. Final simplification98.2%

    \[\leadsto \left(1 - e\right) \cdot \left(\sin v \cdot e\right) \]
  10. Add Preprocessing

Alternative 4: 74.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq 2 \cdot 10^{-27}:\\ \;\;\;\;e \cdot \frac{v}{e + 1}\\ \mathbf{else}:\\ \;\;\;\;\sin v \cdot e\\ \end{array} \end{array} \]
(FPCore (e v)
 :precision binary64
 (if (<= v 2e-27) (* e (/ v (+ e 1.0))) (* (sin v) e)))
double code(double e, double v) {
	double tmp;
	if (v <= 2e-27) {
		tmp = e * (v / (e + 1.0));
	} else {
		tmp = sin(v) * e;
	}
	return tmp;
}
real(8) function code(e, v)
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    real(8) :: tmp
    if (v <= 2d-27) then
        tmp = e * (v / (e + 1.0d0))
    else
        tmp = sin(v) * e
    end if
    code = tmp
end function
public static double code(double e, double v) {
	double tmp;
	if (v <= 2e-27) {
		tmp = e * (v / (e + 1.0));
	} else {
		tmp = Math.sin(v) * e;
	}
	return tmp;
}
def code(e, v):
	tmp = 0
	if v <= 2e-27:
		tmp = e * (v / (e + 1.0))
	else:
		tmp = math.sin(v) * e
	return tmp
function code(e, v)
	tmp = 0.0
	if (v <= 2e-27)
		tmp = Float64(e * Float64(v / Float64(e + 1.0)));
	else
		tmp = Float64(sin(v) * e);
	end
	return tmp
end
function tmp_2 = code(e, v)
	tmp = 0.0;
	if (v <= 2e-27)
		tmp = e * (v / (e + 1.0));
	else
		tmp = sin(v) * e;
	end
	tmp_2 = tmp;
end
code[e_, v_] := If[LessEqual[v, 2e-27], N[(e * N[(v / N[(e + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[v], $MachinePrecision] * e), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;v \leq 2 \cdot 10^{-27}:\\
\;\;\;\;e \cdot \frac{v}{e + 1}\\

\mathbf{else}:\\
\;\;\;\;\sin v \cdot e\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if v < 2.0000000000000001e-27

    1. Initial program 99.8%

      \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
    2. Add Preprocessing
    3. Taylor expanded in v around 0

      \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \frac{\color{blue}{e \cdot v}}{1 + e} \]
      3. +-lowering-+.f6467.9

        \[\leadsto \frac{e \cdot v}{\color{blue}{1 + e}} \]
    5. Simplified67.9%

      \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
    6. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto \color{blue}{e \cdot \frac{v}{1 + e}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{v}{1 + e} \cdot e} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\frac{v}{1 + e} \cdot e} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{v}{1 + e}} \cdot e \]
      5. +-commutativeN/A

        \[\leadsto \frac{v}{\color{blue}{e + 1}} \cdot e \]
      6. +-lowering-+.f6467.9

        \[\leadsto \frac{v}{\color{blue}{e + 1}} \cdot e \]
    7. Applied egg-rr67.9%

      \[\leadsto \color{blue}{\frac{v}{e + 1} \cdot e} \]

    if 2.0000000000000001e-27 < v

    1. Initial program 99.7%

      \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
    2. Add Preprocessing
    3. Taylor expanded in e around 0

      \[\leadsto \color{blue}{e \cdot \sin v} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{e \cdot \sin v} \]
      2. sin-lowering-sin.f6498.2

        \[\leadsto e \cdot \color{blue}{\sin v} \]
    5. Simplified98.2%

      \[\leadsto \color{blue}{e \cdot \sin v} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;v \leq 2 \cdot 10^{-27}:\\ \;\;\;\;e \cdot \frac{v}{e + 1}\\ \mathbf{else}:\\ \;\;\;\;\sin v \cdot e\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 52.0% accurate, 3.6× speedup?

\[\begin{array}{l} \\ v \cdot \frac{1}{\mathsf{fma}\left(v, v \cdot \left(-0.5 - \frac{\mathsf{fma}\left(e, -0.16666666666666666, -0.16666666666666666\right)}{e}\right), 1 + \frac{1}{e}\right)} \end{array} \]
(FPCore (e v)
 :precision binary64
 (*
  v
  (/
   1.0
   (fma
    v
    (* v (- -0.5 (/ (fma e -0.16666666666666666 -0.16666666666666666) e)))
    (+ 1.0 (/ 1.0 e))))))
double code(double e, double v) {
	return v * (1.0 / fma(v, (v * (-0.5 - (fma(e, -0.16666666666666666, -0.16666666666666666) / e))), (1.0 + (1.0 / e))));
}
function code(e, v)
	return Float64(v * Float64(1.0 / fma(v, Float64(v * Float64(-0.5 - Float64(fma(e, -0.16666666666666666, -0.16666666666666666) / e))), Float64(1.0 + Float64(1.0 / e)))))
end
code[e_, v_] := N[(v * N[(1.0 / N[(v * N[(v * N[(-0.5 - N[(N[(e * -0.16666666666666666 + -0.16666666666666666), $MachinePrecision] / e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(1.0 / e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
v \cdot \frac{1}{\mathsf{fma}\left(v, v \cdot \left(-0.5 - \frac{\mathsf{fma}\left(e, -0.16666666666666666, -0.16666666666666666\right)}{e}\right), 1 + \frac{1}{e}\right)}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{1 + e \cdot \cos v}{e \cdot \sin v}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{1 + e \cdot \cos v}{e \cdot \sin v}}} \]
    3. /-lowering-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1 + e \cdot \cos v}{e \cdot \sin v}}} \]
    4. +-commutativeN/A

      \[\leadsto \frac{1}{\frac{\color{blue}{e \cdot \cos v + 1}}{e \cdot \sin v}} \]
    5. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(e, \cos v, 1\right)}}{e \cdot \sin v}} \]
    6. cos-lowering-cos.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(e, \color{blue}{\cos v}, 1\right)}{e \cdot \sin v}} \]
    7. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{\color{blue}{e \cdot \sin v}}} \]
    8. sin-lowering-sin.f6498.5

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{e \cdot \color{blue}{\sin v}}} \]
  4. Applied egg-rr98.5%

    \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{e \cdot \sin v}}} \]
  5. Taylor expanded in v around 0

    \[\leadsto \frac{1}{\color{blue}{\frac{1 + \left(-1 \cdot \left({v}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \frac{1 + e}{e}\right)\right) + \frac{1}{e}\right)}{v}}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1 + \left(-1 \cdot \left({v}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \frac{1 + e}{e}\right)\right) + \frac{1}{e}\right)}{v}}} \]
  7. Simplified50.2%

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(v \cdot v, -0.5 - \frac{\mathsf{fma}\left(e, -0.16666666666666666, -0.16666666666666666\right)}{e}, 1 + \frac{1}{e}\right)}{v}}} \]
  8. Step-by-step derivation
    1. associate-/r/N/A

      \[\leadsto \color{blue}{\frac{1}{\left(v \cdot v\right) \cdot \left(\frac{-1}{2} - \frac{e \cdot \frac{-1}{6} + \frac{-1}{6}}{e}\right) + \left(1 + \frac{1}{e}\right)} \cdot v} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\left(v \cdot v\right) \cdot \left(\frac{-1}{2} - \frac{e \cdot \frac{-1}{6} + \frac{-1}{6}}{e}\right) + \left(1 + \frac{1}{e}\right)} \cdot v} \]
    3. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\left(v \cdot v\right) \cdot \left(\frac{-1}{2} - \frac{e \cdot \frac{-1}{6} + \frac{-1}{6}}{e}\right) + \left(1 + \frac{1}{e}\right)}} \cdot v \]
    4. associate-*l*N/A

      \[\leadsto \frac{1}{\color{blue}{v \cdot \left(v \cdot \left(\frac{-1}{2} - \frac{e \cdot \frac{-1}{6} + \frac{-1}{6}}{e}\right)\right)} + \left(1 + \frac{1}{e}\right)} \cdot v \]
    5. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(v, v \cdot \left(\frac{-1}{2} - \frac{e \cdot \frac{-1}{6} + \frac{-1}{6}}{e}\right), 1 + \frac{1}{e}\right)}} \cdot v \]
    6. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{\mathsf{fma}\left(v, \color{blue}{v \cdot \left(\frac{-1}{2} - \frac{e \cdot \frac{-1}{6} + \frac{-1}{6}}{e}\right)}, 1 + \frac{1}{e}\right)} \cdot v \]
    7. --lowering--.f64N/A

      \[\leadsto \frac{1}{\mathsf{fma}\left(v, v \cdot \color{blue}{\left(\frac{-1}{2} - \frac{e \cdot \frac{-1}{6} + \frac{-1}{6}}{e}\right)}, 1 + \frac{1}{e}\right)} \cdot v \]
    8. /-lowering-/.f64N/A

      \[\leadsto \frac{1}{\mathsf{fma}\left(v, v \cdot \left(\frac{-1}{2} - \color{blue}{\frac{e \cdot \frac{-1}{6} + \frac{-1}{6}}{e}}\right), 1 + \frac{1}{e}\right)} \cdot v \]
    9. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{1}{\mathsf{fma}\left(v, v \cdot \left(\frac{-1}{2} - \frac{\color{blue}{\mathsf{fma}\left(e, \frac{-1}{6}, \frac{-1}{6}\right)}}{e}\right), 1 + \frac{1}{e}\right)} \cdot v \]
    10. +-lowering-+.f64N/A

      \[\leadsto \frac{1}{\mathsf{fma}\left(v, v \cdot \left(\frac{-1}{2} - \frac{\mathsf{fma}\left(e, \frac{-1}{6}, \frac{-1}{6}\right)}{e}\right), \color{blue}{1 + \frac{1}{e}}\right)} \cdot v \]
    11. /-lowering-/.f6451.4

      \[\leadsto \frac{1}{\mathsf{fma}\left(v, v \cdot \left(-0.5 - \frac{\mathsf{fma}\left(e, -0.16666666666666666, -0.16666666666666666\right)}{e}\right), 1 + \color{blue}{\frac{1}{e}}\right)} \cdot v \]
  9. Applied egg-rr51.4%

    \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(v, v \cdot \left(-0.5 - \frac{\mathsf{fma}\left(e, -0.16666666666666666, -0.16666666666666666\right)}{e}\right), 1 + \frac{1}{e}\right)} \cdot v} \]
  10. Final simplification51.4%

    \[\leadsto v \cdot \frac{1}{\mathsf{fma}\left(v, v \cdot \left(-0.5 - \frac{\mathsf{fma}\left(e, -0.16666666666666666, -0.16666666666666666\right)}{e}\right), 1 + \frac{1}{e}\right)} \]
  11. Add Preprocessing

Alternative 6: 51.9% accurate, 4.6× speedup?

\[\begin{array}{l} \\ \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, -0.5, \mathsf{fma}\left(e, 0.16666666666666666, 0.16666666666666666\right)\right), e + 1\right)}{v}} \end{array} \]
(FPCore (e v)
 :precision binary64
 (/
  e
  (/
   (fma
    (* v v)
    (fma e -0.5 (fma e 0.16666666666666666 0.16666666666666666))
    (+ e 1.0))
   v)))
double code(double e, double v) {
	return e / (fma((v * v), fma(e, -0.5, fma(e, 0.16666666666666666, 0.16666666666666666)), (e + 1.0)) / v);
}
function code(e, v)
	return Float64(e / Float64(fma(Float64(v * v), fma(e, -0.5, fma(e, 0.16666666666666666, 0.16666666666666666)), Float64(e + 1.0)) / v))
end
code[e_, v_] := N[(e / N[(N[(N[(v * v), $MachinePrecision] * N[(e * -0.5 + N[(e * 0.16666666666666666 + 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + N[(e + 1.0), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, -0.5, \mathsf{fma}\left(e, 0.16666666666666666, 0.16666666666666666\right)\right), e + 1\right)}{v}}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/l*N/A

      \[\leadsto \color{blue}{e \cdot \frac{\sin v}{1 + e \cdot \cos v}} \]
    2. clear-numN/A

      \[\leadsto e \cdot \color{blue}{\frac{1}{\frac{1 + e \cdot \cos v}{\sin v}}} \]
    3. un-div-invN/A

      \[\leadsto \color{blue}{\frac{e}{\frac{1 + e \cdot \cos v}{\sin v}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{e}{\frac{1 + e \cdot \cos v}{\sin v}}} \]
    5. /-lowering-/.f64N/A

      \[\leadsto \frac{e}{\color{blue}{\frac{1 + e \cdot \cos v}{\sin v}}} \]
    6. +-commutativeN/A

      \[\leadsto \frac{e}{\frac{\color{blue}{e \cdot \cos v + 1}}{\sin v}} \]
    7. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{e}{\frac{\color{blue}{\mathsf{fma}\left(e, \cos v, 1\right)}}{\sin v}} \]
    8. cos-lowering-cos.f64N/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(e, \color{blue}{\cos v}, 1\right)}{\sin v}} \]
    9. sin-lowering-sin.f6499.6

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{\color{blue}{\sin v}}} \]
  4. Applied egg-rr99.6%

    \[\leadsto \color{blue}{\frac{e}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{\sin v}}} \]
  5. Taylor expanded in v around 0

    \[\leadsto \frac{e}{\color{blue}{\frac{1 + \left(e + {v}^{2} \cdot \left(\frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right)\right)\right)}{v}}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \frac{e}{\color{blue}{\frac{1 + \left(e + {v}^{2} \cdot \left(\frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right)\right)\right)}{v}}} \]
    2. associate-+r+N/A

      \[\leadsto \frac{e}{\frac{\color{blue}{\left(1 + e\right) + {v}^{2} \cdot \left(\frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right)\right)}}{v}} \]
    3. +-commutativeN/A

      \[\leadsto \frac{e}{\frac{\color{blue}{{v}^{2} \cdot \left(\frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right)\right) + \left(1 + e\right)}}{v}} \]
    4. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{e}{\frac{\color{blue}{\mathsf{fma}\left({v}^{2}, \frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right), 1 + e\right)}}{v}} \]
    5. unpow2N/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(\color{blue}{v \cdot v}, \frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right), 1 + e\right)}{v}} \]
    6. *-lowering-*.f64N/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(\color{blue}{v \cdot v}, \frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right), 1 + e\right)}{v}} \]
    7. sub-negN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{\frac{-1}{2} \cdot e + \left(\mathsf{neg}\left(\frac{-1}{6} \cdot \left(1 + e\right)\right)\right)}, 1 + e\right)}{v}} \]
    8. *-commutativeN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{e \cdot \frac{-1}{2}} + \left(\mathsf{neg}\left(\frac{-1}{6} \cdot \left(1 + e\right)\right)\right), 1 + e\right)}{v}} \]
    9. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{\mathsf{fma}\left(e, \frac{-1}{2}, \mathsf{neg}\left(\frac{-1}{6} \cdot \left(1 + e\right)\right)\right)}, 1 + e\right)}{v}} \]
    10. distribute-lft-neg-inN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{6}\right)\right) \cdot \left(1 + e\right)}\right), 1 + e\right)}{v}} \]
    11. metadata-evalN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \color{blue}{\frac{1}{6}} \cdot \left(1 + e\right)\right), 1 + e\right)}{v}} \]
    12. +-commutativeN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \frac{1}{6} \cdot \color{blue}{\left(e + 1\right)}\right), 1 + e\right)}{v}} \]
    13. distribute-rgt-inN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \color{blue}{e \cdot \frac{1}{6} + 1 \cdot \frac{1}{6}}\right), 1 + e\right)}{v}} \]
    14. metadata-evalN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, e \cdot \frac{1}{6} + \color{blue}{\frac{1}{6}}\right), 1 + e\right)}{v}} \]
    15. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \color{blue}{\mathsf{fma}\left(e, \frac{1}{6}, \frac{1}{6}\right)}\right), 1 + e\right)}{v}} \]
    16. +-commutativeN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \mathsf{fma}\left(e, \frac{1}{6}, \frac{1}{6}\right)\right), \color{blue}{e + 1}\right)}{v}} \]
    17. +-lowering-+.f6451.4

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, -0.5, \mathsf{fma}\left(e, 0.16666666666666666, 0.16666666666666666\right)\right), \color{blue}{e + 1}\right)}{v}} \]
  7. Simplified51.4%

    \[\leadsto \frac{e}{\color{blue}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, -0.5, \mathsf{fma}\left(e, 0.16666666666666666, 0.16666666666666666\right)\right), e + 1\right)}{v}}} \]
  8. Add Preprocessing

Alternative 7: 51.5% accurate, 5.4× speedup?

\[\begin{array}{l} \\ \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, e \cdot -0.3333333333333333, e + 1\right)}{v}} \end{array} \]
(FPCore (e v)
 :precision binary64
 (/ e (/ (fma (* v v) (* e -0.3333333333333333) (+ e 1.0)) v)))
double code(double e, double v) {
	return e / (fma((v * v), (e * -0.3333333333333333), (e + 1.0)) / v);
}
function code(e, v)
	return Float64(e / Float64(fma(Float64(v * v), Float64(e * -0.3333333333333333), Float64(e + 1.0)) / v))
end
code[e_, v_] := N[(e / N[(N[(N[(v * v), $MachinePrecision] * N[(e * -0.3333333333333333), $MachinePrecision] + N[(e + 1.0), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{e}{\frac{\mathsf{fma}\left(v \cdot v, e \cdot -0.3333333333333333, e + 1\right)}{v}}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/l*N/A

      \[\leadsto \color{blue}{e \cdot \frac{\sin v}{1 + e \cdot \cos v}} \]
    2. clear-numN/A

      \[\leadsto e \cdot \color{blue}{\frac{1}{\frac{1 + e \cdot \cos v}{\sin v}}} \]
    3. un-div-invN/A

      \[\leadsto \color{blue}{\frac{e}{\frac{1 + e \cdot \cos v}{\sin v}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{e}{\frac{1 + e \cdot \cos v}{\sin v}}} \]
    5. /-lowering-/.f64N/A

      \[\leadsto \frac{e}{\color{blue}{\frac{1 + e \cdot \cos v}{\sin v}}} \]
    6. +-commutativeN/A

      \[\leadsto \frac{e}{\frac{\color{blue}{e \cdot \cos v + 1}}{\sin v}} \]
    7. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{e}{\frac{\color{blue}{\mathsf{fma}\left(e, \cos v, 1\right)}}{\sin v}} \]
    8. cos-lowering-cos.f64N/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(e, \color{blue}{\cos v}, 1\right)}{\sin v}} \]
    9. sin-lowering-sin.f6499.6

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{\color{blue}{\sin v}}} \]
  4. Applied egg-rr99.6%

    \[\leadsto \color{blue}{\frac{e}{\frac{\mathsf{fma}\left(e, \cos v, 1\right)}{\sin v}}} \]
  5. Taylor expanded in v around 0

    \[\leadsto \frac{e}{\color{blue}{\frac{1 + \left(e + {v}^{2} \cdot \left(\frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right)\right)\right)}{v}}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \frac{e}{\color{blue}{\frac{1 + \left(e + {v}^{2} \cdot \left(\frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right)\right)\right)}{v}}} \]
    2. associate-+r+N/A

      \[\leadsto \frac{e}{\frac{\color{blue}{\left(1 + e\right) + {v}^{2} \cdot \left(\frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right)\right)}}{v}} \]
    3. +-commutativeN/A

      \[\leadsto \frac{e}{\frac{\color{blue}{{v}^{2} \cdot \left(\frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right)\right) + \left(1 + e\right)}}{v}} \]
    4. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{e}{\frac{\color{blue}{\mathsf{fma}\left({v}^{2}, \frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right), 1 + e\right)}}{v}} \]
    5. unpow2N/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(\color{blue}{v \cdot v}, \frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right), 1 + e\right)}{v}} \]
    6. *-lowering-*.f64N/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(\color{blue}{v \cdot v}, \frac{-1}{2} \cdot e - \frac{-1}{6} \cdot \left(1 + e\right), 1 + e\right)}{v}} \]
    7. sub-negN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{\frac{-1}{2} \cdot e + \left(\mathsf{neg}\left(\frac{-1}{6} \cdot \left(1 + e\right)\right)\right)}, 1 + e\right)}{v}} \]
    8. *-commutativeN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{e \cdot \frac{-1}{2}} + \left(\mathsf{neg}\left(\frac{-1}{6} \cdot \left(1 + e\right)\right)\right), 1 + e\right)}{v}} \]
    9. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{\mathsf{fma}\left(e, \frac{-1}{2}, \mathsf{neg}\left(\frac{-1}{6} \cdot \left(1 + e\right)\right)\right)}, 1 + e\right)}{v}} \]
    10. distribute-lft-neg-inN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{6}\right)\right) \cdot \left(1 + e\right)}\right), 1 + e\right)}{v}} \]
    11. metadata-evalN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \color{blue}{\frac{1}{6}} \cdot \left(1 + e\right)\right), 1 + e\right)}{v}} \]
    12. +-commutativeN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \frac{1}{6} \cdot \color{blue}{\left(e + 1\right)}\right), 1 + e\right)}{v}} \]
    13. distribute-rgt-inN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \color{blue}{e \cdot \frac{1}{6} + 1 \cdot \frac{1}{6}}\right), 1 + e\right)}{v}} \]
    14. metadata-evalN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, e \cdot \frac{1}{6} + \color{blue}{\frac{1}{6}}\right), 1 + e\right)}{v}} \]
    15. accelerator-lowering-fma.f64N/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \color{blue}{\mathsf{fma}\left(e, \frac{1}{6}, \frac{1}{6}\right)}\right), 1 + e\right)}{v}} \]
    16. +-commutativeN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, \frac{-1}{2}, \mathsf{fma}\left(e, \frac{1}{6}, \frac{1}{6}\right)\right), \color{blue}{e + 1}\right)}{v}} \]
    17. +-lowering-+.f6451.4

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, -0.5, \mathsf{fma}\left(e, 0.16666666666666666, 0.16666666666666666\right)\right), \color{blue}{e + 1}\right)}{v}} \]
  7. Simplified51.4%

    \[\leadsto \frac{e}{\color{blue}{\frac{\mathsf{fma}\left(v \cdot v, \mathsf{fma}\left(e, -0.5, \mathsf{fma}\left(e, 0.16666666666666666, 0.16666666666666666\right)\right), e + 1\right)}{v}}} \]
  8. Taylor expanded in e around inf

    \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{\frac{-1}{3} \cdot e}, e + 1\right)}{v}} \]
  9. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{e \cdot \frac{-1}{3}}, e + 1\right)}{v}} \]
    2. *-lowering-*.f6451.2

      \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{e \cdot -0.3333333333333333}, e + 1\right)}{v}} \]
  10. Simplified51.2%

    \[\leadsto \frac{e}{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{e \cdot -0.3333333333333333}, e + 1\right)}{v}} \]
  11. Add Preprocessing

Alternative 8: 50.9% accurate, 11.3× speedup?

\[\begin{array}{l} \\ e \cdot \frac{v}{e + 1} \end{array} \]
(FPCore (e v) :precision binary64 (* e (/ v (+ e 1.0))))
double code(double e, double v) {
	return e * (v / (e + 1.0));
}
real(8) function code(e, v)
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = e * (v / (e + 1.0d0))
end function
public static double code(double e, double v) {
	return e * (v / (e + 1.0));
}
def code(e, v):
	return e * (v / (e + 1.0))
function code(e, v)
	return Float64(e * Float64(v / Float64(e + 1.0)))
end
function tmp = code(e, v)
	tmp = e * (v / (e + 1.0));
end
code[e_, v_] := N[(e * N[(v / N[(e + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
e \cdot \frac{v}{e + 1}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. Taylor expanded in v around 0

    \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \frac{\color{blue}{e \cdot v}}{1 + e} \]
    3. +-lowering-+.f6450.5

      \[\leadsto \frac{e \cdot v}{\color{blue}{1 + e}} \]
  5. Simplified50.5%

    \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
  6. Step-by-step derivation
    1. associate-/l*N/A

      \[\leadsto \color{blue}{e \cdot \frac{v}{1 + e}} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\frac{v}{1 + e} \cdot e} \]
    3. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\frac{v}{1 + e} \cdot e} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{v}{1 + e}} \cdot e \]
    5. +-commutativeN/A

      \[\leadsto \frac{v}{\color{blue}{e + 1}} \cdot e \]
    6. +-lowering-+.f6450.5

      \[\leadsto \frac{v}{\color{blue}{e + 1}} \cdot e \]
  7. Applied egg-rr50.5%

    \[\leadsto \color{blue}{\frac{v}{e + 1} \cdot e} \]
  8. Final simplification50.5%

    \[\leadsto e \cdot \frac{v}{e + 1} \]
  9. Add Preprocessing

Alternative 9: 50.3% accurate, 16.1× speedup?

\[\begin{array}{l} \\ e \cdot \left(v - v \cdot e\right) \end{array} \]
(FPCore (e v) :precision binary64 (* e (- v (* v e))))
double code(double e, double v) {
	return e * (v - (v * e));
}
real(8) function code(e, v)
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = e * (v - (v * e))
end function
public static double code(double e, double v) {
	return e * (v - (v * e));
}
def code(e, v):
	return e * (v - (v * e))
function code(e, v)
	return Float64(e * Float64(v - Float64(v * e)))
end
function tmp = code(e, v)
	tmp = e * (v - (v * e));
end
code[e_, v_] := N[(e * N[(v - N[(v * e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
e \cdot \left(v - v \cdot e\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. Taylor expanded in v around 0

    \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \frac{\color{blue}{e \cdot v}}{1 + e} \]
    3. +-lowering-+.f6450.5

      \[\leadsto \frac{e \cdot v}{\color{blue}{1 + e}} \]
  5. Simplified50.5%

    \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
  6. Step-by-step derivation
    1. associate-/l*N/A

      \[\leadsto \color{blue}{e \cdot \frac{v}{1 + e}} \]
    2. clear-numN/A

      \[\leadsto e \cdot \color{blue}{\frac{1}{\frac{1 + e}{v}}} \]
    3. un-div-invN/A

      \[\leadsto \color{blue}{\frac{e}{\frac{1 + e}{v}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{e}{\frac{1 + e}{v}}} \]
    5. /-lowering-/.f64N/A

      \[\leadsto \frac{e}{\color{blue}{\frac{1 + e}{v}}} \]
    6. +-commutativeN/A

      \[\leadsto \frac{e}{\frac{\color{blue}{e + 1}}{v}} \]
    7. +-lowering-+.f6450.4

      \[\leadsto \frac{e}{\frac{\color{blue}{e + 1}}{v}} \]
  7. Applied egg-rr50.4%

    \[\leadsto \color{blue}{\frac{e}{\frac{e + 1}{v}}} \]
  8. Taylor expanded in e around 0

    \[\leadsto \color{blue}{e \cdot \left(v + -1 \cdot \left(e \cdot v\right)\right)} \]
  9. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{e \cdot \left(v + -1 \cdot \left(e \cdot v\right)\right)} \]
    2. mul-1-negN/A

      \[\leadsto e \cdot \left(v + \color{blue}{\left(\mathsf{neg}\left(e \cdot v\right)\right)}\right) \]
    3. unsub-negN/A

      \[\leadsto e \cdot \color{blue}{\left(v - e \cdot v\right)} \]
    4. --lowering--.f64N/A

      \[\leadsto e \cdot \color{blue}{\left(v - e \cdot v\right)} \]
    5. *-lowering-*.f6449.5

      \[\leadsto e \cdot \left(v - \color{blue}{e \cdot v}\right) \]
  10. Simplified49.5%

    \[\leadsto \color{blue}{e \cdot \left(v - e \cdot v\right)} \]
  11. Final simplification49.5%

    \[\leadsto e \cdot \left(v - v \cdot e\right) \]
  12. Add Preprocessing

Alternative 10: 49.8% accurate, 37.5× speedup?

\[\begin{array}{l} \\ v \cdot e \end{array} \]
(FPCore (e v) :precision binary64 (* v e))
double code(double e, double v) {
	return v * e;
}
real(8) function code(e, v)
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = v * e
end function
public static double code(double e, double v) {
	return v * e;
}
def code(e, v):
	return v * e
function code(e, v)
	return Float64(v * e)
end
function tmp = code(e, v)
	tmp = v * e;
end
code[e_, v_] := N[(v * e), $MachinePrecision]
\begin{array}{l}

\\
v \cdot e
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. Taylor expanded in v around 0

    \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \frac{\color{blue}{e \cdot v}}{1 + e} \]
    3. +-lowering-+.f6450.5

      \[\leadsto \frac{e \cdot v}{\color{blue}{1 + e}} \]
  5. Simplified50.5%

    \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
  6. Taylor expanded in e around 0

    \[\leadsto \color{blue}{e \cdot v} \]
  7. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{v \cdot e} \]
    2. *-lowering-*.f6448.8

      \[\leadsto \color{blue}{v \cdot e} \]
  8. Simplified48.8%

    \[\leadsto \color{blue}{v \cdot e} \]
  9. Add Preprocessing

Alternative 11: 4.5% accurate, 225.0× speedup?

\[\begin{array}{l} \\ v \end{array} \]
(FPCore (e v) :precision binary64 v)
double code(double e, double v) {
	return v;
}
real(8) function code(e, v)
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = v
end function
public static double code(double e, double v) {
	return v;
}
def code(e, v):
	return v
function code(e, v)
	return v
end
function tmp = code(e, v)
	tmp = v;
end
code[e_, v_] := v
\begin{array}{l}

\\
v
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. Taylor expanded in v around 0

    \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \frac{\color{blue}{e \cdot v}}{1 + e} \]
    3. +-lowering-+.f6450.5

      \[\leadsto \frac{e \cdot v}{\color{blue}{1 + e}} \]
  5. Simplified50.5%

    \[\leadsto \color{blue}{\frac{e \cdot v}{1 + e}} \]
  6. Taylor expanded in e around inf

    \[\leadsto \color{blue}{v} \]
  7. Step-by-step derivation
    1. Simplified4.8%

      \[\leadsto \color{blue}{v} \]
    2. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2024198 
    (FPCore (e v)
      :name "Trigonometry A"
      :precision binary64
      :pre (and (<= 0.0 e) (<= e 1.0))
      (/ (* e (sin v)) (+ 1.0 (* e (cos v)))))