
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (tanh (/ t y)) (tanh (/ x y)))))
(if (<= (+ x (* (* y z) t_1)) 1e+287)
(fma z (* y t_1) x)
(+ x (* z (- t x))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y)) - tanh((x / y));
double tmp;
if ((x + ((y * z) * t_1)) <= 1e+287) {
tmp = fma(z, (y * t_1), x);
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) tmp = 0.0 if (Float64(x + Float64(Float64(y * z) * t_1)) <= 1e+287) tmp = fma(z, Float64(y * t_1), x); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + N[(N[(y * z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 1e+287], N[(z * N[(y * t$95$1), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\
\mathbf{if}\;x + \left(y \cdot z\right) \cdot t_1 \leq 10^{+287}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot t_1, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 1.0000000000000001e287Initial program 97.1%
+-commutative97.1%
*-commutative97.1%
associate-*l*99.1%
fma-def99.2%
Simplified99.2%
if 1.0000000000000001e287 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 49.1%
Taylor expanded in y around inf 96.1%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (if (<= y 7.6e+186) (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))) (- (* z t) (* x (+ z -1.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.6e+186) {
tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
} else {
tmp = (z * t) - (x * (z + -1.0));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 7.6d+186) then
tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
else
tmp = (z * t) - (x * (z + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.6e+186) {
tmp = x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
} else {
tmp = (z * t) - (x * (z + -1.0));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 7.6e+186: tmp = x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y)))) else: tmp = (z * t) - (x * (z + -1.0)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 7.6e+186) tmp = Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))); else tmp = Float64(Float64(z * t) - Float64(x * Float64(z + -1.0))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 7.6e+186) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); else tmp = (z * t) - (x * (z + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 7.6e+186], N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * t), $MachinePrecision] - N[(x * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.6 \cdot 10^{+186}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot t - x \cdot \left(z + -1\right)\\
\end{array}
\end{array}
if y < 7.5999999999999996e186Initial program 94.9%
if 7.5999999999999996e186 < y Initial program 69.3%
Taylor expanded in y around inf 99.9%
Taylor expanded in x around -inf 99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification95.4%
(FPCore (x y z t) :precision binary64 (if (<= y 2.8e+75) (fma z (* y (tanh (/ t y))) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.8e+75) {
tmp = fma(z, (y * tanh((t / y))), x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 2.8e+75) tmp = fma(z, Float64(y * tanh(Float64(t / y))), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.8e+75], N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot \tanh \left(\frac{t}{y}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 2.80000000000000012e75Initial program 94.8%
+-commutative94.8%
*-commutative94.8%
associate-*l*97.2%
fma-def97.2%
Simplified97.2%
Taylor expanded in x around 0 25.9%
associate-/r*25.7%
rec-exp25.7%
div-sub25.7%
rec-exp25.7%
tanh-def-a80.0%
Simplified79.2%
if 2.80000000000000012e75 < y Initial program 82.3%
Taylor expanded in y around inf 94.4%
+-commutative94.4%
fma-def94.5%
Simplified94.5%
Final simplification82.1%
(FPCore (x y z t) :precision binary64 (if (<= y 6.2e+73) (+ x (* (* y z) (tanh (/ t y)))) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.2e+73) {
tmp = x + ((y * z) * tanh((t / y)));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 6.2e+73) tmp = Float64(x + Float64(Float64(y * z) * tanh(Float64(t / y)))); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.2e+73], N[(x + N[(N[(y * z), $MachinePrecision] * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{+73}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 6.1999999999999999e73Initial program 94.8%
Taylor expanded in x around 0 25.7%
associate-/r*25.7%
rec-exp25.7%
div-sub25.7%
rec-exp25.7%
tanh-def-a80.0%
Simplified80.0%
if 6.1999999999999999e73 < y Initial program 82.3%
Taylor expanded in y around inf 94.4%
+-commutative94.4%
fma-def94.5%
Simplified94.5%
Final simplification82.7%
(FPCore (x y z t) :precision binary64 (if (<= y 1.8e+37) x (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e+37) {
tmp = x;
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.8e+37) tmp = x; else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.8e+37], x, N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.79999999999999999e37Initial program 94.6%
Taylor expanded in x around inf 68.2%
if 1.79999999999999999e37 < y Initial program 85.1%
Taylor expanded in y around inf 88.8%
+-commutative88.8%
fma-def88.9%
Simplified88.9%
Final simplification72.9%
(FPCore (x y z t) :precision binary64 (if (<= y 1.22e+38) x (if (<= y 2.6e+223) (* x (- 1.0 z)) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.22e+38) {
tmp = x;
} else if (y <= 2.6e+223) {
tmp = x * (1.0 - z);
} else {
tmp = z * (t - x);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 1.22d+38) then
tmp = x
else if (y <= 2.6d+223) then
tmp = x * (1.0d0 - z)
else
tmp = z * (t - x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.22e+38) {
tmp = x;
} else if (y <= 2.6e+223) {
tmp = x * (1.0 - z);
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.22e+38: tmp = x elif y <= 2.6e+223: tmp = x * (1.0 - z) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.22e+38) tmp = x; elseif (y <= 2.6e+223) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.22e+38) tmp = x; elseif (y <= 2.6e+223) tmp = x * (1.0 - z); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.22e+38], x, If[LessEqual[y, 2.6e+223], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.22 \cdot 10^{+38}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+223}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.22e38Initial program 94.6%
Taylor expanded in x around inf 67.9%
if 1.22e38 < y < 2.6000000000000002e223Initial program 95.4%
Taylor expanded in y around inf 84.6%
Taylor expanded in x around inf 64.5%
mul-1-neg64.5%
unsub-neg64.5%
Simplified64.5%
if 2.6000000000000002e223 < y Initial program 55.1%
Taylor expanded in y around inf 99.8%
Taylor expanded in z around inf 82.1%
Final simplification68.1%
(FPCore (x y z t) :precision binary64 (if (<= y 3.65e+37) x (if (<= y 1.2e+239) (* x (- 1.0 z)) (+ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.65e+37) {
tmp = x;
} else if (y <= 1.2e+239) {
tmp = x * (1.0 - z);
} else {
tmp = x + (z * t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 3.65d+37) then
tmp = x
else if (y <= 1.2d+239) then
tmp = x * (1.0d0 - z)
else
tmp = x + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.65e+37) {
tmp = x;
} else if (y <= 1.2e+239) {
tmp = x * (1.0 - z);
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.65e+37: tmp = x elif y <= 1.2e+239: tmp = x * (1.0 - z) else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.65e+37) tmp = x; elseif (y <= 1.2e+239) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.65e+37) tmp = x; elseif (y <= 1.2e+239) tmp = x * (1.0 - z); else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.65e+37], x, If[LessEqual[y, 1.2e+239], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.65 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+239}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 3.65000000000000019e37Initial program 94.6%
Taylor expanded in x around inf 67.9%
if 3.65000000000000019e37 < y < 1.2e239Initial program 95.4%
Taylor expanded in y around inf 84.6%
Taylor expanded in x around inf 64.5%
mul-1-neg64.5%
unsub-neg64.5%
Simplified64.5%
if 1.2e239 < y Initial program 55.1%
Taylor expanded in x around 0 23.7%
associate-/r*23.7%
rec-exp23.7%
div-sub23.7%
rec-exp23.7%
tanh-def-a53.9%
Simplified53.9%
Taylor expanded in y around inf 71.6%
+-commutative71.6%
*-commutative71.6%
Simplified71.6%
Final simplification67.5%
(FPCore (x y z t) :precision binary64 (if (<= y 1.8e+37) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e+37) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 1.8d+37) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e+37) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.8e+37: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.8e+37) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.8e+37) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.8e+37], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.79999999999999999e37Initial program 94.6%
Taylor expanded in x around inf 68.2%
if 1.79999999999999999e37 < y Initial program 85.1%
Taylor expanded in y around inf 88.8%
Final simplification72.9%
(FPCore (x y z t) :precision binary64 (if (<= y 4.2e+37) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.2e+37) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 4.2d+37) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.2e+37) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.2e+37: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.2e+37) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.2e+37) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.2e+37], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.2 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 4.2000000000000002e37Initial program 94.6%
Taylor expanded in x around inf 67.9%
if 4.2000000000000002e37 < y Initial program 84.8%
Taylor expanded in y around inf 88.6%
Taylor expanded in x around inf 60.4%
mul-1-neg60.4%
unsub-neg60.4%
Simplified60.4%
Final simplification66.2%
(FPCore (x y z t) :precision binary64 (if (<= y 1.82e+239) x (* z t)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.82e+239) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 1.82d+239) then
tmp = x
else
tmp = z * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.82e+239) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.82e+239: tmp = x else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.82e+239) tmp = x; else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.82e+239) tmp = x; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.82e+239], x, N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.82 \cdot 10^{+239}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 1.82000000000000008e239Initial program 94.7%
Taylor expanded in x around inf 64.2%
if 1.82000000000000008e239 < y Initial program 55.1%
Taylor expanded in y around inf 99.8%
Taylor expanded in x around -inf 99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in t around inf 53.5%
*-commutative53.5%
Simplified53.5%
Final simplification63.6%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 92.4%
Taylor expanded in x around inf 61.4%
Final simplification61.4%
(FPCore (x y z t) :precision binary64 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
herbie shell --seed 2023318
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:herbie-target
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))