
(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 9 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 7.6e+64)
(+ x (* (- t_1 (tanh (/ x y))) (* y z)))
(+ 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 <= 7.6e+64) {
tmp = x + ((t_1 - tanh((x / y))) * (y * z));
} 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 <= 7.6d+64) then
tmp = x + ((t_1 - tanh((x / y))) * (y * z))
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 <= 7.6e+64) {
tmp = x + ((t_1 - Math.tanh((x / y))) * (y * z));
} 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 <= 7.6e+64: tmp = x + ((t_1 - math.tanh((x / y))) * (y * z)) 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 <= 7.6e+64) tmp = Float64(x + Float64(Float64(t_1 - tanh(Float64(x / y))) * Float64(y * z))); 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 <= 7.6e+64) tmp = x + ((t_1 - tanh((x / y))) * (y * z)); 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, 7.6e+64], N[(x + N[(N[(t$95$1 - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y * z), $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 7.6 \cdot 10^{+64}:\\
\;\;\;\;x + \left(t_1 - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 7.6000000000000002e64Initial program 95.8%
if 7.6000000000000002e64 < y Initial program 76.4%
Taylor expanded in x around 0 46.8%
+-commutative46.8%
Simplified95.1%
Taylor expanded in z around 0 46.8%
sub-neg46.8%
distribute-lft-in46.8%
associate-*r/46.8%
rec-exp46.8%
rec-exp46.8%
tanh-def-a93.2%
Simplified95.1%
Final simplification95.6%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (fma (* y (- (tanh (/ t y)) (tanh (/ x y)))) z x))
y = abs(y);
double code(double x, double y, double z, double t) {
return fma((y * (tanh((t / y)) - tanh((x / y)))), z, x);
}
y = abs(y) function code(x, y, z, t) return fma(Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), z, x) end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right)
\end{array}
Initial program 91.9%
+-commutative91.9%
*-commutative91.9%
associate-*r*98.2%
fma-def98.2%
Applied egg-rr98.2%
Final simplification98.2%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (tanh (/ t y))))) (if (<= y 1.92e+65) (fma t_1 z x) (+ x (* z (- t_1 x))))))
y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = y * tanh((t / y));
double tmp;
if (y <= 1.92e+65) {
tmp = fma(t_1, z, x);
} else {
tmp = x + (z * (t_1 - x));
}
return tmp;
}
y = abs(y) function code(x, y, z, t) t_1 = Float64(y * tanh(Float64(t / y))) tmp = 0.0 if (y <= 1.92e+65) tmp = fma(t_1, z, x); else tmp = Float64(x + Float64(z * Float64(t_1 - x))); end return tmp end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.92e+65], N[(t$95$1 * z + x), $MachinePrecision], N[(x + N[(z * N[(t$95$1 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := y \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 1.92 \cdot 10^{+65}:\\
\;\;\;\;\mathsf{fma}\left(t_1, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t_1 - x\right)\\
\end{array}
\end{array}
if y < 1.91999999999999999e65Initial program 95.8%
+-commutative95.8%
*-commutative95.8%
associate-*r*99.5%
fma-def99.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 29.0%
associate-/r*29.0%
div-sub29.0%
rec-exp29.0%
rec-exp29.0%
tanh-def-a81.0%
Simplified81.0%
if 1.91999999999999999e65 < y Initial program 76.4%
Taylor expanded in x around 0 46.8%
+-commutative46.8%
Simplified95.1%
Taylor expanded in z around 0 46.8%
sub-neg46.8%
distribute-lft-in46.8%
associate-*r/46.8%
rec-exp46.8%
rec-exp46.8%
tanh-def-a93.2%
Simplified95.1%
Final simplification83.8%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 2.32e+64) (+ x (* t_1 (* y z))) (+ 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 <= 2.32e+64) {
tmp = x + (t_1 * (y * z));
} 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 <= 2.32d+64) then
tmp = x + (t_1 * (y * z))
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 <= 2.32e+64) {
tmp = x + (t_1 * (y * z));
} 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 <= 2.32e+64: tmp = x + (t_1 * (y * z)) 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 <= 2.32e+64) tmp = Float64(x + Float64(t_1 * Float64(y * z))); 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 <= 2.32e+64) tmp = x + (t_1 * (y * z)); 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, 2.32e+64], N[(x + N[(t$95$1 * N[(y * z), $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 2.32 \cdot 10^{+64}:\\
\;\;\;\;x + t_1 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 2.3199999999999999e64Initial program 95.8%
Taylor expanded in x around 0 29.0%
associate-*r*28.8%
associate-/r*28.8%
div-sub28.8%
rec-exp28.8%
rec-exp28.8%
tanh-def-a78.8%
Simplified78.8%
if 2.3199999999999999e64 < y Initial program 76.4%
Taylor expanded in x around 0 46.8%
+-commutative46.8%
Simplified95.1%
Taylor expanded in z around 0 46.8%
sub-neg46.8%
distribute-lft-in46.8%
associate-*r/46.8%
rec-exp46.8%
rec-exp46.8%
tanh-def-a93.2%
Simplified95.1%
Final simplification82.1%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 4.15e+65) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.15e+65) {
tmp = x + (tanh((t / y)) * (y * z));
} 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 <= 4.15d+65) then
tmp = x + (tanh((t / y)) * (y * z))
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 <= 4.15e+65) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 4.15e+65: tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 4.15e+65) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); 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 <= 4.15e+65) tmp = x + (tanh((t / y)) * (y * z)); 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, 4.15e+65], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.15 \cdot 10^{+65}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.1500000000000002e65Initial program 95.8%
Taylor expanded in x around 0 29.0%
associate-*r*28.8%
associate-/r*28.8%
div-sub28.8%
rec-exp28.8%
rec-exp28.8%
tanh-def-a78.8%
Simplified78.8%
if 4.1500000000000002e65 < y Initial program 76.4%
Taylor expanded in y around inf 88.1%
Final simplification80.7%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 4.3e-43) x (if (or (<= y 6.2e+86) (not (<= y 3.4e+129))) (+ x (* t z)) (- x (* x z)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.3e-43) {
tmp = x;
} else if ((y <= 6.2e+86) || !(y <= 3.4e+129)) {
tmp = x + (t * z);
} else {
tmp = x - (x * 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 <= 4.3d-43) then
tmp = x
else if ((y <= 6.2d+86) .or. (.not. (y <= 3.4d+129))) then
tmp = x + (t * z)
else
tmp = x - (x * 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 <= 4.3e-43) {
tmp = x;
} else if ((y <= 6.2e+86) || !(y <= 3.4e+129)) {
tmp = x + (t * z);
} else {
tmp = x - (x * z);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 4.3e-43: tmp = x elif (y <= 6.2e+86) or not (y <= 3.4e+129): tmp = x + (t * z) else: tmp = x - (x * z) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 4.3e-43) tmp = x; elseif ((y <= 6.2e+86) || !(y <= 3.4e+129)) tmp = Float64(x + Float64(t * z)); else tmp = Float64(x - Float64(x * z)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.3e-43) tmp = x; elseif ((y <= 6.2e+86) || ~((y <= 3.4e+129))) tmp = x + (t * z); else tmp = x - (x * z); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 4.3e-43], x, If[Or[LessEqual[y, 6.2e+86], N[Not[LessEqual[y, 3.4e+129]], $MachinePrecision]], N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{-43}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+86} \lor \neg \left(y \leq 3.4 \cdot 10^{+129}\right):\\
\;\;\;\;x + t \cdot z\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < 4.29999999999999964e-43Initial program 95.3%
Taylor expanded in x around inf 65.5%
if 4.29999999999999964e-43 < y < 6.2000000000000004e86 or 3.40000000000000018e129 < y Initial program 83.1%
Taylor expanded in y around inf 81.2%
Taylor expanded in t around inf 70.9%
if 6.2000000000000004e86 < y < 3.40000000000000018e129Initial program 82.5%
Taylor expanded in x around 0 49.9%
+-commutative49.9%
Simplified94.0%
Taylor expanded in x around inf 62.3%
neg-mul-162.3%
distribute-rgt-in62.3%
distribute-lft-neg-out62.3%
unsub-neg62.3%
*-lft-identity62.3%
Simplified62.3%
Final simplification66.7%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.1e-42) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.1e-42) {
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.1d-42) 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.1e-42) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.1e-42: 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.1e-42) 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.1e-42) 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.1e-42], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{-42}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.10000000000000003e-42Initial program 95.3%
Taylor expanded in x around inf 65.5%
if 1.10000000000000003e-42 < y Initial program 83.0%
Taylor expanded in y around inf 80.9%
Final simplification69.8%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 2.1e-43) x (+ x (* t z))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.1e-43) {
tmp = x;
} else {
tmp = x + (t * 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 <= 2.1d-43) then
tmp = x
else
tmp = x + (t * 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 <= 2.1e-43) {
tmp = x;
} else {
tmp = x + (t * z);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 2.1e-43: tmp = x else: tmp = x + (t * z) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 2.1e-43) tmp = x; else tmp = Float64(x + Float64(t * z)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.1e-43) tmp = x; else tmp = x + (t * z); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 2.1e-43], x, N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{-43}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + t \cdot z\\
\end{array}
\end{array}
if y < 2.1000000000000001e-43Initial program 95.3%
Taylor expanded in x around inf 65.5%
if 2.1000000000000001e-43 < y Initial program 83.0%
Taylor expanded in y around inf 80.9%
Taylor expanded in t around inf 65.2%
Final simplification65.5%
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 91.9%
Taylor expanded in x around inf 58.1%
Final simplification58.1%
(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 2023279
(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))))))