(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
↓
(FPCore (a b)
:precision binary64
(if (<= a -120000000.0) (exp a) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
↓
double code(double a, double b) {
double tmp;
if (a <= -120000000.0) {
tmp = exp(a);
} else {
tmp = 1.0 / (exp(b) + 1.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (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 <= (-120000000.0d0)) then
tmp = exp(a)
else
tmp = 1.0d0 / (exp(b) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
↓
public static double code(double a, double b) {
double tmp;
if (a <= -120000000.0) {
tmp = Math.exp(a);
} else {
tmp = 1.0 / (Math.exp(b) + 1.0);
}
return tmp;
}
herbie shell --seed 2023187
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:herbie-target
(/ 1.0 (+ 1.0 (exp (- b a))))
(/ (exp a) (+ (exp a) (exp b))))