(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ y (/ (- z a) (- z t))))) (t_2 (/ (* y (- z t)) (- z a))))
(if (<= t_2 -2e+295)
t_1
(if (<= t_2 2e+154)
(- (+ x (/ (* y z) (- z a))) (/ (* y t) (- z a)))
t_1))))double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (y / ((z - a) / (z - t)));
double t_2 = (y * (z - t)) / (z - a);
double tmp;
if (t_2 <= -2e+295) {
tmp = t_1;
} else if (t_2 <= 2e+154) {
tmp = (x + ((y * z) / (z - a))) - ((y * t) / (z - a));
} 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)) / (z - a))
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) :: t_2
real(8) :: tmp
t_1 = x + (y / ((z - a) / (z - t)))
t_2 = (y * (z - t)) / (z - a)
if (t_2 <= (-2d+295)) then
tmp = t_1
else if (t_2 <= 2d+154) then
tmp = (x + ((y * z) / (z - a))) - ((y * t) / (z - a))
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)) / (z - a));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x + (y / ((z - a) / (z - t)));
double t_2 = (y * (z - t)) / (z - a);
double tmp;
if (t_2 <= -2e+295) {
tmp = t_1;
} else if (t_2 <= 2e+154) {
tmp = (x + ((y * z) / (z - a))) - ((y * t) / (z - a));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
def code(x, y, z, t, a): t_1 = x + (y / ((z - a) / (z - t))) t_2 = (y * (z - t)) / (z - a) tmp = 0 if t_2 <= -2e+295: tmp = t_1 elif t_2 <= 2e+154: tmp = (x + ((y * z) / (z - a))) - ((y * t) / (z - a)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function code(x, y, z, t, a) t_1 = Float64(x + Float64(y / Float64(Float64(z - a) / Float64(z - t)))) t_2 = Float64(Float64(y * Float64(z - t)) / Float64(z - a)) tmp = 0.0 if (t_2 <= -2e+295) tmp = t_1; elseif (t_2 <= 2e+154) tmp = Float64(Float64(x + Float64(Float64(y * z) / Float64(z - a))) - Float64(Float64(y * t) / Float64(z - a))); else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
function tmp_2 = code(x, y, z, t, a) t_1 = x + (y / ((z - a) / (z - t))); t_2 = (y * (z - t)) / (z - a); tmp = 0.0; if (t_2 <= -2e+295) tmp = t_1; elseif (t_2 <= 2e+154) tmp = (x + ((y * z) / (z - a))) - ((y * t) / (z - a)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(y / N[(N[(z - a), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+295], t$95$1, If[LessEqual[t$95$2, 2e+154], N[(N[(x + N[(N[(y * z), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y * t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
x + \frac{y \cdot \left(z - t\right)}{z - a}
\begin{array}{l}
t_1 := x + \frac{y}{\frac{z - a}{z - t}}\\
t_2 := \frac{y \cdot \left(z - t\right)}{z - a}\\
\mathbf{if}\;t_2 \leq -2 \cdot 10^{+295}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+154}:\\
\;\;\;\;\left(x + \frac{y \cdot z}{z - a}\right) - \frac{y \cdot t}{z - a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 10.9 |
|---|---|
| Target | 1.2 |
| Herbie | 0.6 |
if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < -2e295 or 2.00000000000000007e154 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) Initial program 48.8
Simplified2.2
Applied egg-rr1.9
if -2e295 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < 2.00000000000000007e154Initial program 0.3
Simplified1.1
Taylor expanded in t around 0 0.3
Final simplification0.6
herbie shell --seed 2022182
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, A"
:precision binary64
:herbie-target
(+ x (/ y (/ (- z a) (- z t))))
(+ x (/ (* y (- z t)) (- z a))))