(FPCore (a b) :precision binary64 (log (+ (exp a) (exp b))))
↓
(FPCore (a b)
:precision binary64
(if (<= a -38.0) (/ b (+ (exp a) 1.0)) (log (+ (exp a) (exp b)))))
double code(double a, double b) {
return log((exp(a) + exp(b)));
}
↓
double code(double a, double b) {
double tmp;
if (a <= -38.0) {
tmp = b / (exp(a) + 1.0);
} else {
tmp = log((exp(a) + exp(b)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = log((exp(a) + exp(b)))
end function
↓
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-38.0d0)) then
tmp = b / (exp(a) + 1.0d0)
else
tmp = log((exp(a) + exp(b)))
end if
code = tmp
end function
public static double code(double a, double b) {
return Math.log((Math.exp(a) + Math.exp(b)));
}
↓
public static double code(double a, double b) {
double tmp;
if (a <= -38.0) {
tmp = b / (Math.exp(a) + 1.0);
} else {
tmp = Math.log((Math.exp(a) + Math.exp(b)));
}
return tmp;
}
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.
Herbie found 12 alternatives:
Alternative
Accuracy
Speedup
Accuracy vs Speed
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.