
(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:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (e v) :precision binary64 (let* ((t_0 (* (cos v) e))) (* (/ (* (sin v) e) (- (pow t_0 2.0) 1.0)) (- t_0 1.0))))
double code(double e, double v) {
double t_0 = cos(v) * e;
return ((sin(v) * e) / (pow(t_0, 2.0) - 1.0)) * (t_0 - 1.0);
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
real(8) :: t_0
t_0 = cos(v) * e
code = ((sin(v) * e) / ((t_0 ** 2.0d0) - 1.0d0)) * (t_0 - 1.0d0)
end function
public static double code(double e, double v) {
double t_0 = Math.cos(v) * e;
return ((Math.sin(v) * e) / (Math.pow(t_0, 2.0) - 1.0)) * (t_0 - 1.0);
}
def code(e, v): t_0 = math.cos(v) * e return ((math.sin(v) * e) / (math.pow(t_0, 2.0) - 1.0)) * (t_0 - 1.0)
function code(e, v) t_0 = Float64(cos(v) * e) return Float64(Float64(Float64(sin(v) * e) / Float64((t_0 ^ 2.0) - 1.0)) * Float64(t_0 - 1.0)) end
function tmp = code(e, v) t_0 = cos(v) * e; tmp = ((sin(v) * e) / ((t_0 ^ 2.0) - 1.0)) * (t_0 - 1.0); end
code[e_, v_] := Block[{t$95$0 = N[(N[Cos[v], $MachinePrecision] * e), $MachinePrecision]}, N[(N[(N[(N[Sin[v], $MachinePrecision] * e), $MachinePrecision] / N[(N[Power[t$95$0, 2.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos v \cdot e\\
\frac{\sin v \cdot e}{{t\_0}^{2} - 1} \cdot \left(t\_0 - 1\right)
\end{array}
\end{array}
Initial program 99.8%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
(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}
Initial program 99.8%
(FPCore (e v) :precision binary64 (/ (* e (sin v)) (+ 1.0 e)))
double code(double e, double v) {
return (e * sin(v)) / (1.0 + e);
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = (e * sin(v)) / (1.0d0 + e)
end function
public static double code(double e, double v) {
return (e * Math.sin(v)) / (1.0 + e);
}
def code(e, v): return (e * math.sin(v)) / (1.0 + e)
function code(e, v) return Float64(Float64(e * sin(v)) / Float64(1.0 + e)) end
function tmp = code(e, v) tmp = (e * sin(v)) / (1.0 + e); end
code[e_, v_] := N[(N[(e * N[Sin[v], $MachinePrecision]), $MachinePrecision] / N[(1.0 + e), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e \cdot \sin v}{1 + e}
\end{array}
Initial program 99.8%
Taylor expanded in v around 0
lower-+.f6499.7
Applied rewrites99.7%
(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(Float64(1.0 - e) * sin(v)) * e) end
function tmp = code(e, v) tmp = ((1.0 - e) * sin(v)) * e; end
code[e_, v_] := N[(N[(N[(1.0 - e), $MachinePrecision] * N[Sin[v], $MachinePrecision]), $MachinePrecision] * e), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(1 - e\right) \cdot \sin v\right) \cdot e
\end{array}
Initial program 99.8%
Taylor expanded in e around 0
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
distribute-lft-neg-inN/A
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
Taylor expanded in v around 0
Applied rewrites98.6%
(FPCore (e v) :precision binary64 (* (sin v) e))
double code(double e, double v) {
return sin(v) * e;
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = sin(v) * e
end function
public static double code(double e, double v) {
return Math.sin(v) * e;
}
def code(e, v): return math.sin(v) * e
function code(e, v) return Float64(sin(v) * e) end
function tmp = code(e, v) tmp = sin(v) * e; end
code[e_, v_] := N[(N[Sin[v], $MachinePrecision] * e), $MachinePrecision]
\begin{array}{l}
\\
\sin v \cdot e
\end{array}
Initial program 99.8%
Taylor expanded in e around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6498.2
Applied rewrites98.2%
(FPCore (e v) :precision binary64 (/ (* (* e v) (- 1.0 e)) (- 1.0 (* e e))))
double code(double e, double v) {
return ((e * v) * (1.0 - e)) / (1.0 - (e * e));
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = ((e * v) * (1.0d0 - e)) / (1.0d0 - (e * e))
end function
public static double code(double e, double v) {
return ((e * v) * (1.0 - e)) / (1.0 - (e * e));
}
def code(e, v): return ((e * v) * (1.0 - e)) / (1.0 - (e * e))
function code(e, v) return Float64(Float64(Float64(e * v) * Float64(1.0 - e)) / Float64(1.0 - Float64(e * e))) end
function tmp = code(e, v) tmp = ((e * v) * (1.0 - e)) / (1.0 - (e * e)); end
code[e_, v_] := N[(N[(N[(e * v), $MachinePrecision] * N[(1.0 - e), $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(e * e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(e \cdot v\right) \cdot \left(1 - e\right)}{1 - e \cdot e}
\end{array}
Initial program 99.8%
Taylor expanded in v around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6447.8
Applied rewrites47.8%
Applied rewrites47.8%
(FPCore (e v) :precision binary64 (/ (* e v) (+ 1.0 e)))
double code(double e, double v) {
return (e * v) / (1.0 + e);
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = (e * v) / (1.0d0 + e)
end function
public static double code(double e, double v) {
return (e * v) / (1.0 + e);
}
def code(e, v): return (e * v) / (1.0 + e)
function code(e, v) return Float64(Float64(e * v) / Float64(1.0 + e)) end
function tmp = code(e, v) tmp = (e * v) / (1.0 + e); end
code[e_, v_] := N[(N[(e * v), $MachinePrecision] / N[(1.0 + e), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e \cdot v}{1 + e}
\end{array}
Initial program 99.8%
Taylor expanded in v around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6447.8
Applied rewrites47.8%
Applied rewrites47.8%
(FPCore (e v) :precision binary64 (* (/ e (+ 1.0 e)) v))
double code(double e, double v) {
return (e / (1.0 + e)) * v;
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = (e / (1.0d0 + e)) * v
end function
public static double code(double e, double v) {
return (e / (1.0 + e)) * v;
}
def code(e, v): return (e / (1.0 + e)) * v
function code(e, v) return Float64(Float64(e / Float64(1.0 + e)) * v) end
function tmp = code(e, v) tmp = (e / (1.0 + e)) * v; end
code[e_, v_] := N[(N[(e / N[(1.0 + e), $MachinePrecision]), $MachinePrecision] * v), $MachinePrecision]
\begin{array}{l}
\\
\frac{e}{1 + e} \cdot v
\end{array}
Initial program 99.8%
Taylor expanded in v around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6447.8
Applied rewrites47.8%
(FPCore (e v) :precision binary64 (* (* (- 1.0 e) v) e))
double code(double e, double v) {
return ((1.0 - e) * v) * e;
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = ((1.0d0 - e) * v) * e
end function
public static double code(double e, double v) {
return ((1.0 - e) * v) * e;
}
def code(e, v): return ((1.0 - e) * v) * e
function code(e, v) return Float64(Float64(Float64(1.0 - e) * v) * e) end
function tmp = code(e, v) tmp = ((1.0 - e) * v) * e; end
code[e_, v_] := N[(N[(N[(1.0 - e), $MachinePrecision] * v), $MachinePrecision] * e), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(1 - e\right) \cdot v\right) \cdot e
\end{array}
Initial program 99.8%
Taylor expanded in e around 0
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
distribute-lft-neg-inN/A
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
Taylor expanded in v around 0
Applied rewrites46.7%
(FPCore (e v) :precision binary64 (* e v))
double code(double e, double v) {
return e * v;
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = e * v
end function
public static double code(double e, double v) {
return e * v;
}
def code(e, v): return e * v
function code(e, v) return Float64(e * v) end
function tmp = code(e, v) tmp = e * v; end
code[e_, v_] := N[(e * v), $MachinePrecision]
\begin{array}{l}
\\
e \cdot v
\end{array}
Initial program 99.8%
Taylor expanded in v around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6447.8
Applied rewrites47.8%
Taylor expanded in e around 0
Applied rewrites46.4%
herbie shell --seed 2024340
(FPCore (e v)
:name "Trigonometry A"
:precision binary64
:pre (and (<= 0.0 e) (<= e 1.0))
(/ (* e (sin v)) (+ 1.0 (* e (cos v)))))