
(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 11 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 (* e (cos v)))) (* (/ (* (sin v) e) (- 1.0 (pow t_0 2.0))) (- 1.0 t_0))))
double code(double e, double v) {
double t_0 = e * cos(v);
return ((sin(v) * e) / (1.0 - pow(t_0, 2.0))) * (1.0 - t_0);
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
real(8) :: t_0
t_0 = e * cos(v)
code = ((sin(v) * e) / (1.0d0 - (t_0 ** 2.0d0))) * (1.0d0 - t_0)
end function
public static double code(double e, double v) {
double t_0 = e * Math.cos(v);
return ((Math.sin(v) * e) / (1.0 - Math.pow(t_0, 2.0))) * (1.0 - t_0);
}
def code(e, v): t_0 = e * math.cos(v) return ((math.sin(v) * e) / (1.0 - math.pow(t_0, 2.0))) * (1.0 - t_0)
function code(e, v) t_0 = Float64(e * cos(v)) return Float64(Float64(Float64(sin(v) * e) / Float64(1.0 - (t_0 ^ 2.0))) * Float64(1.0 - t_0)) end
function tmp = code(e, v) t_0 = e * cos(v); tmp = ((sin(v) * e) / (1.0 - (t_0 ^ 2.0))) * (1.0 - t_0); end
code[e_, v_] := Block[{t$95$0 = N[(e * N[Cos[v], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[Sin[v], $MachinePrecision] * e), $MachinePrecision] / N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e \cdot \cos v\\
\frac{\sin v \cdot e}{1 - {t_0}^{2}} \cdot \left(1 - t_0\right)
\end{array}
\end{array}
Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
fma-udef99.6%
+-commutative99.6%
associate-/l*99.8%
*-commutative99.8%
flip-+99.8%
associate-/r/99.8%
*-commutative99.8%
metadata-eval99.8%
pow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (e v) :precision binary64 (/ e (+ (/ 1.0 (sin v)) (/ e (tan v)))))
double code(double e, double v) {
return e / ((1.0 / sin(v)) + (e / tan(v)));
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = e / ((1.0d0 / sin(v)) + (e / tan(v)))
end function
public static double code(double e, double v) {
return e / ((1.0 / Math.sin(v)) + (e / Math.tan(v)));
}
def code(e, v): return e / ((1.0 / math.sin(v)) + (e / math.tan(v)))
function code(e, v) return Float64(e / Float64(Float64(1.0 / sin(v)) + Float64(e / tan(v)))) end
function tmp = code(e, v) tmp = e / ((1.0 / sin(v)) + (e / tan(v))); end
code[e_, v_] := N[(e / N[(N[(1.0 / N[Sin[v], $MachinePrecision]), $MachinePrecision] + N[(e / N[Tan[v], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e}{\frac{1}{\sin v} + \frac{e}{\tan v}}
\end{array}
Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
fma-udef99.6%
+-commutative99.6%
associate-/l*99.8%
*-commutative99.8%
flip-+99.8%
associate-/r/99.8%
*-commutative99.8%
metadata-eval99.8%
pow299.8%
Applied egg-rr99.8%
expm1-log1p-u99.8%
expm1-udef30.5%
associate-*l/30.5%
associate-/l*30.5%
*-commutative30.5%
metadata-eval30.5%
unpow230.5%
flip-+30.5%
+-commutative30.5%
Applied egg-rr30.5%
expm1-def99.8%
expm1-log1p99.8%
associate-/l*99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in e around 0 99.6%
expm1-log1p-u99.6%
expm1-udef30.5%
associate-/l*30.5%
quot-tan30.5%
Applied egg-rr30.5%
expm1-def99.6%
expm1-log1p99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (e v) :precision binary64 (/ (* (sin v) e) (+ 1.0 (* e (cos v)))))
double code(double e, double v) {
return (sin(v) * e) / (1.0 + (e * cos(v)));
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = (sin(v) * e) / (1.0d0 + (e * cos(v)))
end function
public static double code(double e, double v) {
return (Math.sin(v) * e) / (1.0 + (e * Math.cos(v)));
}
def code(e, v): return (math.sin(v) * e) / (1.0 + (e * math.cos(v)))
function code(e, v) return Float64(Float64(sin(v) * e) / Float64(1.0 + Float64(e * cos(v)))) end
function tmp = code(e, v) tmp = (sin(v) * e) / (1.0 + (e * cos(v))); end
code[e_, v_] := N[(N[(N[Sin[v], $MachinePrecision] * e), $MachinePrecision] / N[(1.0 + N[(e * N[Cos[v], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin v \cdot e}{1 + e \cdot \cos v}
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (e v) :precision binary64 (/ (sin v) (+ (cos v) (/ 1.0 e))))
double code(double e, double v) {
return sin(v) / (cos(v) + (1.0 / e));
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = sin(v) / (cos(v) + (1.0d0 / e))
end function
public static double code(double e, double v) {
return Math.sin(v) / (Math.cos(v) + (1.0 / e));
}
def code(e, v): return math.sin(v) / (math.cos(v) + (1.0 / e))
function code(e, v) return Float64(sin(v) / Float64(cos(v) + Float64(1.0 / e))) end
function tmp = code(e, v) tmp = sin(v) / (cos(v) + (1.0 / e)); end
code[e_, v_] := N[(N[Sin[v], $MachinePrecision] / N[(N[Cos[v], $MachinePrecision] + N[(1.0 / e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin v}{\cos v + \frac{1}{e}}
\end{array}
Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in e around 0 99.6%
Final simplification99.6%
(FPCore (e v) :precision binary64 (/ (sin v) (+ 1.0 (/ 1.0 e))))
double code(double e, double v) {
return sin(v) / (1.0 + (1.0 / e));
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = sin(v) / (1.0d0 + (1.0d0 / e))
end function
public static double code(double e, double v) {
return Math.sin(v) / (1.0 + (1.0 / e));
}
def code(e, v): return math.sin(v) / (1.0 + (1.0 / e))
function code(e, v) return Float64(sin(v) / Float64(1.0 + Float64(1.0 / e))) end
function tmp = code(e, v) tmp = sin(v) / (1.0 + (1.0 / e)); end
code[e_, v_] := N[(N[Sin[v], $MachinePrecision] / N[(1.0 + N[(1.0 / e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin v}{1 + \frac{1}{e}}
\end{array}
Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in v around 0 98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in v around inf 98.8%
+-commutative98.8%
*-commutative98.8%
/-rgt-identity98.8%
associate-/r/98.6%
associate-/r*98.6%
distribute-rgt-in98.7%
rgt-mult-inverse98.7%
*-lft-identity98.7%
Simplified98.7%
Final simplification98.7%
(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%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in e around 0 97.9%
Final simplification97.9%
(FPCore (e v) :precision binary64 (/ e (+ (* v (+ (* e -0.5) (* -0.16666666666666666 (- -1.0 e)))) (+ (/ 1.0 v) (/ e v)))))
double code(double e, double v) {
return e / ((v * ((e * -0.5) + (-0.16666666666666666 * (-1.0 - e)))) + ((1.0 / v) + (e / v)));
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = e / ((v * ((e * (-0.5d0)) + ((-0.16666666666666666d0) * ((-1.0d0) - e)))) + ((1.0d0 / v) + (e / v)))
end function
public static double code(double e, double v) {
return e / ((v * ((e * -0.5) + (-0.16666666666666666 * (-1.0 - e)))) + ((1.0 / v) + (e / v)));
}
def code(e, v): return e / ((v * ((e * -0.5) + (-0.16666666666666666 * (-1.0 - e)))) + ((1.0 / v) + (e / v)))
function code(e, v) return Float64(e / Float64(Float64(v * Float64(Float64(e * -0.5) + Float64(-0.16666666666666666 * Float64(-1.0 - e)))) + Float64(Float64(1.0 / v) + Float64(e / v)))) end
function tmp = code(e, v) tmp = e / ((v * ((e * -0.5) + (-0.16666666666666666 * (-1.0 - e)))) + ((1.0 / v) + (e / v))); end
code[e_, v_] := N[(e / N[(N[(v * N[(N[(e * -0.5), $MachinePrecision] + N[(-0.16666666666666666 * N[(-1.0 - e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / v), $MachinePrecision] + N[(e / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e}{v \cdot \left(e \cdot -0.5 + -0.16666666666666666 \cdot \left(-1 - e\right)\right) + \left(\frac{1}{v} + \frac{e}{v}\right)}
\end{array}
Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
fma-udef99.6%
+-commutative99.6%
associate-/l*99.8%
*-commutative99.8%
flip-+99.8%
associate-/r/99.8%
*-commutative99.8%
metadata-eval99.8%
pow299.8%
Applied egg-rr99.8%
expm1-log1p-u99.8%
expm1-udef30.5%
associate-*l/30.5%
associate-/l*30.5%
*-commutative30.5%
metadata-eval30.5%
unpow230.5%
flip-+30.5%
+-commutative30.5%
Applied egg-rr30.5%
expm1-def99.8%
expm1-log1p99.8%
associate-/l*99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in v around 0 52.0%
Final simplification52.0%
(FPCore (e v) :precision binary64 (* v (- e (* e e))))
double code(double e, double v) {
return v * (e - (e * e));
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = v * (e - (e * e))
end function
public static double code(double e, double v) {
return v * (e - (e * e));
}
def code(e, v): return v * (e - (e * e))
function code(e, v) return Float64(v * Float64(e - Float64(e * e))) end
function tmp = code(e, v) tmp = v * (e - (e * e)); end
code[e_, v_] := N[(v * N[(e - N[(e * e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
v \cdot \left(e - e \cdot e\right)
\end{array}
Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in v around 0 51.2%
associate-/l*51.1%
associate-/r/51.2%
+-commutative51.2%
Simplified51.2%
Taylor expanded in e around 0 50.6%
mul-1-neg50.6%
unsub-neg50.6%
unpow250.6%
Simplified50.6%
Final simplification50.6%
(FPCore (e v) :precision binary64 (* v (/ e (+ e 1.0))))
double code(double e, double v) {
return v * (e / (e + 1.0));
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = v * (e / (e + 1.0d0))
end function
public static double code(double e, double v) {
return v * (e / (e + 1.0));
}
def code(e, v): return v * (e / (e + 1.0))
function code(e, v) return Float64(v * Float64(e / Float64(e + 1.0))) end
function tmp = code(e, v) tmp = v * (e / (e + 1.0)); end
code[e_, v_] := N[(v * N[(e / N[(e + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
v \cdot \frac{e}{e + 1}
\end{array}
Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in v around 0 51.2%
associate-/l*51.1%
associate-/r/51.2%
+-commutative51.2%
Simplified51.2%
Final simplification51.2%
(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}
Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in v around 0 51.2%
associate-/l*51.1%
associate-/r/51.2%
+-commutative51.2%
Simplified51.2%
Taylor expanded in e around 0 50.3%
Final simplification50.3%
(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}
Initial program 99.8%
*-commutative99.8%
associate-/l*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in v around 0 51.2%
associate-/l*51.1%
associate-/r/51.2%
+-commutative51.2%
Simplified51.2%
Taylor expanded in e around inf 4.4%
Final simplification4.4%
herbie shell --seed 2023280
(FPCore (e v)
:name "Trigonometry A"
:precision binary64
:pre (and (<= 0.0 e) (<= e 1.0))
(/ (* e (sin v)) (+ 1.0 (* e (cos v)))))