(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- a t)))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ y (/ (- a t) (- z t))))))
(if (<= y -2.763118437090793e-294)
t_1
(if (<= y 1e+40) (+ x (/ (* y (- z t)) (- a t))) t_1))))double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (a - t)));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (y / ((a - t) / (z - t)));
double tmp;
if (y <= -2.763118437090793e-294) {
tmp = t_1;
} else if (y <= 1e+40) {
tmp = x + ((y * (z - t)) / (a - t));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + (y * ((z - t) / (a - t)))
end function
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = x + (y / ((a - t) / (z - t)))
if (y <= (-2.763118437090793d-294)) then
tmp = t_1
else if (y <= 1d+40) then
tmp = x + ((y * (z - t)) / (a - t))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (a - t)));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x + (y / ((a - t) / (z - t)));
double tmp;
if (y <= -2.763118437090793e-294) {
tmp = t_1;
} else if (y <= 1e+40) {
tmp = x + ((y * (z - t)) / (a - t));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): return x + (y * ((z - t) / (a - t)))
def code(x, y, z, t, a): t_1 = x + (y / ((a - t) / (z - t))) tmp = 0 if y <= -2.763118437090793e-294: tmp = t_1 elif y <= 1e+40: tmp = x + ((y * (z - t)) / (a - t)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(a - t)))) end
function code(x, y, z, t, a) t_1 = Float64(x + Float64(y / Float64(Float64(a - t) / Float64(z - t)))) tmp = 0.0 if (y <= -2.763118437090793e-294) tmp = t_1; elseif (y <= 1e+40) tmp = Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t))); else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t, a) tmp = x + (y * ((z - t) / (a - t))); end
function tmp_2 = code(x, y, z, t, a) t_1 = x + (y / ((a - t) / (z - t))); tmp = 0.0; if (y <= -2.763118437090793e-294) tmp = t_1; elseif (y <= 1e+40) tmp = x + ((y * (z - t)) / (a - t)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.763118437090793e-294], t$95$1, If[LessEqual[y, 1e+40], N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
t_1 := x + \frac{y}{\frac{a - t}{z - t}}\\
\mathbf{if}\;y \leq -2.763118437090793 \cdot 10^{-294}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 10^{+40}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a - t}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 1.5 |
|---|---|
| Target | 0.4 |
| Herbie | 0.9 |
if y < -2.76311843709079307e-294 or 1.00000000000000003e40 < y Initial program 1.2
Applied egg-rr1.1
if -2.76311843709079307e-294 < y < 1.00000000000000003e40Initial program 2.2
Taylor expanded in y around 0 0.6
Final simplification0.9
herbie shell --seed 2022182
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, B"
:precision binary64
:herbie-target
(if (< y -8.508084860551241e-17) (+ x (* y (/ (- z t) (- a t)))) (if (< y 2.894426862792089e-49) (+ x (* (* y (- z t)) (/ 1.0 (- a t)))) (+ x (* y (/ (- z t) (- a t))))))
(+ x (* y (/ (- z t) (- a t)))))