
(FPCore (x e) :precision binary64 (* (- 1.0 (pow (cos x) 2.0)) (pow e (- x))))
double code(double x, double e) {
return (1.0 - pow(cos(x), 2.0)) * pow(e, -x);
}
real(8) function code(x, e)
real(8), intent (in) :: x
real(8), intent (in) :: e
code = (1.0d0 - (cos(x) ** 2.0d0)) * (e ** -x)
end function
public static double code(double x, double e) {
return (1.0 - Math.pow(Math.cos(x), 2.0)) * Math.pow(e, -x);
}
def code(x, e): return (1.0 - math.pow(math.cos(x), 2.0)) * math.pow(e, -x)
function code(x, e) return Float64(Float64(1.0 - (cos(x) ^ 2.0)) * (e ^ Float64(-x))) end
function tmp = code(x, e) tmp = (1.0 - (cos(x) ^ 2.0)) * (e ^ -x); end
code[x_, e_] := N[(N[(1.0 - N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[e, (-x)], $MachinePrecision]), $MachinePrecision]
\left(1 - {\cos x}^{2}\right) \cdot {e}^{\left(-x\right)}
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x e) :precision binary64 (* (- 1.0 (pow (cos x) 2.0)) (pow e (- x))))
double code(double x, double e) {
return (1.0 - pow(cos(x), 2.0)) * pow(e, -x);
}
real(8) function code(x, e)
real(8), intent (in) :: x
real(8), intent (in) :: e
code = (1.0d0 - (cos(x) ** 2.0d0)) * (e ** -x)
end function
public static double code(double x, double e) {
return (1.0 - Math.pow(Math.cos(x), 2.0)) * Math.pow(e, -x);
}
def code(x, e): return (1.0 - math.pow(math.cos(x), 2.0)) * math.pow(e, -x)
function code(x, e) return Float64(Float64(1.0 - (cos(x) ^ 2.0)) * (e ^ Float64(-x))) end
function tmp = code(x, e) tmp = (1.0 - (cos(x) ^ 2.0)) * (e ^ -x); end
code[x_, e_] := N[(N[(1.0 - N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[e, (-x)], $MachinePrecision]), $MachinePrecision]
\left(1 - {\cos x}^{2}\right) \cdot {e}^{\left(-x\right)}
(FPCore (x e) :precision binary64 (- 1.0 (* (* 1.0 1.0) 1.0)))
double code(double x, double e) {
return 1.0 - ((1.0 * 1.0) * 1.0);
}
real(8) function code(x, e)
real(8), intent (in) :: x
real(8), intent (in) :: e
code = 1.0d0 - ((1.0d0 * 1.0d0) * 1.0d0)
end function
public static double code(double x, double e) {
return 1.0 - ((1.0 * 1.0) * 1.0);
}
def code(x, e): return 1.0 - ((1.0 * 1.0) * 1.0)
function code(x, e) return Float64(1.0 - Float64(Float64(1.0 * 1.0) * 1.0)) end
function tmp = code(x, e) tmp = 1.0 - ((1.0 * 1.0) * 1.0); end
code[x_, e_] := N[(1.0 - N[(N[(1.0 * 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision]
1 - \left(1 \cdot 1\right) \cdot 1
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
fp-cancel-sub-signN/A
*-lft-identityN/A
lower--.f64N/A
lower-*.f64100.0%
lift-pow.f64N/A
unpow2N/A
lower-*.f64100.0%
Applied rewrites100.0%
(FPCore (x e) :precision binary64 (* 1.0 (* x x)))
double code(double x, double e) {
return 1.0 * (x * x);
}
real(8) function code(x, e)
real(8), intent (in) :: x
real(8), intent (in) :: e
code = 1.0d0 * (x * x)
end function
public static double code(double x, double e) {
return 1.0 * (x * x);
}
def code(x, e): return 1.0 * (x * x)
function code(x, e) return Float64(1.0 * Float64(x * x)) end
function tmp = code(x, e) tmp = 1.0 * (x * x); end
code[x_, e_] := N[(1.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]
1 \cdot \left(x \cdot x\right)
Initial program 100.0%
Taylor expanded in x around 0
lower-pow.f6447.4%
Applied rewrites47.4%
Taylor expanded in x around 0
Applied rewrites1.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f641.8%
lift-pow.f64N/A
unpow2N/A
lower-*.f641.8%
Applied rewrites1.8%
herbie shell --seed 1
(FPCore (x e)
:name "(1-cos(x)^2)e^-x"
:precision binary64
:pre (and (and (<= 0.0 x) (<= x 1.79e+308)) (and (<= -1000.0 e) (<= e -1000.0)))
(* (- 1.0 (pow (cos x) 2.0)) (pow e (- x))))