atan(x2 / x1) * (180.0 / 3.14159265359)

Percentage Accurate: 99.5% → 99.5%
Time: 2.2s
Alternatives: 1
Speedup: 1.1×

Specification

?
\[\left(1 \leq x2 \land x2 \leq 100\right) \land \left(1 \leq x1 \land x1 \leq 100\right)\]
\[\begin{array}{l} \\ \tan^{-1} \left(\frac{x2}{x1}\right) \cdot \frac{180}{3.14159265359} \end{array} \]
(FPCore (x2 x1)
 :precision binary64
 (* (atan (/ x2 x1)) (/ 180.0 3.14159265359)))
double code(double x2, double x1) {
	return atan((x2 / x1)) * (180.0 / 3.14159265359);
}
real(8) function code(x2, x1)
    real(8), intent (in) :: x2
    real(8), intent (in) :: x1
    code = atan((x2 / x1)) * (180.0d0 / 3.14159265359d0)
end function
public static double code(double x2, double x1) {
	return Math.atan((x2 / x1)) * (180.0 / 3.14159265359);
}
def code(x2, x1):
	return math.atan((x2 / x1)) * (180.0 / 3.14159265359)
function code(x2, x1)
	return Float64(atan(Float64(x2 / x1)) * Float64(180.0 / 3.14159265359))
end
function tmp = code(x2, x1)
	tmp = atan((x2 / x1)) * (180.0 / 3.14159265359);
end
code[x2_, x1_] := N[(N[ArcTan[N[(x2 / x1), $MachinePrecision]], $MachinePrecision] * N[(180.0 / 3.14159265359), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1} \left(\frac{x2}{x1}\right) \cdot \frac{180}{3.14159265359}
\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 1 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.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \tan^{-1} \left(\frac{x2}{x1}\right) \cdot \frac{180}{3.14159265359} \end{array} \]
(FPCore (x2 x1)
 :precision binary64
 (* (atan (/ x2 x1)) (/ 180.0 3.14159265359)))
double code(double x2, double x1) {
	return atan((x2 / x1)) * (180.0 / 3.14159265359);
}
real(8) function code(x2, x1)
    real(8), intent (in) :: x2
    real(8), intent (in) :: x1
    code = atan((x2 / x1)) * (180.0d0 / 3.14159265359d0)
end function
public static double code(double x2, double x1) {
	return Math.atan((x2 / x1)) * (180.0 / 3.14159265359);
}
def code(x2, x1):
	return math.atan((x2 / x1)) * (180.0 / 3.14159265359)
function code(x2, x1)
	return Float64(atan(Float64(x2 / x1)) * Float64(180.0 / 3.14159265359))
end
function tmp = code(x2, x1)
	tmp = atan((x2 / x1)) * (180.0 / 3.14159265359);
end
code[x2_, x1_] := N[(N[ArcTan[N[(x2 / x1), $MachinePrecision]], $MachinePrecision] * N[(180.0 / 3.14159265359), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1} \left(\frac{x2}{x1}\right) \cdot \frac{180}{3.14159265359}
\end{array}

Alternative 1: 99.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \tan^{-1} \left(\frac{x2}{x1}\right) \cdot 57.29577951307855 \end{array} \]
(FPCore (x2 x1) :precision binary64 (* (atan (/ x2 x1)) 57.29577951307855))
double code(double x2, double x1) {
	return atan((x2 / x1)) * 57.29577951307855;
}
real(8) function code(x2, x1)
    real(8), intent (in) :: x2
    real(8), intent (in) :: x1
    code = atan((x2 / x1)) * 57.29577951307855d0
end function
public static double code(double x2, double x1) {
	return Math.atan((x2 / x1)) * 57.29577951307855;
}
def code(x2, x1):
	return math.atan((x2 / x1)) * 57.29577951307855
function code(x2, x1)
	return Float64(atan(Float64(x2 / x1)) * 57.29577951307855)
end
function tmp = code(x2, x1)
	tmp = atan((x2 / x1)) * 57.29577951307855;
end
code[x2_, x1_] := N[(N[ArcTan[N[(x2 / x1), $MachinePrecision]], $MachinePrecision] * 57.29577951307855), $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1} \left(\frac{x2}{x1}\right) \cdot 57.29577951307855
\end{array}
Derivation
  1. Initial program 99.5%

    \[\tan^{-1} \left(\frac{x2}{x1}\right) \cdot \frac{180}{3.14159265359} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \tan^{-1} \left(\frac{x2}{x1}\right) \cdot \color{blue}{\frac{180}{\frac{3537118876014453}{1125899906842624}}} \]
    2. metadata-eval99.5

      \[\leadsto \tan^{-1} \left(\frac{x2}{x1}\right) \cdot \color{blue}{57.29577951307855} \]
  4. Applied rewrites99.5%

    \[\leadsto \tan^{-1} \left(\frac{x2}{x1}\right) \cdot \color{blue}{57.29577951307855} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 1 
(FPCore (x2 x1)
  :name "atan(x2 / x1) * (180.0 / 3.14159265359)"
  :precision binary64
  :pre (and (and (<= 1.0 x2) (<= x2 100.0)) (and (<= 1.0 x1) (<= x1 100.0)))
  (* (atan (/ x2 x1)) (/ 180.0 3.14159265359)))