
(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}
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 1.8e+143)
(+ x (* y (* z (- t_1 (tanh (/ x y))))))
(+ x (* z (- (* y t_1) x))))))y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 1.8e+143) {
tmp = x + (y * (z * (t_1 - tanh((x / y)))));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 1.8d+143) then
tmp = x + (y * (z * (t_1 - tanh((x / y)))))
else
tmp = x + (z * ((y * t_1) - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 1.8e+143) {
tmp = x + (y * (z * (t_1 - Math.tanh((x / y)))));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 1.8e+143: tmp = x + (y * (z * (t_1 - math.tanh((x / y))))) else: tmp = x + (z * ((y * t_1) - x)) return tmp
y = abs(y) function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 1.8e+143) tmp = Float64(x + Float64(y * Float64(z * Float64(t_1 - tanh(Float64(x / y)))))); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 1.8e+143) tmp = x + (y * (z * (t_1 - tanh((x / y))))); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 1.8e+143], N[(x + N[(y * N[(z * N[(t$95$1 - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 1.8 \cdot 10^{+143}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(t_1 - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 1.8e143Initial program 98.7%
associate-*l*98.3%
Simplified98.3%
if 1.8e143 < y Initial program 72.7%
associate-*l*89.9%
Simplified89.9%
Taylor expanded in x around 0 83.3%
Taylor expanded in y around 0 57.7%
+-commutative57.7%
mul-1-neg57.7%
*-commutative57.7%
distribute-lft-neg-in57.7%
mul-1-neg57.7%
associate-*r*57.7%
distribute-rgt-out57.7%
mul-1-neg57.7%
Simplified92.6%
Final simplification97.7%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
y = abs(y);
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
y = abs(y) function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 95.8%
+-commutative95.8%
*-commutative95.8%
associate-*l*98.9%
fma-def98.9%
Simplified98.9%
Final simplification98.9%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 8.8e+95) (+ x (* t_1 (* z y))) (+ x (* z (- (* y t_1) x))))))
y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 8.8e+95) {
tmp = x + (t_1 * (z * y));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 8.8d+95) then
tmp = x + (t_1 * (z * y))
else
tmp = x + (z * ((y * t_1) - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 8.8e+95) {
tmp = x + (t_1 * (z * y));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 8.8e+95: tmp = x + (t_1 * (z * y)) else: tmp = x + (z * ((y * t_1) - x)) return tmp
y = abs(y) function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 8.8e+95) tmp = Float64(x + Float64(t_1 * Float64(z * y))); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 8.8e+95) tmp = x + (t_1 * (z * y)); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 8.8e+95], N[(x + N[(t$95$1 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 8.8 \cdot 10^{+95}:\\
\;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 8.7999999999999996e95Initial program 98.7%
associate-*l*98.2%
Simplified98.2%
Taylor expanded in x around 0 24.3%
*-commutative24.3%
associate-*r*24.2%
associate-/r*24.2%
rec-exp24.2%
div-sub24.2%
rec-exp24.2%
Simplified89.4%
if 8.7999999999999996e95 < y Initial program 76.8%
associate-*l*91.4%
Simplified91.4%
Taylor expanded in x around 0 85.8%
Taylor expanded in y around 0 58.1%
+-commutative58.1%
mul-1-neg58.1%
*-commutative58.1%
distribute-lft-neg-in58.1%
mul-1-neg58.1%
associate-*r*58.1%
distribute-rgt-out58.1%
mul-1-neg58.1%
Simplified93.8%
Final simplification90.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 8.1e+99) (+ x (* (tanh (/ t y)) (* z y))) (fma (- t x) z x)))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.1e+99) {
tmp = x + (tanh((t / y)) * (z * y));
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 8.1e+99) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); else tmp = fma(Float64(t - x), z, x); end return tmp end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 8.1e+99], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.1 \cdot 10^{+99}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\end{array}
\end{array}
if y < 8.10000000000000015e99Initial program 98.7%
associate-*l*98.2%
Simplified98.2%
Taylor expanded in x around 0 24.3%
*-commutative24.3%
associate-*r*24.2%
associate-/r*24.2%
rec-exp24.2%
div-sub24.2%
rec-exp24.2%
Simplified89.4%
if 8.10000000000000015e99 < y Initial program 76.8%
+-commutative76.8%
*-commutative76.8%
associate-*l*91.4%
fma-def91.4%
Simplified91.4%
Taylor expanded in y around inf 88.5%
fma-def88.5%
Simplified88.5%
Final simplification89.3%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.1e-17) x (fma (- t x) z x)))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.1e-17) {
tmp = x;
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.1e-17) tmp = x; else tmp = fma(Float64(t - x), z, x); end return tmp end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1.1e-17], x, N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{-17}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\end{array}
\end{array}
if y < 1.1e-17Initial program 99.0%
+-commutative99.0%
*-commutative99.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 69.9%
if 1.1e-17 < y Initial program 84.7%
+-commutative84.7%
*-commutative84.7%
associate-*l*95.0%
fma-def95.0%
Simplified95.0%
Taylor expanded in y around inf 71.3%
fma-def71.3%
Simplified71.3%
Final simplification70.2%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 2.15e-17) x (+ (* x (- 1.0 z)) (* z t))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.15e-17) {
tmp = x;
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 2.15d-17) then
tmp = x
else
tmp = (x * (1.0d0 - z)) + (z * t)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.15e-17) {
tmp = x;
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 2.15e-17: tmp = x else: tmp = (x * (1.0 - z)) + (z * t) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 2.15e-17) tmp = x; else tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(z * t)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.15e-17) tmp = x; else tmp = (x * (1.0 - z)) + (z * t); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 2.15e-17], x, N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.15 \cdot 10^{-17}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if y < 2.15000000000000012e-17Initial program 99.0%
+-commutative99.0%
*-commutative99.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 69.9%
if 2.15000000000000012e-17 < y Initial program 84.7%
associate-*l*94.9%
Simplified94.9%
Taylor expanded in y around inf 69.7%
associate-/l*69.6%
Simplified69.6%
associate-/r/66.3%
Applied egg-rr66.3%
Taylor expanded in x around 0 71.3%
Final simplification70.2%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.5e-17) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.5e-17) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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.5d-17) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.5e-17) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.5e-17: tmp = x else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.5e-17) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.5e-17) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1.5e-17], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{-17}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.50000000000000003e-17Initial program 99.0%
+-commutative99.0%
*-commutative99.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 69.9%
if 1.50000000000000003e-17 < y Initial program 84.7%
+-commutative84.7%
*-commutative84.7%
associate-*l*95.0%
fma-def95.0%
Simplified95.0%
Taylor expanded in y around inf 71.3%
Final simplification70.2%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1e+98) x (* x (- 1.0 z))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1e+98) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 1d+98) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1e+98) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1e+98: tmp = x else: tmp = x * (1.0 - z) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1e+98) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1e+98) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1e+98], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+98}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 9.99999999999999998e97Initial program 98.7%
+-commutative98.7%
*-commutative98.7%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 67.7%
if 9.99999999999999998e97 < y Initial program 76.8%
associate-*l*91.4%
Simplified91.4%
Taylor expanded in x around 0 85.8%
Taylor expanded in x around inf 61.4%
*-commutative61.4%
+-commutative61.4%
mul-1-neg61.4%
unsub-neg61.4%
Simplified61.4%
Final simplification66.9%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 0.00048) x (+ x (* z t))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 0.00048) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 0.00048d0) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 0.00048) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 0.00048: tmp = x else: tmp = x + (z * t) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 0.00048) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 0.00048) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 0.00048], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.00048:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 4.80000000000000012e-4Initial program 99.0%
+-commutative99.0%
*-commutative99.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 70.3%
if 4.80000000000000012e-4 < y Initial program 83.8%
associate-*l*94.6%
Simplified94.6%
Taylor expanded in x around 0 33.4%
*-commutative33.4%
associate-*r*32.6%
associate-/r*32.6%
rec-exp32.6%
div-sub32.6%
rec-exp32.6%
Simplified74.2%
Taylor expanded in y around inf 61.9%
Final simplification68.6%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= z -5.2e+149) (* z t) x))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.2e+149) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
NOTE: y should be positive before calling this function
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 (z <= (-5.2d+149)) then
tmp = z * t
else
tmp = x
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.2e+149) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if z <= -5.2e+149: tmp = z * t else: tmp = x return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (z <= -5.2e+149) tmp = Float64(z * t); else tmp = x; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5.2e+149) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[z, -5.2e+149], N[(z * t), $MachinePrecision], x]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+149}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -5.19999999999999957e149Initial program 84.5%
associate-*l*93.6%
Simplified93.6%
Taylor expanded in x around 0 5.0%
*-commutative5.0%
associate-*r*3.9%
associate-/r*3.9%
rec-exp3.9%
div-sub3.9%
rec-exp3.9%
Simplified64.1%
Taylor expanded in y around inf 39.0%
Taylor expanded in t around inf 35.5%
*-commutative35.5%
Simplified35.5%
if -5.19999999999999957e149 < z Initial program 97.4%
+-commutative97.4%
*-commutative97.4%
associate-*l*99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in z around 0 70.6%
Final simplification66.3%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 x)
y = abs(y);
double code(double x, double y, double z, double t) {
return x;
}
NOTE: y should be positive before calling this function
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
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
return x;
}
y = abs(y) def code(x, y, z, t): return x
y = abs(y) function code(x, y, z, t) return x end
y = abs(y) function tmp = code(x, y, z, t) tmp = x; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := x
\begin{array}{l}
y = |y|\\
\\
x
\end{array}
Initial program 95.8%
+-commutative95.8%
*-commutative95.8%
associate-*l*98.9%
fma-def98.9%
Simplified98.9%
Taylor expanded in z around 0 64.0%
Final simplification64.0%
(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 2023257
(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))))))