(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
(FPCore (x y z t a) :precision binary64 (+ (/ y (/ (- a t) (- z t))) (* x (- (+ (/ t (- a t)) 1.0) (/ z (- a t))))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
return (y / ((a - t) / (z - t))) + (x * (((t / (a - t)) + 1.0) - (z / (a - t))));
}
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 - x) * (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
code = (y / ((a - t) / (z - t))) + (x * (((t / (a - t)) + 1.0d0) - (z / (a - t))))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
return (y / ((a - t) / (z - t))) + (x * (((t / (a - t)) + 1.0) - (z / (a - t))));
}
def code(x, y, z, t, a): return x + (((y - x) * (z - t)) / (a - t))
def code(x, y, z, t, a): return (y / ((a - t) / (z - t))) + (x * (((t / (a - t)) + 1.0) - (z / (a - t))))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) end
function code(x, y, z, t, a) return Float64(Float64(y / Float64(Float64(a - t) / Float64(z - t))) + Float64(x * Float64(Float64(Float64(t / Float64(a - t)) + 1.0) - Float64(z / Float64(a - t))))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - x) * (z - t)) / (a - t)); end
function tmp = code(x, y, z, t, a) tmp = (y / ((a - t) / (z - t))) + (x * (((t / (a - t)) + 1.0) - (z / (a - t)))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(N[(N[(t / N[(a - t), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\frac{y}{\frac{a - t}{z - t}} + x \cdot \left(\left(\frac{t}{a - t} + 1\right) - \frac{z}{a - t}\right)
Results
| Original | 24.4 |
|---|---|
| Target | 9.7 |
| Herbie | 4.7 |
Initial program 24.4
Simplified15.0
Taylor expanded in x around -inf 15.1
Simplified7.8
Applied egg-rr7.9
Applied egg-rr4.7
Final simplification4.7
herbie shell --seed 2022192
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
:precision binary64
:herbie-target
(if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t))))))
(+ x (/ (* (- y x) (- z t)) (- a t))))