
(FPCore (x y z) :precision binary64 :pre TRUE (+ (* x y) (* (- x 1.0) z)))
double code(double x, double y, double z) {
return (x * y) + ((x - 1.0) * z);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) + ((x - 1.0d0) * z)
end function
public static double code(double x, double y, double z) {
return (x * y) + ((x - 1.0) * z);
}
def code(x, y, z): return (x * y) + ((x - 1.0) * z)
function code(x, y, z) return Float64(Float64(x * y) + Float64(Float64(x - 1.0) * z)) end
function tmp = code(x, y, z) tmp = (x * y) + ((x - 1.0) * z); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(N[(x - 1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * y) + ((x - (1)) * z) END code
x \cdot y + \left(x - 1\right) \cdot z
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (+ (* x y) (* (- x 1.0) z)))
double code(double x, double y, double z) {
return (x * y) + ((x - 1.0) * z);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) + ((x - 1.0d0) * z)
end function
public static double code(double x, double y, double z) {
return (x * y) + ((x - 1.0) * z);
}
def code(x, y, z): return (x * y) + ((x - 1.0) * z)
function code(x, y, z) return Float64(Float64(x * y) + Float64(Float64(x - 1.0) * z)) end
function tmp = code(x, y, z) tmp = (x * y) + ((x - 1.0) * z); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(N[(x - 1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * y) + ((x - (1)) * z) END code
x \cdot y + \left(x - 1\right) \cdot z
(FPCore (x y z) :precision binary64 :pre TRUE (- (* x (+ y z)) z))
double code(double x, double y, double z) {
return (x * (y + z)) - z;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (y + z)) - z
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) - z;
}
def code(x, y, z): return (x * (y + z)) - z
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) - z) end
function tmp = code(x, y, z) tmp = (x * (y + z)) - z; end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * (y + z)) - z END code
x \cdot \left(y + z\right) - z
Initial program 97.9%
Applied rewrites100.0%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (+ y z))))
(if (<= x -14298.649587223466)
t_0
(if (<= x 0.0005660629841236394) (fma z -1.0 (* y x)) t_0))))double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -14298.649587223466) {
tmp = t_0;
} else if (x <= 0.0005660629841236394) {
tmp = fma(z, -1.0, (y * x));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * Float64(y + z)) tmp = 0.0 if (x <= -14298.649587223466) tmp = t_0; elseif (x <= 0.0005660629841236394) tmp = fma(z, -1.0, Float64(y * x)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -14298.649587223466], t$95$0, If[LessEqual[x, 0.0005660629841236394], N[(z * -1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET t_0 = (x * (y + z)) IN LET tmp_1 = IF (x <= (566062984123639448448550570702764161978848278522491455078125e-63)) THEN ((z * (-1)) + (y * x)) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-14298649587223466369323432445526123046875e-36)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
\mathbf{if}\;x \leq -14298.649587223466:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.0005660629841236394:\\
\;\;\;\;\mathsf{fma}\left(z, -1, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -14298.649587223466 or 5.6606298412363945e-4 < x Initial program 97.9%
Taylor expanded in x around inf
Applied rewrites64.9%
if -14298.649587223466 < x < 5.6606298412363945e-4Initial program 97.9%
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites75.8%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (+ y z))))
(if (<= x -2.8368855981903414e-51)
t_0
(if (<= x 464742860.8895076) (* z (- x 1.0)) t_0))))double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -2.8368855981903414e-51) {
tmp = t_0;
} else if (x <= 464742860.8895076) {
tmp = z * (x - 1.0);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (y + z)
if (x <= (-2.8368855981903414d-51)) then
tmp = t_0
else if (x <= 464742860.8895076d0) then
tmp = z * (x - 1.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -2.8368855981903414e-51) {
tmp = t_0;
} else if (x <= 464742860.8895076) {
tmp = z * (x - 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y + z) tmp = 0 if x <= -2.8368855981903414e-51: tmp = t_0 elif x <= 464742860.8895076: tmp = z * (x - 1.0) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y + z)) tmp = 0.0 if (x <= -2.8368855981903414e-51) tmp = t_0; elseif (x <= 464742860.8895076) tmp = Float64(z * Float64(x - 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y + z); tmp = 0.0; if (x <= -2.8368855981903414e-51) tmp = t_0; elseif (x <= 464742860.8895076) tmp = z * (x - 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.8368855981903414e-51], t$95$0, If[LessEqual[x, 464742860.8895076], N[(z * N[(x - 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET t_0 = (x * (y + z)) IN LET tmp_1 = IF (x <= (464742860889507591724395751953125e-24)) THEN (z * (x - (1))) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-28368855981903414102920337465896913142028897505741484614367286972627935745057502704794255345263793652131194254318143559929623156480593682005064692930318415164947509765625e-220)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
\mathbf{if}\;x \leq -2.8368855981903414 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 464742860.8895076:\\
\;\;\;\;z \cdot \left(x - 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -2.8368855981903414e-51 or 464742860.88950759 < x Initial program 97.9%
Taylor expanded in x around inf
Applied rewrites64.9%
if -2.8368855981903414e-51 < x < 464742860.88950759Initial program 97.9%
Taylor expanded in y around 0
Applied rewrites62.4%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (+ y z))))
(if (<= x -2.8368855981903414e-51)
t_0
(if (<= x 9.957315309628584e-34) (* z -1.0) t_0))))double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -2.8368855981903414e-51) {
tmp = t_0;
} else if (x <= 9.957315309628584e-34) {
tmp = z * -1.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (y + z)
if (x <= (-2.8368855981903414d-51)) then
tmp = t_0
else if (x <= 9.957315309628584d-34) then
tmp = z * (-1.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -2.8368855981903414e-51) {
tmp = t_0;
} else if (x <= 9.957315309628584e-34) {
tmp = z * -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y + z) tmp = 0 if x <= -2.8368855981903414e-51: tmp = t_0 elif x <= 9.957315309628584e-34: tmp = z * -1.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y + z)) tmp = 0.0 if (x <= -2.8368855981903414e-51) tmp = t_0; elseif (x <= 9.957315309628584e-34) tmp = Float64(z * -1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y + z); tmp = 0.0; if (x <= -2.8368855981903414e-51) tmp = t_0; elseif (x <= 9.957315309628584e-34) tmp = z * -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.8368855981903414e-51], t$95$0, If[LessEqual[x, 9.957315309628584e-34], N[(z * -1.0), $MachinePrecision], t$95$0]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET t_0 = (x * (y + z)) IN LET tmp_1 = IF (x <= (995731530962858429324473884117268777133337992305983115666935440622549596510538661930608296535272216942757950164377689361572265625e-162)) THEN (z * (-1)) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-28368855981903414102920337465896913142028897505741484614367286972627935745057502704794255345263793652131194254318143559929623156480593682005064692930318415164947509765625e-220)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
\mathbf{if}\;x \leq -2.8368855981903414 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9.957315309628584 \cdot 10^{-34}:\\
\;\;\;\;z \cdot -1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -2.8368855981903414e-51 or 9.9573153096285843e-34 < x Initial program 97.9%
Taylor expanded in x around inf
Applied rewrites64.9%
if -2.8368855981903414e-51 < x < 9.9573153096285843e-34Initial program 97.9%
Taylor expanded in y around 0
Applied rewrites62.4%
Taylor expanded in x around 0
Applied rewrites36.9%
(FPCore (x y z)
:precision binary64
:pre TRUE
(if (<= x -1.5035300976793776e+239)
(* x z)
(if (<= x -2.8368855981903414e-51)
(* x y)
(if (<= x 9.957315309628584e-34) (* z -1.0) (* x y)))))double code(double x, double y, double z) {
double tmp;
if (x <= -1.5035300976793776e+239) {
tmp = x * z;
} else if (x <= -2.8368855981903414e-51) {
tmp = x * y;
} else if (x <= 9.957315309628584e-34) {
tmp = z * -1.0;
} else {
tmp = x * y;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.5035300976793776d+239)) then
tmp = x * z
else if (x <= (-2.8368855981903414d-51)) then
tmp = x * y
else if (x <= 9.957315309628584d-34) then
tmp = z * (-1.0d0)
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.5035300976793776e+239) {
tmp = x * z;
} else if (x <= -2.8368855981903414e-51) {
tmp = x * y;
} else if (x <= 9.957315309628584e-34) {
tmp = z * -1.0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.5035300976793776e+239: tmp = x * z elif x <= -2.8368855981903414e-51: tmp = x * y elif x <= 9.957315309628584e-34: tmp = z * -1.0 else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.5035300976793776e+239) tmp = Float64(x * z); elseif (x <= -2.8368855981903414e-51) tmp = Float64(x * y); elseif (x <= 9.957315309628584e-34) tmp = Float64(z * -1.0); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.5035300976793776e+239) tmp = x * z; elseif (x <= -2.8368855981903414e-51) tmp = x * y; elseif (x <= 9.957315309628584e-34) tmp = z * -1.0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.5035300976793776e+239], N[(x * z), $MachinePrecision], If[LessEqual[x, -2.8368855981903414e-51], N[(x * y), $MachinePrecision], If[LessEqual[x, 9.957315309628584e-34], N[(z * -1.0), $MachinePrecision], N[(x * y), $MachinePrecision]]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET tmp_2 = IF (x <= (995731530962858429324473884117268777133337992305983115666935440622549596510538661930608296535272216942757950164377689361572265625e-162)) THEN (z * (-1)) ELSE (x * y) ENDIF IN LET tmp_1 = IF (x <= (-28368855981903414102920337465896913142028897505741484614367286972627935745057502704794255345263793652131194254318143559929623156480593682005064692930318415164947509765625e-220)) THEN (x * y) ELSE tmp_2 ENDIF IN LET tmp = IF (x <= (-150353009767937760884154711860257714387891541855886104115194725250238209157055610191370157512538108171292045452085945712819285768336718498601584906828263806694983474966458656621376604065417300474854092836554645825468703895493522125781729280)) THEN (x * z) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;x \leq -1.5035300976793776 \cdot 10^{+239}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;x \leq -2.8368855981903414 \cdot 10^{-51}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 9.957315309628584 \cdot 10^{-34}:\\
\;\;\;\;z \cdot -1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if x < -1.5035300976793776e239Initial program 97.9%
Taylor expanded in x around inf
Applied rewrites64.9%
Taylor expanded in y around 0
Applied rewrites27.9%
if -1.5035300976793776e239 < x < -2.8368855981903414e-51 or 9.9573153096285843e-34 < x Initial program 97.9%
Taylor expanded in x around inf
Applied rewrites64.9%
Taylor expanded in y around 0
Applied rewrites27.9%
Taylor expanded in undef-var around zero
Applied rewrites2.6%
Taylor expanded in y around inf
Applied rewrites41.3%
if -2.8368855981903414e-51 < x < 9.9573153096285843e-34Initial program 97.9%
Taylor expanded in y around 0
Applied rewrites62.4%
Taylor expanded in x around 0
Applied rewrites36.9%
(FPCore (x y z) :precision binary64 :pre TRUE (if (<= y -8.429824474477093e-68) (* x y) (if (<= y 3.07342713026798e-110) (* x z) (* x y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.429824474477093e-68) {
tmp = x * y;
} else if (y <= 3.07342713026798e-110) {
tmp = x * z;
} else {
tmp = x * y;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-8.429824474477093d-68)) then
tmp = x * y
else if (y <= 3.07342713026798d-110) then
tmp = x * z
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.429824474477093e-68) {
tmp = x * y;
} else if (y <= 3.07342713026798e-110) {
tmp = x * z;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.429824474477093e-68: tmp = x * y elif y <= 3.07342713026798e-110: tmp = x * z else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.429824474477093e-68) tmp = Float64(x * y); elseif (y <= 3.07342713026798e-110) tmp = Float64(x * z); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.429824474477093e-68) tmp = x * y; elseif (y <= 3.07342713026798e-110) tmp = x * z; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.429824474477093e-68], N[(x * y), $MachinePrecision], If[LessEqual[y, 3.07342713026798e-110], N[(x * z), $MachinePrecision], N[(x * y), $MachinePrecision]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET tmp_1 = IF (y <= (3073427130267980153005627182190657993395790266346178807683912839381824716108030662403918387306509888781507111484986848945374899460134021774697330315701930108353347326619958155595922805617888049569222363859348691391916452399978367507736953548628895889670962497363109096337741021898182225413620471954345703125e-416)) THEN (x * z) ELSE (x * y) ENDIF IN LET tmp = IF (y <= (-84298244744770933169202899367670995163693774118542341362793512875956795725840722784332340093490592411985259885516636098652107019404335476668413384352593432461903176326767361814518153551034629344940185546875e-273)) THEN (x * y) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;y \leq -8.429824474477093 \cdot 10^{-68}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 3.07342713026798 \cdot 10^{-110}:\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if y < -8.4298244744770933e-68 or 3.0734271302679802e-110 < y Initial program 97.9%
Taylor expanded in x around inf
Applied rewrites64.9%
Taylor expanded in y around 0
Applied rewrites27.9%
Taylor expanded in undef-var around zero
Applied rewrites2.6%
Taylor expanded in y around inf
Applied rewrites41.3%
if -8.4298244744770933e-68 < y < 3.0734271302679802e-110Initial program 97.9%
Taylor expanded in x around inf
Applied rewrites64.9%
Taylor expanded in y around 0
Applied rewrites27.9%
(FPCore (x y z) :precision binary64 :pre TRUE (* x y))
double code(double x, double y, double z) {
return x * y;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * y
end function
public static double code(double x, double y, double z) {
return x * y;
}
def code(x, y, z): return x * y
function code(x, y, z) return Float64(x * y) end
function tmp = code(x, y, z) tmp = x * y; end
code[x_, y_, z_] := N[(x * y), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = x * y END code
x \cdot y
Initial program 97.9%
Taylor expanded in x around inf
Applied rewrites64.9%
Taylor expanded in y around 0
Applied rewrites27.9%
Taylor expanded in undef-var around zero
Applied rewrites2.6%
Taylor expanded in y around inf
Applied rewrites41.3%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Drawing:drawTextsR from Chart-1.5.3"
:precision binary64
(+ (* x y) (* (- x 1.0) z)))