| Alternative 1 | |
|---|---|
| Error | 29.7 |
| Cost | 1504 |
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (* (- t x) (/ (- y z) (- a z))))))
(if (<= a -1.02e-209)
t_1
(if (<= a 2.2e-180) (- t (/ (- t x) (/ z y))) t_1))))double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = x + ((t - x) * ((y - z) / (a - z)));
double tmp;
if (a <= -1.02e-209) {
tmp = t_1;
} else if (a <= 2.2e-180) {
tmp = t - ((t - x) / (z / y));
} 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 - x)) / (a - z))
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 + ((t - x) * ((y - z) / (a - z)))
if (a <= (-1.02d-209)) then
tmp = t_1
else if (a <= 2.2d-180) then
tmp = t - ((t - x) / (z / y))
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 - x)) / (a - z));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x + ((t - x) * ((y - z) / (a - z)));
double tmp;
if (a <= -1.02e-209) {
tmp = t_1;
} else if (a <= 2.2e-180) {
tmp = t - ((t - x) / (z / y));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): return x + (((y - z) * (t - x)) / (a - z))
def code(x, y, z, t, a): t_1 = x + ((t - x) * ((y - z) / (a - z))) tmp = 0 if a <= -1.02e-209: tmp = t_1 elif a <= 2.2e-180: tmp = t - ((t - x) / (z / y)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) end
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(t - x) * Float64(Float64(y - z) / Float64(a - z)))) tmp = 0.0 if (a <= -1.02e-209) tmp = t_1; elseif (a <= 2.2e-180) tmp = Float64(t - Float64(Float64(t - x) / Float64(z / y))); else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * (t - x)) / (a - z)); end
function tmp_2 = code(x, y, z, t, a) t_1 = x + ((t - x) * ((y - z) / (a - z))); tmp = 0.0; if (a <= -1.02e-209) tmp = t_1; elseif (a <= 2.2e-180) tmp = t - ((t - x) / (z / y)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.02e-209], t$95$1, If[LessEqual[a, 2.2e-180], N[(t - N[(N[(t - x), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
t_1 := x + \left(t - x\right) \cdot \frac{y - z}{a - z}\\
\mathbf{if}\;a \leq -1.02 \cdot 10^{-209}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \leq 2.2 \cdot 10^{-180}:\\
\;\;\;\;t - \frac{t - x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 24.4 |
|---|---|
| Target | 11.9 |
| Herbie | 9.8 |
if a < -1.01999999999999999e-209 or 2.20000000000000013e-180 < a Initial program 23.5
Simplified10.4
[Start]23.5 | \[ x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\] |
|---|---|
rational.json-simplify-49 [=>]10.4 | \[ x + \color{blue}{\left(t - x\right) \cdot \frac{y - z}{a - z}}
\] |
if -1.01999999999999999e-209 < a < 2.20000000000000013e-180Initial program 28.9
Simplified19.5
[Start]28.9 | \[ x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\] |
|---|---|
rational.json-simplify-49 [=>]19.5 | \[ x + \color{blue}{\left(t - x\right) \cdot \frac{y - z}{a - z}}
\] |
Taylor expanded in z around -inf 9.4
Simplified9.4
[Start]9.4 | \[ -1 \cdot \frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z} + t
\] |
|---|---|
rational.json-simplify-1 [=>]9.4 | \[ \color{blue}{t + -1 \cdot \frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z}}
\] |
rational.json-simplify-2 [=>]9.4 | \[ t + \color{blue}{\frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z} \cdot -1}
\] |
rational.json-simplify-9 [=>]9.4 | \[ t + \color{blue}{\left(-\frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z}\right)}
\] |
rational.json-simplify-2 [=>]9.4 | \[ t + \left(-\frac{\color{blue}{\left(t - x\right) \cdot y} - a \cdot \left(t - x\right)}{z}\right)
\] |
rational.json-simplify-52 [=>]9.4 | \[ t + \left(-\frac{\color{blue}{\left(t - x\right) \cdot \left(y - a\right)}}{z}\right)
\] |
Taylor expanded in a around 0 11.0
Simplified6.7
[Start]11.0 | \[ t - \frac{y \cdot \left(t - x\right)}{z}
\] |
|---|---|
rational.json-simplify-49 [=>]6.8 | \[ t - \color{blue}{\left(t - x\right) \cdot \frac{y}{z}}
\] |
rational.json-simplify-2 [=>]6.8 | \[ t - \color{blue}{\frac{y}{z} \cdot \left(t - x\right)}
\] |
rational.json-simplify-35 [=>]6.8 | \[ t - \color{blue}{\frac{y + y}{z + z}} \cdot \left(t - x\right)
\] |
rational.json-simplify-7 [<=]6.8 | \[ t - \frac{y + y}{\color{blue}{\frac{z + z}{1}}} \cdot \left(t - x\right)
\] |
rational.json-simplify-61 [=>]6.9 | \[ t - \color{blue}{\frac{1}{\frac{z + z}{y + y}}} \cdot \left(t - x\right)
\] |
rational.json-simplify-7 [<=]6.9 | \[ t - \frac{1}{\frac{z + z}{y + y}} \cdot \color{blue}{\frac{t - x}{1}}
\] |
rational.json-simplify-55 [=>]6.7 | \[ t - \color{blue}{\frac{\frac{t - x}{1}}{\frac{\frac{z + z}{y + y}}{1}}}
\] |
rational.json-simplify-7 [=>]6.7 | \[ t - \frac{\color{blue}{t - x}}{\frac{\frac{z + z}{y + y}}{1}}
\] |
rational.json-simplify-7 [=>]6.7 | \[ t - \frac{t - x}{\color{blue}{\frac{z + z}{y + y}}}
\] |
rational.json-simplify-36 [=>]6.7 | \[ t - \frac{t - x}{\color{blue}{\frac{z}{y}}}
\] |
Final simplification9.8
| Alternative 1 | |
|---|---|
| Error | 29.7 |
| Cost | 1504 |
| Alternative 2 | |
|---|---|
| Error | 30.5 |
| Cost | 1504 |
| Alternative 3 | |
|---|---|
| Error | 30.6 |
| Cost | 1504 |
| Alternative 4 | |
|---|---|
| Error | 31.0 |
| Cost | 1504 |
| Alternative 5 | |
|---|---|
| Error | 23.5 |
| Cost | 1368 |
| Alternative 6 | |
|---|---|
| Error | 22.5 |
| Cost | 1368 |
| Alternative 7 | |
|---|---|
| Error | 31.7 |
| Cost | 1240 |
| Alternative 8 | |
|---|---|
| Error | 31.8 |
| Cost | 1240 |
| Alternative 9 | |
|---|---|
| Error | 31.7 |
| Cost | 1240 |
| Alternative 10 | |
|---|---|
| Error | 31.8 |
| Cost | 1240 |
| Alternative 11 | |
|---|---|
| Error | 23.5 |
| Cost | 1236 |
| Alternative 12 | |
|---|---|
| Error | 15.3 |
| Cost | 1232 |
| Alternative 13 | |
|---|---|
| Error | 23.7 |
| Cost | 1104 |
| Alternative 14 | |
|---|---|
| Error | 23.7 |
| Cost | 1104 |
| Alternative 15 | |
|---|---|
| Error | 24.1 |
| Cost | 1104 |
| Alternative 16 | |
|---|---|
| Error | 27.1 |
| Cost | 1040 |
| Alternative 17 | |
|---|---|
| Error | 19.8 |
| Cost | 972 |
| Alternative 18 | |
|---|---|
| Error | 35.0 |
| Cost | 712 |
| Alternative 19 | |
|---|---|
| Error | 36.4 |
| Cost | 328 |
| Alternative 20 | |
|---|---|
| Error | 45.8 |
| Cost | 64 |
herbie shell --seed 2023074
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
:precision binary64
:herbie-target
(if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))
(+ x (/ (* (- y z) (- t x)) (- a z))))