
(FPCore (x) :precision binary64 (- (/ x x) (* (/ 1 x) (sqrt (* x x)))))
double code(double x) {
return (x / x) - ((1.0 / x) * sqrt((x * x)));
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (x / x) - ((1.0d0 / x) * sqrt((x * x)))
end function
public static double code(double x) {
return (x / x) - ((1.0 / x) * Math.sqrt((x * x)));
}
def code(x): return (x / x) - ((1.0 / x) * math.sqrt((x * x)))
function code(x) return Float64(Float64(x / x) - Float64(Float64(1.0 / x) * sqrt(Float64(x * x)))) end
function tmp = code(x) tmp = (x / x) - ((1.0 / x) * sqrt((x * x))); end
code[x_] := N[(N[(x / x), $MachinePrecision] - N[(N[(1 / x), $MachinePrecision] * N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
Herbie found 1 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ x x) (* (/ 1 x) (sqrt (* x x)))))
double code(double x) {
return (x / x) - ((1.0 / x) * sqrt((x * x)));
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (x / x) - ((1.0d0 / x) * sqrt((x * x)))
end function
public static double code(double x) {
return (x / x) - ((1.0 / x) * Math.sqrt((x * x)));
}
def code(x): return (x / x) - ((1.0 / x) * math.sqrt((x * x)))
function code(x) return Float64(Float64(x / x) - Float64(Float64(1.0 / x) * sqrt(Float64(x * x)))) end
function tmp = code(x) tmp = (x / x) - ((1.0 / x) * sqrt((x * x))); end
code[x_] := N[(N[(x / x), $MachinePrecision] - N[(N[(1 / x), $MachinePrecision] * N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
(FPCore (x) :precision binary64 (/ (- x (fabs x)) x))
double code(double x) {
return (x - fabs(x)) / x;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (x - abs(x)) / x
end function
public static double code(double x) {
return (x - Math.abs(x)) / x;
}
def code(x): return (x - math.fabs(x)) / x
function code(x) return Float64(Float64(x - abs(x)) / x) end
function tmp = code(x) tmp = (x - abs(x)) / x; end
code[x_] := N[(N[(x - N[Abs[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\frac{x - \left|x\right|}{x}
Initial program 50.2%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
sub-divN/A
*-lft-identityN/A
add-sound-/N/A
lower-/.f64N/A
lower--.f6454.0%
lift-sqrt.f64N/A
lift-*.f64N/A
rem-sqrt-squareN/A
lower-fabs.f64100.0%
Applied rewrites100.0%
herbie shell --seed 2025326 -o generate:taylor -o generate:evaluate
(FPCore (x)
:name "sqrt sqr"
:precision binary64
(- (/ x x) (* (/ 1 x) (sqrt (* x x)))))