
(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 (+ x (* y (- (* z (tanh (/ t y))) (* z (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * ((z * tanh((t / y))) - (z * 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))) - (z * 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))) - (z * Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * ((z * math.tanh((t / y))) - (z * math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(Float64(z * tanh(Float64(t / y))) - Float64(z * tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * ((z * tanh((t / y))) - (z * tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right) - z \cdot \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Initial program 92.1%
sub-neg92.1%
distribute-lft-in86.8%
Applied egg-rr86.8%
distribute-rgt-neg-out86.8%
distribute-lft-neg-in86.8%
add-sqr-sqrt40.0%
sqrt-unprod75.2%
sqr-neg75.2%
sqrt-unprod42.0%
add-sqr-sqrt70.4%
cancel-sign-sub-inv70.4%
associate-*l*70.4%
associate-*l*74.7%
distribute-lft-out--74.7%
add-sqr-sqrt45.2%
sqrt-unprod82.5%
Applied egg-rr97.0%
Final simplification97.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}
Initial program 92.1%
sub-neg92.1%
distribute-lft-in86.8%
Applied egg-rr86.8%
distribute-lft-out92.1%
sub-neg92.1%
associate-*l*97.0%
Simplified97.0%
Final simplification97.0%
(FPCore (x y z t) :precision binary64 (if (or (<= y 1.8e+59) (and (not (<= y 1.35e+100)) (<= y 9e+134))) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 1.8e+59) || (!(y <= 1.35e+100) && (y <= 9e+134))) {
tmp = x + (y * (z * tanh((t / y))));
} 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+59) .or. (.not. (y <= 1.35d+100)) .and. (y <= 9d+134)) then
tmp = x + (y * (z * tanh((t / y))))
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+59) || (!(y <= 1.35e+100) && (y <= 9e+134))) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= 1.8e+59) or (not (y <= 1.35e+100) and (y <= 9e+134)): tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= 1.8e+59) || (!(y <= 1.35e+100) && (y <= 9e+134))) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); 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+59) || (~((y <= 1.35e+100)) && (y <= 9e+134))) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, 1.8e+59], And[N[Not[LessEqual[y, 1.35e+100]], $MachinePrecision], LessEqual[y, 9e+134]]], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+59} \lor \neg \left(y \leq 1.35 \cdot 10^{+100}\right) \land y \leq 9 \cdot 10^{+134}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.7999999999999999e59 or 1.34999999999999999e100 < y < 8.9999999999999995e134Initial program 94.2%
Taylor expanded in x around 0 24.8%
associate-/r*24.8%
rec-exp24.8%
div-sub24.8%
rec-exp24.8%
tanh-def-a80.1%
Simplified80.1%
if 1.7999999999999999e59 < y < 1.34999999999999999e100 or 8.9999999999999995e134 < y Initial program 84.3%
Taylor expanded in y around inf 89.3%
Final simplification82.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 1.45e+59)
(+ x (* y (* z t_1)))
(if (or (<= y 3.6e+100) (not (<= y 1.7e+131)))
(+ x (* z (- t x)))
(+ x (* t_1 (* y z)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 1.45e+59) {
tmp = x + (y * (z * t_1));
} else if ((y <= 3.6e+100) || !(y <= 1.7e+131)) {
tmp = x + (z * (t - x));
} else {
tmp = x + (t_1 * (y * 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) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 1.45d+59) then
tmp = x + (y * (z * t_1))
else if ((y <= 3.6d+100) .or. (.not. (y <= 1.7d+131))) then
tmp = x + (z * (t - x))
else
tmp = x + (t_1 * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 1.45e+59) {
tmp = x + (y * (z * t_1));
} else if ((y <= 3.6e+100) || !(y <= 1.7e+131)) {
tmp = x + (z * (t - x));
} else {
tmp = x + (t_1 * (y * z));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 1.45e+59: tmp = x + (y * (z * t_1)) elif (y <= 3.6e+100) or not (y <= 1.7e+131): tmp = x + (z * (t - x)) else: tmp = x + (t_1 * (y * z)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 1.45e+59) tmp = Float64(x + Float64(y * Float64(z * t_1))); elseif ((y <= 3.6e+100) || !(y <= 1.7e+131)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = Float64(x + Float64(t_1 * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 1.45e+59) tmp = x + (y * (z * t_1)); elseif ((y <= 3.6e+100) || ~((y <= 1.7e+131))) tmp = x + (z * (t - x)); else tmp = x + (t_1 * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 1.45e+59], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 3.6e+100], N[Not[LessEqual[y, 1.7e+131]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 1.45 \cdot 10^{+59}:\\
\;\;\;\;x + y \cdot \left(z \cdot t\_1\right)\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+100} \lor \neg \left(y \leq 1.7 \cdot 10^{+131}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\_1 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if y < 1.44999999999999995e59Initial program 94.5%
Taylor expanded in x around 0 24.6%
associate-/r*24.6%
rec-exp24.6%
div-sub24.6%
rec-exp24.6%
tanh-def-a80.2%
Simplified80.2%
if 1.44999999999999995e59 < y < 3.6e100 or 1.69999999999999993e131 < y Initial program 84.3%
Taylor expanded in y around inf 89.3%
if 3.6e100 < y < 1.69999999999999993e131Initial program 88.6%
Taylor expanded in x around 0 27.3%
associate-/r*27.3%
rec-exp27.3%
div-sub27.3%
rec-exp27.3%
tanh-def-a78.3%
Simplified78.3%
Final simplification82.0%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.1e-7) (not (<= x 0.000135))) (- x (* y (* z (tanh (/ x y))))) (+ x (* (* y z) (- (tanh (/ t y)) (/ x y))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.1e-7) || !(x <= 0.000135)) {
tmp = x - (y * (z * tanh((x / y))));
} else {
tmp = x + ((y * z) * (tanh((t / y)) - (x / y)));
}
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 ((x <= (-2.1d-7)) .or. (.not. (x <= 0.000135d0))) then
tmp = x - (y * (z * tanh((x / y))))
else
tmp = x + ((y * z) * (tanh((t / y)) - (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.1e-7) || !(x <= 0.000135)) {
tmp = x - (y * (z * Math.tanh((x / y))));
} else {
tmp = x + ((y * z) * (Math.tanh((t / y)) - (x / y)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -2.1e-7) or not (x <= 0.000135): tmp = x - (y * (z * math.tanh((x / y)))) else: tmp = x + ((y * z) * (math.tanh((t / y)) - (x / y))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.1e-7) || !(x <= 0.000135)) tmp = Float64(x - Float64(y * Float64(z * tanh(Float64(x / y))))); else tmp = Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -2.1e-7) || ~((x <= 0.000135))) tmp = x - (y * (z * tanh((x / y)))); else tmp = x + ((y * z) * (tanh((t / y)) - (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.1e-7], N[Not[LessEqual[x, 0.000135]], $MachinePrecision]], N[(x - N[(y * N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-7} \lor \neg \left(x \leq 0.000135\right):\\
\;\;\;\;x - y \cdot \left(z \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\\
\end{array}
\end{array}
if x < -2.1e-7 or 1.35000000000000002e-4 < x Initial program 92.6%
sub-neg92.6%
distribute-lft-in86.9%
Applied egg-rr86.9%
distribute-rgt-neg-out86.9%
distribute-lft-neg-in86.9%
add-sqr-sqrt39.2%
sqrt-unprod76.4%
sqr-neg76.4%
sqrt-unprod37.9%
add-sqr-sqrt69.8%
cancel-sign-sub-inv69.8%
associate-*l*69.8%
associate-*l*70.6%
distribute-lft-out--70.6%
add-sqr-sqrt37.9%
sqrt-unprod81.3%
Applied egg-rr99.9%
Taylor expanded in t around 0 12.6%
mul-1-neg12.6%
associate-/l*12.6%
associate-/l*12.6%
rec-exp12.6%
rec-exp12.6%
tanh-def-a89.7%
distribute-rgt-neg-in89.7%
Simplified89.7%
if -2.1e-7 < x < 1.35000000000000002e-4Initial program 91.6%
Taylor expanded in x around 0 80.3%
Final simplification85.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.25e-10) (not (<= t 1.45e-48))) (+ x (* y (* z (tanh (/ t y))))) (+ x (- (* z t) (* y (* z (tanh (/ x y))))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.25e-10) || !(t <= 1.45e-48)) {
tmp = x + (y * (z * tanh((t / y))));
} else {
tmp = x + ((z * t) - (y * (z * tanh((x / y)))));
}
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 ((t <= (-1.25d-10)) .or. (.not. (t <= 1.45d-48))) then
tmp = x + (y * (z * tanh((t / y))))
else
tmp = x + ((z * t) - (y * (z * tanh((x / y)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.25e-10) || !(t <= 1.45e-48)) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + ((z * t) - (y * (z * Math.tanh((x / y)))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.25e-10) or not (t <= 1.45e-48): tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + ((z * t) - (y * (z * math.tanh((x / y))))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.25e-10) || !(t <= 1.45e-48)) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); else tmp = Float64(x + Float64(Float64(z * t) - Float64(y * Float64(z * tanh(Float64(x / y)))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.25e-10) || ~((t <= 1.45e-48))) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + ((z * t) - (y * (z * tanh((x / y))))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.25e-10], N[Not[LessEqual[t, 1.45e-48]], $MachinePrecision]], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(z * t), $MachinePrecision] - N[(y * N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.25 \cdot 10^{-10} \lor \neg \left(t \leq 1.45 \cdot 10^{-48}\right):\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(z \cdot t - y \cdot \left(z \cdot \tanh \left(\frac{x}{y}\right)\right)\right)\\
\end{array}
\end{array}
if t < -1.25000000000000008e-10 or 1.4500000000000001e-48 < t Initial program 94.4%
Taylor expanded in x around 0 11.0%
associate-/r*11.0%
rec-exp11.1%
div-sub11.1%
rec-exp11.1%
tanh-def-a84.3%
Simplified84.3%
if -1.25000000000000008e-10 < t < 1.4500000000000001e-48Initial program 89.4%
sub-neg89.4%
distribute-lft-in83.1%
Applied egg-rr83.1%
Taylor expanded in t around 0 28.8%
+-commutative28.8%
mul-1-neg28.8%
unsub-neg28.8%
*-commutative28.8%
associate-/l*28.8%
associate-/l*28.8%
rec-exp28.8%
Simplified89.0%
Final simplification86.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -5.8e-6) (not (<= x 0.000205))) (- x (* y (* z (tanh (/ x y))))) (+ x (* y (* z (tanh (/ t y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -5.8e-6) || !(x <= 0.000205)) {
tmp = x - (y * (z * tanh((x / y))));
} else {
tmp = x + (y * (z * tanh((t / y))));
}
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 ((x <= (-5.8d-6)) .or. (.not. (x <= 0.000205d0))) then
tmp = x - (y * (z * tanh((x / y))))
else
tmp = x + (y * (z * tanh((t / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -5.8e-6) || !(x <= 0.000205)) {
tmp = x - (y * (z * Math.tanh((x / y))));
} else {
tmp = x + (y * (z * Math.tanh((t / y))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -5.8e-6) or not (x <= 0.000205): tmp = x - (y * (z * math.tanh((x / y)))) else: tmp = x + (y * (z * math.tanh((t / y)))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -5.8e-6) || !(x <= 0.000205)) tmp = Float64(x - Float64(y * Float64(z * tanh(Float64(x / y))))); else tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -5.8e-6) || ~((x <= 0.000205))) tmp = x - (y * (z * tanh((x / y)))); else tmp = x + (y * (z * tanh((t / y)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -5.8e-6], N[Not[LessEqual[x, 0.000205]], $MachinePrecision]], N[(x - N[(y * N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{-6} \lor \neg \left(x \leq 0.000205\right):\\
\;\;\;\;x - y \cdot \left(z \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\end{array}
\end{array}
if x < -5.8000000000000004e-6 or 2.05e-4 < x Initial program 92.5%
sub-neg92.5%
distribute-lft-in86.8%
Applied egg-rr86.8%
distribute-rgt-neg-out86.8%
distribute-lft-neg-in86.8%
add-sqr-sqrt39.5%
sqrt-unprod76.2%
sqr-neg76.2%
sqrt-unprod37.4%
add-sqr-sqrt69.6%
cancel-sign-sub-inv69.6%
associate-*l*69.6%
associate-*l*70.3%
distribute-lft-out--70.4%
add-sqr-sqrt37.4%
sqrt-unprod81.2%
Applied egg-rr99.9%
Taylor expanded in t around 0 12.7%
mul-1-neg12.7%
associate-/l*12.7%
associate-/l*12.7%
rec-exp12.7%
rec-exp12.7%
tanh-def-a89.7%
distribute-rgt-neg-in89.7%
Simplified89.7%
if -5.8000000000000004e-6 < x < 2.05e-4Initial program 91.7%
Taylor expanded in x around 0 20.9%
associate-/r*20.9%
rec-exp20.9%
div-sub20.9%
rec-exp20.9%
tanh-def-a80.0%
Simplified80.0%
Final simplification84.9%
(FPCore (x y z t) :precision binary64 (if (<= y 1.6e+59) x (if (<= y 1.9e+210) (* x (- 1.0 z)) (+ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.6e+59) {
tmp = x;
} else if (y <= 1.9e+210) {
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 <= 1.6d+59) then
tmp = x
else if (y <= 1.9d+210) 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 <= 1.6e+59) {
tmp = x;
} else if (y <= 1.9e+210) {
tmp = x * (1.0 - z);
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.6e+59: tmp = x elif y <= 1.9e+210: tmp = x * (1.0 - z) else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.6e+59) tmp = x; elseif (y <= 1.9e+210) 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 <= 1.6e+59) tmp = x; elseif (y <= 1.9e+210) tmp = x * (1.0 - z); else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.6e+59], x, If[LessEqual[y, 1.9e+210], 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 1.6 \cdot 10^{+59}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+210}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.59999999999999991e59Initial program 94.5%
+-commutative94.5%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
Taylor expanded in y around 0 60.6%
if 1.59999999999999991e59 < y < 1.90000000000000014e210Initial program 83.8%
Taylor expanded in x around 0 67.4%
Taylor expanded in x around inf 59.8%
mul-1-neg59.8%
unsub-neg59.8%
Simplified59.8%
if 1.90000000000000014e210 < y Initial program 86.1%
Taylor expanded in y around inf 82.5%
Taylor expanded in t around inf 85.9%
*-commutative85.9%
Simplified85.9%
Final simplification63.3%
(FPCore (x y z t) :precision binary64 (if (<= y 2.75e+57) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.75e+57) {
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 <= 2.75d+57) 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 <= 2.75e+57) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.75e+57: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.75e+57) 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 <= 2.75e+57) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.75e+57], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.75 \cdot 10^{+57}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.7500000000000001e57Initial program 94.5%
+-commutative94.5%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
Taylor expanded in y around 0 60.6%
if 2.7500000000000001e57 < y Initial program 84.8%
Taylor expanded in y around inf 83.1%
Final simplification66.0%
(FPCore (x y z t) :precision binary64 (if (<= y 7e+58) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7e+58) {
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 <= 7d+58) 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 <= 7e+58) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 7e+58: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 7e+58) 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 <= 7e+58) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 7e+58], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{+58}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 6.9999999999999995e58Initial program 94.5%
+-commutative94.5%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
Taylor expanded in y around 0 60.6%
if 6.9999999999999995e58 < y Initial program 84.8%
Taylor expanded in x around 0 75.8%
Taylor expanded in x around inf 59.2%
mul-1-neg59.2%
unsub-neg59.2%
Simplified59.2%
Final simplification60.3%
(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.1%
+-commutative92.1%
associate-*l*97.0%
fma-define97.0%
Simplified97.0%
Taylor expanded in y around 0 55.4%
Final simplification55.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 2024060
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))