
(FPCore (x) :precision binary64 (/ (- 1 (cos x)) (sin x)))
double code(double x) {
return (1.0 - cos(x)) / sin(x);
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (1.0d0 - cos(x)) / sin(x)
end function
public static double code(double x) {
return (1.0 - Math.cos(x)) / Math.sin(x);
}
def code(x): return (1.0 - math.cos(x)) / math.sin(x)
function code(x) return Float64(Float64(1.0 - cos(x)) / sin(x)) end
function tmp = code(x) tmp = (1.0 - cos(x)) / sin(x); end
code[x_] := N[(N[(1 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]
\frac{1 - \cos x}{\sin x}
Herbie found 1 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ (- 1 (cos x)) (sin x)))
double code(double x) {
return (1.0 - cos(x)) / sin(x);
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (1.0d0 - cos(x)) / sin(x)
end function
public static double code(double x) {
return (1.0 - Math.cos(x)) / Math.sin(x);
}
def code(x): return (1.0 - math.cos(x)) / math.sin(x)
function code(x) return Float64(Float64(1.0 - cos(x)) / sin(x)) end
function tmp = code(x) tmp = (1.0 - cos(x)) / sin(x); end
code[x_] := N[(N[(1 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]
\frac{1 - \cos x}{\sin x}
(FPCore (x) :precision binary64 (tan (* 1/2 x)))
double code(double x) {
return tan((0.5 * x));
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = tan((0.5d0 * x))
end function
public static double code(double x) {
return Math.tan((0.5 * x));
}
def code(x): return math.tan((0.5 * x))
function code(x) return tan(Float64(0.5 * x)) end
function tmp = code(x) tmp = tan((0.5 * x)); end
code[x_] := N[Tan[N[(1/2 * x), $MachinePrecision]], $MachinePrecision]
\tan \left(\frac{1}{2} \cdot x\right)
Initial program 52.7%
lift-/.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
hang-p0-tanN/A
lower-tan.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval100.0%
Applied rewrites100.0%
herbie shell --seed 2025326 -o generate:taylor -o generate:evaluate
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
(/ (- 1 (cos x)) (sin x)))