
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / (y - (z * t))
end function
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
def code(x, y, z, t): return x / (y - (z * t))
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y - z \cdot t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / (y - (z * t))
end function
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
def code(x, y, z, t): return x / (y - (z * t))
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y - z \cdot t}
\end{array}
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / (y - (z * t))
end function
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
def code(x, y, z, t): return x / (y - (z * t))
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y - z \cdot t}
\end{array}
Initial program 97.9%
(FPCore (x y z t) :precision binary64 (if (<= (/ x (- y (* z t))) -5e-213) (* (- x) (+ (pow (* t z) -1.0) (/ y (pow (* t z) 2.0)))) (/ (/ x t) (- z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / (y - (z * t))) <= -5e-213) {
tmp = -x * (pow((t * z), -1.0) + (y / pow((t * z), 2.0)));
} else {
tmp = (x / t) / -z;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x / (y - (z * t))) <= (-5d-213)) then
tmp = -x * (((t * z) ** (-1.0d0)) + (y / ((t * z) ** 2.0d0)))
else
tmp = (x / t) / -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / (y - (z * t))) <= -5e-213) {
tmp = -x * (Math.pow((t * z), -1.0) + (y / Math.pow((t * z), 2.0)));
} else {
tmp = (x / t) / -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / (y - (z * t))) <= -5e-213: tmp = -x * (math.pow((t * z), -1.0) + (y / math.pow((t * z), 2.0))) else: tmp = (x / t) / -z return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / Float64(y - Float64(z * t))) <= -5e-213) tmp = Float64(Float64(-x) * Float64((Float64(t * z) ^ -1.0) + Float64(y / (Float64(t * z) ^ 2.0)))); else tmp = Float64(Float64(x / t) / Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / (y - (z * t))) <= -5e-213) tmp = -x * (((t * z) ^ -1.0) + (y / ((t * z) ^ 2.0))); else tmp = (x / t) / -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-213], N[((-x) * N[(N[Power[N[(t * z), $MachinePrecision], -1.0], $MachinePrecision] + N[(y / N[Power[N[(t * z), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y - z \cdot t} \leq -5 \cdot 10^{-213}:\\
\;\;\;\;\left(-x\right) \cdot \left({\left(t \cdot z\right)}^{-1} + \frac{y}{{\left(t \cdot z\right)}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\end{array}
\end{array}
if (/.f64 x (-.f64 y (*.f64 z t))) < -4.99999999999999977e-213Initial program 99.8%
Taylor expanded in t around inf
distribute-lft-outN/A
associate-*r/N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6426.9
Applied rewrites26.9%
Taylor expanded in x around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6435.3
Applied rewrites35.3%
if -4.99999999999999977e-213 < (/.f64 x (-.f64 y (*.f64 z t))) Initial program 97.0%
Taylor expanded in z around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
Applied rewrites37.7%
Taylor expanded in y around 0
lift-/.f6457.8
Applied rewrites57.8%
Final simplification51.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ x (- y (* z t)))) (t_2 (pow (* t z) 2.0)))
(if (or (<= t_1 -1e-321) (not (<= t_1 0.0)))
(* (- x) (+ (pow (* t z) -1.0) (/ y t_2)))
(- (* (+ (/ x (* (* z y) t)) (/ x t_2)) y)))))
double code(double x, double y, double z, double t) {
double t_1 = x / (y - (z * t));
double t_2 = pow((t * z), 2.0);
double tmp;
if ((t_1 <= -1e-321) || !(t_1 <= 0.0)) {
tmp = -x * (pow((t * z), -1.0) + (y / t_2));
} else {
tmp = -(((x / ((z * y) * t)) + (x / t_2)) * y);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x / (y - (z * t))
t_2 = (t * z) ** 2.0d0
if ((t_1 <= (-1d-321)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = -x * (((t * z) ** (-1.0d0)) + (y / t_2))
else
tmp = -(((x / ((z * y) * t)) + (x / t_2)) * y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x / (y - (z * t));
double t_2 = Math.pow((t * z), 2.0);
double tmp;
if ((t_1 <= -1e-321) || !(t_1 <= 0.0)) {
tmp = -x * (Math.pow((t * z), -1.0) + (y / t_2));
} else {
tmp = -(((x / ((z * y) * t)) + (x / t_2)) * y);
}
return tmp;
}
def code(x, y, z, t): t_1 = x / (y - (z * t)) t_2 = math.pow((t * z), 2.0) tmp = 0 if (t_1 <= -1e-321) or not (t_1 <= 0.0): tmp = -x * (math.pow((t * z), -1.0) + (y / t_2)) else: tmp = -(((x / ((z * y) * t)) + (x / t_2)) * y) return tmp
function code(x, y, z, t) t_1 = Float64(x / Float64(y - Float64(z * t))) t_2 = Float64(t * z) ^ 2.0 tmp = 0.0 if ((t_1 <= -1e-321) || !(t_1 <= 0.0)) tmp = Float64(Float64(-x) * Float64((Float64(t * z) ^ -1.0) + Float64(y / t_2))); else tmp = Float64(-Float64(Float64(Float64(x / Float64(Float64(z * y) * t)) + Float64(x / t_2)) * y)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x / (y - (z * t)); t_2 = (t * z) ^ 2.0; tmp = 0.0; if ((t_1 <= -1e-321) || ~((t_1 <= 0.0))) tmp = -x * (((t * z) ^ -1.0) + (y / t_2)); else tmp = -(((x / ((z * y) * t)) + (x / t_2)) * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(t * z), $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e-321], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[((-x) * N[(N[Power[N[(t * z), $MachinePrecision], -1.0], $MachinePrecision] + N[(y / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(N[(N[(x / N[(N[(z * y), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(x / t$95$2), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision])]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{y - z \cdot t}\\
t_2 := {\left(t \cdot z\right)}^{2}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-321} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\left(-x\right) \cdot \left({\left(t \cdot z\right)}^{-1} + \frac{y}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;-\left(\frac{x}{\left(z \cdot y\right) \cdot t} + \frac{x}{t\_2}\right) \cdot y\\
\end{array}
\end{array}
if (/.f64 x (-.f64 y (*.f64 z t))) < -9.98013e-322 or -0.0 < (/.f64 x (-.f64 y (*.f64 z t))) Initial program 99.8%
Taylor expanded in t around inf
distribute-lft-outN/A
associate-*r/N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6432.0
Applied rewrites32.0%
Taylor expanded in x around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6441.5
Applied rewrites41.5%
if -9.98013e-322 < (/.f64 x (-.f64 y (*.f64 z t))) < -0.0Initial program 92.8%
Taylor expanded in t around inf
distribute-lft-outN/A
associate-*r/N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6471.6
Applied rewrites71.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6473.5
Applied rewrites73.5%
Final simplification50.5%
(FPCore (x y z t) :precision binary64 (* (- x) (+ (pow (* t z) -1.0) (/ y (pow (* t z) 2.0)))))
double code(double x, double y, double z, double t) {
return -x * (pow((t * z), -1.0) + (y / pow((t * z), 2.0)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = -x * (((t * z) ** (-1.0d0)) + (y / ((t * z) ** 2.0d0)))
end function
public static double code(double x, double y, double z, double t) {
return -x * (Math.pow((t * z), -1.0) + (y / Math.pow((t * z), 2.0)));
}
def code(x, y, z, t): return -x * (math.pow((t * z), -1.0) + (y / math.pow((t * z), 2.0)))
function code(x, y, z, t) return Float64(Float64(-x) * Float64((Float64(t * z) ^ -1.0) + Float64(y / (Float64(t * z) ^ 2.0)))) end
function tmp = code(x, y, z, t) tmp = -x * (((t * z) ^ -1.0) + (y / ((t * z) ^ 2.0))); end
code[x_, y_, z_, t_] := N[((-x) * N[(N[Power[N[(t * z), $MachinePrecision], -1.0], $MachinePrecision] + N[(y / N[Power[N[(t * z), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-x\right) \cdot \left({\left(t \cdot z\right)}^{-1} + \frac{y}{{\left(t \cdot z\right)}^{2}}\right)
\end{array}
Initial program 97.9%
Taylor expanded in t around inf
distribute-lft-outN/A
associate-*r/N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6443.1
Applied rewrites43.1%
Taylor expanded in x around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6447.2
Applied rewrites47.2%
Final simplification47.2%
herbie shell --seed 2025057
(FPCore (x y z t)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
:alt
(! :herbie-platform default (if (< x -161819597360704900000000000000000000000000000000000) (/ 1 (- (/ y x) (* (/ z x) t))) (if (< x 213783064348764440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ x (- y (* z t))) (/ 1 (- (/ y x) (* (/ z x) t))))))
(/ x (- y (* z t))))