(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
↓
(FPCore (a b)
:precision binary64
(let* ((t_0 (/ 1.0 (+ (exp b) 1.0))))
(if (<= (exp b) 5e-55)
t_0
(if (<= (exp b) 2.0) (/ (exp a) (+ (exp a) 1.0)) t_0))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 / (exp(b) + 1.0d0)
if (exp(b) <= 5d-55) then
tmp = t_0
else if (exp(b) <= 2.0d0) then
tmp = exp(a) / (exp(a) + 1.0d0)
else
tmp = t_0
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 t_0 = 1.0 / (Math.exp(b) + 1.0);
double tmp;
if (Math.exp(b) <= 5e-55) {
tmp = t_0;
} else if (Math.exp(b) <= 2.0) {
tmp = Math.exp(a) / (Math.exp(a) + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
herbie shell --seed 2022338
(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))))