
(FPCore (x) :precision binary64 (- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))
double code(double x) {
return (x / x) - ((1.0 / x) * sqrt((x * x)));
}
real(8) function code(x)
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.0 / x), $MachinePrecision] * N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))
double code(double x) {
return (x / x) - ((1.0 / x) * sqrt((x * x)));
}
real(8) function code(x)
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.0 / x), $MachinePrecision] * N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
\end{array}
(FPCore (x) :precision binary64 (- 1.0 (/ (fabs x) x)))
double code(double x) {
return 1.0 - (fabs(x) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (abs(x) / x)
end function
public static double code(double x) {
return 1.0 - (Math.abs(x) / x);
}
def code(x): return 1.0 - (math.fabs(x) / x)
function code(x) return Float64(1.0 - Float64(abs(x) / x)) end
function tmp = code(x) tmp = 1.0 - (abs(x) / x); end
code[x_] := N[(1.0 - N[(N[Abs[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left|x\right|}{x}
\end{array}
Initial program 49.7%
cancel-sign-sub-inv49.7%
*-inverses49.7%
distribute-frac-neg249.7%
sqr-neg49.7%
*-inverses49.7%
cancel-sign-sub49.7%
*-inverses49.7%
*-inverses49.7%
distribute-neg-frac49.7%
*-inverses49.7%
metadata-eval49.7%
associate-*l/51.2%
neg-mul-151.2%
distribute-neg-frac51.2%
distribute-neg-frac251.2%
Simplified100.0%
(FPCore (x) :precision binary64 (if (<= x -4e-310) (- 1.0 (/ (/ (+ 1.0 (- -1.0 (* x -2.0))) (- 2.0 x)) x)) 0.0))
double code(double x) {
double tmp;
if (x <= -4e-310) {
tmp = 1.0 - (((1.0 + (-1.0 - (x * -2.0))) / (2.0 - x)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-4d-310)) then
tmp = 1.0d0 - (((1.0d0 + ((-1.0d0) - (x * (-2.0d0)))) / (2.0d0 - x)) / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -4e-310) {
tmp = 1.0 - (((1.0 + (-1.0 - (x * -2.0))) / (2.0 - x)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -4e-310: tmp = 1.0 - (((1.0 + (-1.0 - (x * -2.0))) / (2.0 - x)) / x) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= -4e-310) tmp = Float64(1.0 - Float64(Float64(Float64(1.0 + Float64(-1.0 - Float64(x * -2.0))) / Float64(2.0 - x)) / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -4e-310) tmp = 1.0 - (((1.0 + (-1.0 - (x * -2.0))) / (2.0 - x)) / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -4e-310], N[(1.0 - N[(N[(N[(1.0 + N[(-1.0 - N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;1 - \frac{\frac{1 + \left(-1 - x \cdot -2\right)}{2 - x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -3.999999999999988e-310Initial program 50.7%
cancel-sign-sub-inv50.7%
*-inverses50.7%
distribute-frac-neg250.7%
sqr-neg50.7%
*-inverses50.7%
cancel-sign-sub50.7%
*-inverses50.7%
*-inverses50.7%
distribute-neg-frac50.7%
*-inverses50.7%
metadata-eval50.7%
associate-*l/50.7%
neg-mul-150.7%
distribute-neg-frac50.7%
distribute-neg-frac250.7%
Simplified100.0%
expm1-log1p-u96.4%
expm1-undefine52.4%
log1p-undefine52.4%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt10.1%
rem-exp-log11.5%
Applied egg-rr11.5%
associate--l+11.6%
flip-+11.1%
metadata-eval11.1%
sub-neg11.1%
metadata-eval11.1%
sub-neg11.1%
metadata-eval11.1%
sub-neg11.1%
metadata-eval11.1%
Applied egg-rr11.1%
metadata-eval11.1%
associate--r+11.1%
+-commutative11.1%
associate-+l+11.1%
metadata-eval11.1%
+-rgt-identity11.1%
Simplified11.1%
Taylor expanded in x around 0 18.6%
*-commutative18.6%
Simplified18.6%
if -3.999999999999988e-310 < x Initial program 48.7%
cancel-sign-sub-inv48.7%
*-inverses48.7%
distribute-frac-neg248.7%
sqr-neg48.7%
*-inverses48.7%
cancel-sign-sub48.7%
*-inverses48.7%
*-inverses48.7%
distribute-neg-frac48.7%
*-inverses48.7%
metadata-eval48.7%
associate-*l/51.6%
neg-mul-151.6%
distribute-neg-frac51.6%
distribute-neg-frac251.6%
Simplified100.0%
Taylor expanded in x around 0 100.0%
div-sub100.0%
rem-square-sqrt49.1%
fabs-sqr49.1%
rem-square-sqrt100.0%
*-inverses100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification60.9%
(FPCore (x) :precision binary64 (if (<= x -5e+16) (- 1.0 (* x (* (+ x 2.0) (/ 1.0 (* x (+ x 2.0)))))) (if (<= x -4e-310) (- 1.0 (/ (+ 1.0 (+ x -1.0)) x)) 0.0)))
double code(double x) {
double tmp;
if (x <= -5e+16) {
tmp = 1.0 - (x * ((x + 2.0) * (1.0 / (x * (x + 2.0)))));
} else if (x <= -4e-310) {
tmp = 1.0 - ((1.0 + (x + -1.0)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-5d+16)) then
tmp = 1.0d0 - (x * ((x + 2.0d0) * (1.0d0 / (x * (x + 2.0d0)))))
else if (x <= (-4d-310)) then
tmp = 1.0d0 - ((1.0d0 + (x + (-1.0d0))) / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -5e+16) {
tmp = 1.0 - (x * ((x + 2.0) * (1.0 / (x * (x + 2.0)))));
} else if (x <= -4e-310) {
tmp = 1.0 - ((1.0 + (x + -1.0)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -5e+16: tmp = 1.0 - (x * ((x + 2.0) * (1.0 / (x * (x + 2.0))))) elif x <= -4e-310: tmp = 1.0 - ((1.0 + (x + -1.0)) / x) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= -5e+16) tmp = Float64(1.0 - Float64(x * Float64(Float64(x + 2.0) * Float64(1.0 / Float64(x * Float64(x + 2.0)))))); elseif (x <= -4e-310) tmp = Float64(1.0 - Float64(Float64(1.0 + Float64(x + -1.0)) / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -5e+16) tmp = 1.0 - (x * ((x + 2.0) * (1.0 / (x * (x + 2.0))))); elseif (x <= -4e-310) tmp = 1.0 - ((1.0 + (x + -1.0)) / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -5e+16], N[(1.0 - N[(x * N[(N[(x + 2.0), $MachinePrecision] * N[(1.0 / N[(x * N[(x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4e-310], N[(1.0 - N[(N[(1.0 + N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+16}:\\
\;\;\;\;1 - x \cdot \left(\left(x + 2\right) \cdot \frac{1}{x \cdot \left(x + 2\right)}\right)\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;1 - \frac{1 + \left(x + -1\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -5e16Initial program 48.9%
cancel-sign-sub-inv48.9%
*-inverses48.9%
distribute-frac-neg248.9%
sqr-neg48.9%
*-inverses48.9%
cancel-sign-sub48.9%
*-inverses48.9%
*-inverses48.9%
distribute-neg-frac48.9%
*-inverses48.9%
metadata-eval48.9%
associate-*l/48.9%
neg-mul-148.9%
distribute-neg-frac48.9%
distribute-neg-frac248.9%
Simplified100.0%
expm1-log1p-u92.0%
expm1-undefine92.0%
log1p-undefine92.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
rem-exp-log3.1%
Applied egg-rr3.1%
clear-num3.1%
associate-/r/4.1%
add-exp-log0.0%
expm1-define0.0%
log1p-define0.0%
expm1-log1p-u4.1%
Applied egg-rr4.1%
*-inverses4.1%
associate-/r*12.1%
clear-num12.2%
associate-/r/12.1%
*-commutative12.1%
Applied egg-rr12.1%
if -5e16 < x < -3.999999999999988e-310Initial program 52.2%
cancel-sign-sub-inv52.2%
*-inverses52.2%
distribute-frac-neg252.2%
sqr-neg52.2%
*-inverses52.2%
cancel-sign-sub52.2%
*-inverses52.2%
*-inverses52.2%
distribute-neg-frac52.2%
*-inverses52.2%
metadata-eval52.2%
associate-*l/52.2%
neg-mul-152.2%
distribute-neg-frac52.2%
distribute-neg-frac252.2%
Simplified100.0%
expm1-log1p-u99.9%
expm1-undefine20.3%
log1p-undefine20.3%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt18.2%
rem-exp-log18.3%
Applied egg-rr18.3%
associate--l+18.4%
+-commutative18.4%
sub-neg18.4%
metadata-eval18.4%
Applied egg-rr18.4%
if -3.999999999999988e-310 < x Initial program 48.7%
cancel-sign-sub-inv48.7%
*-inverses48.7%
distribute-frac-neg248.7%
sqr-neg48.7%
*-inverses48.7%
cancel-sign-sub48.7%
*-inverses48.7%
*-inverses48.7%
distribute-neg-frac48.7%
*-inverses48.7%
metadata-eval48.7%
associate-*l/51.6%
neg-mul-151.6%
distribute-neg-frac51.6%
distribute-neg-frac251.6%
Simplified100.0%
Taylor expanded in x around 0 100.0%
div-sub100.0%
rem-square-sqrt49.1%
fabs-sqr49.1%
rem-square-sqrt100.0%
*-inverses100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification59.5%
(FPCore (x) :precision binary64 (if (<= x -1e+20) (- 1.0 (* (+ x 2.0) (/ x (* x (+ x 2.0))))) (if (<= x -4e-310) (- 1.0 (/ (+ 1.0 (+ x -1.0)) x)) 0.0)))
double code(double x) {
double tmp;
if (x <= -1e+20) {
tmp = 1.0 - ((x + 2.0) * (x / (x * (x + 2.0))));
} else if (x <= -4e-310) {
tmp = 1.0 - ((1.0 + (x + -1.0)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1d+20)) then
tmp = 1.0d0 - ((x + 2.0d0) * (x / (x * (x + 2.0d0))))
else if (x <= (-4d-310)) then
tmp = 1.0d0 - ((1.0d0 + (x + (-1.0d0))) / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1e+20) {
tmp = 1.0 - ((x + 2.0) * (x / (x * (x + 2.0))));
} else if (x <= -4e-310) {
tmp = 1.0 - ((1.0 + (x + -1.0)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1e+20: tmp = 1.0 - ((x + 2.0) * (x / (x * (x + 2.0)))) elif x <= -4e-310: tmp = 1.0 - ((1.0 + (x + -1.0)) / x) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= -1e+20) tmp = Float64(1.0 - Float64(Float64(x + 2.0) * Float64(x / Float64(x * Float64(x + 2.0))))); elseif (x <= -4e-310) tmp = Float64(1.0 - Float64(Float64(1.0 + Float64(x + -1.0)) / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1e+20) tmp = 1.0 - ((x + 2.0) * (x / (x * (x + 2.0)))); elseif (x <= -4e-310) tmp = 1.0 - ((1.0 + (x + -1.0)) / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1e+20], N[(1.0 - N[(N[(x + 2.0), $MachinePrecision] * N[(x / N[(x * N[(x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4e-310], N[(1.0 - N[(N[(1.0 + N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+20}:\\
\;\;\;\;1 - \left(x + 2\right) \cdot \frac{x}{x \cdot \left(x + 2\right)}\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;1 - \frac{1 + \left(x + -1\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1e20Initial program 48.9%
cancel-sign-sub-inv48.9%
*-inverses48.9%
distribute-frac-neg248.9%
sqr-neg48.9%
*-inverses48.9%
cancel-sign-sub48.9%
*-inverses48.9%
*-inverses48.9%
distribute-neg-frac48.9%
*-inverses48.9%
metadata-eval48.9%
associate-*l/48.9%
neg-mul-148.9%
distribute-neg-frac48.9%
distribute-neg-frac248.9%
Simplified100.0%
expm1-log1p-u92.0%
expm1-undefine92.0%
log1p-undefine92.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
rem-exp-log3.1%
Applied egg-rr3.1%
add-exp-log3.1%
log-div0.0%
associate--l+0.0%
log1p-define0.0%
add-exp-log0.0%
expm1-define0.0%
log1p-expm1-u0.0%
log1p-expm1-u0.0%
expm1-define0.0%
add-exp-log0.0%
log1p-define0.0%
associate--l+0.0%
div-exp0.0%
add-exp-log0.0%
add-exp-log3.1%
flip--11.8%
associate-/r/12.1%
Applied egg-rr12.1%
if -1e20 < x < -3.999999999999988e-310Initial program 52.2%
cancel-sign-sub-inv52.2%
*-inverses52.2%
distribute-frac-neg252.2%
sqr-neg52.2%
*-inverses52.2%
cancel-sign-sub52.2%
*-inverses52.2%
*-inverses52.2%
distribute-neg-frac52.2%
*-inverses52.2%
metadata-eval52.2%
associate-*l/52.2%
neg-mul-152.2%
distribute-neg-frac52.2%
distribute-neg-frac252.2%
Simplified100.0%
expm1-log1p-u99.9%
expm1-undefine20.3%
log1p-undefine20.3%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt18.2%
rem-exp-log18.3%
Applied egg-rr18.3%
associate--l+18.4%
+-commutative18.4%
sub-neg18.4%
metadata-eval18.4%
Applied egg-rr18.4%
if -3.999999999999988e-310 < x Initial program 48.7%
cancel-sign-sub-inv48.7%
*-inverses48.7%
distribute-frac-neg248.7%
sqr-neg48.7%
*-inverses48.7%
cancel-sign-sub48.7%
*-inverses48.7%
*-inverses48.7%
distribute-neg-frac48.7%
*-inverses48.7%
metadata-eval48.7%
associate-*l/51.6%
neg-mul-151.6%
distribute-neg-frac51.6%
distribute-neg-frac251.6%
Simplified100.0%
Taylor expanded in x around 0 100.0%
div-sub100.0%
rem-square-sqrt49.1%
fabs-sqr49.1%
rem-square-sqrt100.0%
*-inverses100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification59.4%
(FPCore (x) :precision binary64 (if (<= x -4e-310) (- 1.0 (/ (+ 1.0 (+ x -1.0)) x)) 0.0))
double code(double x) {
double tmp;
if (x <= -4e-310) {
tmp = 1.0 - ((1.0 + (x + -1.0)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-4d-310)) then
tmp = 1.0d0 - ((1.0d0 + (x + (-1.0d0))) / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -4e-310) {
tmp = 1.0 - ((1.0 + (x + -1.0)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -4e-310: tmp = 1.0 - ((1.0 + (x + -1.0)) / x) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= -4e-310) tmp = Float64(1.0 - Float64(Float64(1.0 + Float64(x + -1.0)) / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -4e-310) tmp = 1.0 - ((1.0 + (x + -1.0)) / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -4e-310], N[(1.0 - N[(N[(1.0 + N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;1 - \frac{1 + \left(x + -1\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -3.999999999999988e-310Initial program 50.7%
cancel-sign-sub-inv50.7%
*-inverses50.7%
distribute-frac-neg250.7%
sqr-neg50.7%
*-inverses50.7%
cancel-sign-sub50.7%
*-inverses50.7%
*-inverses50.7%
distribute-neg-frac50.7%
*-inverses50.7%
metadata-eval50.7%
associate-*l/50.7%
neg-mul-150.7%
distribute-neg-frac50.7%
distribute-neg-frac250.7%
Simplified100.0%
expm1-log1p-u96.4%
expm1-undefine52.4%
log1p-undefine52.4%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt10.1%
rem-exp-log11.5%
Applied egg-rr11.5%
associate--l+11.6%
+-commutative11.6%
sub-neg11.6%
metadata-eval11.6%
Applied egg-rr11.6%
if -3.999999999999988e-310 < x Initial program 48.7%
cancel-sign-sub-inv48.7%
*-inverses48.7%
distribute-frac-neg248.7%
sqr-neg48.7%
*-inverses48.7%
cancel-sign-sub48.7%
*-inverses48.7%
*-inverses48.7%
distribute-neg-frac48.7%
*-inverses48.7%
metadata-eval48.7%
associate-*l/51.6%
neg-mul-151.6%
distribute-neg-frac51.6%
distribute-neg-frac251.6%
Simplified100.0%
Taylor expanded in x around 0 100.0%
div-sub100.0%
rem-square-sqrt49.1%
fabs-sqr49.1%
rem-square-sqrt100.0%
*-inverses100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification57.5%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 49.7%
cancel-sign-sub-inv49.7%
*-inverses49.7%
distribute-frac-neg249.7%
sqr-neg49.7%
*-inverses49.7%
cancel-sign-sub49.7%
*-inverses49.7%
*-inverses49.7%
distribute-neg-frac49.7%
*-inverses49.7%
metadata-eval49.7%
associate-*l/51.2%
neg-mul-151.2%
distribute-neg-frac51.2%
distribute-neg-frac251.2%
Simplified100.0%
Taylor expanded in x around 0 100.0%
div-sub100.0%
rem-square-sqrt25.5%
fabs-sqr25.5%
rem-square-sqrt53.5%
*-inverses53.5%
*-inverses53.5%
metadata-eval53.5%
Simplified53.5%
(FPCore (x) :precision binary64 (if (< x 0.0) 2.0 0.0))
double code(double x) {
double tmp;
if (x < 0.0) {
tmp = 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x < 0.0d0) then
tmp = 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x < 0.0) {
tmp = 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x < 0.0: tmp = 2.0 else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x < 0.0) tmp = 2.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x < 0.0) tmp = 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[Less[x, 0.0], 2.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x < 0:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
herbie shell --seed 2024179
(FPCore (x)
:name "sqrt sqr"
:precision binary64
:alt
(! :herbie-platform default (if (< x 0) 2 0))
(- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))