
(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 10 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}
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 3.4e+181) (fma y_m (* z (- (tanh (/ t y_m)) (tanh (/ x y_m)))) x) (+ x (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 3.4e+181) {
tmp = fma(y_m, (z * (tanh((t / y_m)) - tanh((x / y_m)))), x);
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 3.4e+181) tmp = fma(y_m, Float64(z * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))), x); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 3.4e+181], N[(y$95$m * N[(z * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 3.4 \cdot 10^{+181}:\\
\;\;\;\;\mathsf{fma}\left(y\_m, z \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.40000000000000031e181Initial program 97.2%
+-commutative97.2%
associate-*l*98.7%
fma-define98.7%
Simplified98.7%
if 3.40000000000000031e181 < y Initial program 75.7%
Taylor expanded in y around inf 95.6%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (or (<= t -3.2e-30) (not (<= t 2.7e-10))) (+ x (* y_m (* z (tanh (/ t y_m))))) (fma y_m (* z (- (/ t y_m) (tanh (/ x y_m)))) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if ((t <= -3.2e-30) || !(t <= 2.7e-10)) {
tmp = x + (y_m * (z * tanh((t / y_m))));
} else {
tmp = fma(y_m, (z * ((t / y_m) - tanh((x / y_m)))), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if ((t <= -3.2e-30) || !(t <= 2.7e-10)) tmp = Float64(x + Float64(y_m * Float64(z * tanh(Float64(t / y_m))))); else tmp = fma(y_m, Float64(z * Float64(Float64(t / y_m) - tanh(Float64(x / y_m)))), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[Or[LessEqual[t, -3.2e-30], N[Not[LessEqual[t, 2.7e-10]], $MachinePrecision]], N[(x + N[(y$95$m * N[(z * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(z * N[(N[(t / y$95$m), $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.2 \cdot 10^{-30} \lor \neg \left(t \leq 2.7 \cdot 10^{-10}\right):\\
\;\;\;\;x + y\_m \cdot \left(z \cdot \tanh \left(\frac{t}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y\_m, z \cdot \left(\frac{t}{y\_m} - \tanh \left(\frac{x}{y\_m}\right)\right), x\right)\\
\end{array}
\end{array}
if t < -3.2e-30 or 2.7e-10 < t Initial program 97.2%
Taylor expanded in x around 0 10.4%
associate-/r*10.4%
div-sub10.4%
rec-exp10.4%
rec-exp10.4%
tanh-def-a92.5%
Simplified92.5%
if -3.2e-30 < t < 2.7e-10Initial program 93.5%
+-commutative93.5%
associate-*l*95.1%
fma-define95.1%
Simplified95.1%
Taylor expanded in t around 0 89.5%
Final simplification91.1%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 4.5e+180) (+ x (* (- (tanh (/ t y_m)) (tanh (/ x y_m))) (* y_m z))) (+ x (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 4.5e+180) {
tmp = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y_m <= 4.5d+180) then
tmp = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 4.5e+180) {
tmp = x + ((Math.tanh((t / y_m)) - Math.tanh((x / y_m))) * (y_m * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 4.5e+180: tmp = x + ((math.tanh((t / y_m)) - math.tanh((x / y_m))) * (y_m * z)) else: tmp = x + (z * (t - x)) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 4.5e+180) tmp = Float64(x + Float64(Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))) * Float64(y_m * z))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 4.5e+180) tmp = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 4.5e+180], N[(x + N[(N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 4.5 \cdot 10^{+180}:\\
\;\;\;\;x + \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right) \cdot \left(y\_m \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.49999999999999981e180Initial program 97.2%
if 4.49999999999999981e180 < y Initial program 75.7%
Taylor expanded in y around inf 95.6%
Final simplification97.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (or (<= t -2.4e-21) (not (<= t 1.8e-84))) (+ x (* y_m (* z (tanh (/ t y_m))))) (+ x (* (* y_m z) (- (/ t y_m) (tanh (/ x y_m)))))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if ((t <= -2.4e-21) || !(t <= 1.8e-84)) {
tmp = x + (y_m * (z * tanh((t / y_m))));
} else {
tmp = x + ((y_m * z) * ((t / y_m) - tanh((x / y_m))));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-2.4d-21)) .or. (.not. (t <= 1.8d-84))) then
tmp = x + (y_m * (z * tanh((t / y_m))))
else
tmp = x + ((y_m * z) * ((t / y_m) - tanh((x / y_m))))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if ((t <= -2.4e-21) || !(t <= 1.8e-84)) {
tmp = x + (y_m * (z * Math.tanh((t / y_m))));
} else {
tmp = x + ((y_m * z) * ((t / y_m) - Math.tanh((x / y_m))));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if (t <= -2.4e-21) or not (t <= 1.8e-84): tmp = x + (y_m * (z * math.tanh((t / y_m)))) else: tmp = x + ((y_m * z) * ((t / y_m) - math.tanh((x / y_m)))) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if ((t <= -2.4e-21) || !(t <= 1.8e-84)) tmp = Float64(x + Float64(y_m * Float64(z * tanh(Float64(t / y_m))))); else tmp = Float64(x + Float64(Float64(y_m * z) * Float64(Float64(t / y_m) - tanh(Float64(x / y_m))))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if ((t <= -2.4e-21) || ~((t <= 1.8e-84))) tmp = x + (y_m * (z * tanh((t / y_m)))); else tmp = x + ((y_m * z) * ((t / y_m) - tanh((x / y_m)))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[Or[LessEqual[t, -2.4e-21], N[Not[LessEqual[t, 1.8e-84]], $MachinePrecision]], N[(x + N[(y$95$m * N[(z * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[(t / y$95$m), $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.4 \cdot 10^{-21} \lor \neg \left(t \leq 1.8 \cdot 10^{-84}\right):\\
\;\;\;\;x + y\_m \cdot \left(z \cdot \tanh \left(\frac{t}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(y\_m \cdot z\right) \cdot \left(\frac{t}{y\_m} - \tanh \left(\frac{x}{y\_m}\right)\right)\\
\end{array}
\end{array}
if t < -2.3999999999999999e-21 or 1.80000000000000002e-84 < t Initial program 96.8%
Taylor expanded in x around 0 11.1%
associate-/r*11.1%
div-sub11.2%
rec-exp11.2%
rec-exp11.2%
tanh-def-a91.1%
Simplified91.1%
if -2.3999999999999999e-21 < t < 1.80000000000000002e-84Initial program 93.8%
Taylor expanded in t around 0 91.1%
Final simplification91.1%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 8.4e+179) (+ x (* y_m (* z (tanh (/ t y_m))))) (+ x (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 8.4e+179) {
tmp = x + (y_m * (z * tanh((t / y_m))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y_m <= 8.4d+179) then
tmp = x + (y_m * (z * tanh((t / y_m))))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 8.4e+179) {
tmp = x + (y_m * (z * Math.tanh((t / y_m))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 8.4e+179: tmp = x + (y_m * (z * math.tanh((t / y_m)))) else: tmp = x + (z * (t - x)) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 8.4e+179) tmp = Float64(x + Float64(y_m * Float64(z * tanh(Float64(t / y_m))))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 8.4e+179) tmp = x + (y_m * (z * tanh((t / y_m)))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 8.4e+179], N[(x + N[(y$95$m * N[(z * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 8.4 \cdot 10^{+179}:\\
\;\;\;\;x + y\_m \cdot \left(z \cdot \tanh \left(\frac{t}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 8.3999999999999994e179Initial program 97.2%
Taylor expanded in x around 0 25.4%
associate-/r*25.4%
div-sub25.4%
rec-exp25.4%
rec-exp25.4%
tanh-def-a80.6%
Simplified80.6%
if 8.3999999999999994e179 < y Initial program 75.7%
Taylor expanded in y around inf 95.6%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 920000000000.0) x (+ x (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 920000000000.0) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y_m <= 920000000000.0d0) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 920000000000.0) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 920000000000.0: tmp = x else: tmp = x + (z * (t - x)) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 920000000000.0) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 920000000000.0) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 920000000000.0], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 920000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 9.2e11Initial program 96.7%
+-commutative96.7%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
Taylor expanded in y around 0 62.3%
if 9.2e11 < y Initial program 91.2%
Taylor expanded in y around inf 73.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 3.5e+25) x (+ x (* z t))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 3.5e+25) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y_m <= 3.5d+25) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 3.5e+25) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 3.5e+25: tmp = x else: tmp = x + (z * t) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 3.5e+25) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 3.5e+25) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 3.5e+25], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 3.5 \cdot 10^{+25}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 3.49999999999999999e25Initial program 96.7%
+-commutative96.7%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
Taylor expanded in y around 0 62.2%
if 3.49999999999999999e25 < y Initial program 90.8%
Taylor expanded in x around 0 38.1%
associate-/r*38.1%
div-sub38.1%
rec-exp38.1%
rec-exp38.1%
tanh-def-a81.1%
Simplified81.1%
Taylor expanded in y around inf 67.1%
+-commutative67.1%
*-commutative67.1%
Simplified67.1%
Final simplification63.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 58000.0) x (* x (- 1.0 z))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 58000.0) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y_m <= 58000.0d0) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 58000.0) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 58000.0: tmp = x else: tmp = x * (1.0 - z) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 58000.0) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 58000.0) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 58000.0], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 58000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 58000Initial program 96.7%
+-commutative96.7%
associate-*l*98.4%
fma-define98.5%
Simplified98.5%
Taylor expanded in y around 0 62.5%
if 58000 < y Initial program 91.3%
Taylor expanded in y around inf 74.3%
Taylor expanded in x around inf 51.0%
mul-1-neg51.0%
unsub-neg51.0%
Simplified51.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= z -8.6e+201) (* z (- x)) x))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (z <= -8.6e+201) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-8.6d+201)) then
tmp = z * -x
else
tmp = x
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (z <= -8.6e+201) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if z <= -8.6e+201: tmp = z * -x else: tmp = x return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (z <= -8.6e+201) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (z <= -8.6e+201) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[z, -8.6e+201], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.6 \cdot 10^{+201}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -8.59999999999999981e201Initial program 72.3%
Taylor expanded in y around inf 61.0%
Taylor expanded in x around inf 50.0%
mul-1-neg50.0%
unsub-neg50.0%
Simplified50.0%
Taylor expanded in z around inf 50.0%
neg-mul-150.0%
distribute-rgt-neg-in50.0%
Simplified50.0%
if -8.59999999999999981e201 < z Initial program 97.1%
+-commutative97.1%
associate-*l*97.9%
fma-define98.0%
Simplified98.0%
Taylor expanded in y around 0 61.6%
Final simplification60.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 x)
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
return x;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
return x;
}
y_m = math.fabs(y) def code(x, y_m, z, t): return x
y_m = abs(y) function code(x, y_m, z, t) return x end
y_m = abs(y); function tmp = code(x, y_m, z, t) tmp = x; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := x
\begin{array}{l}
y_m = \left|y\right|
\\
x
\end{array}
Initial program 95.5%
+-commutative95.5%
associate-*l*97.3%
fma-define97.3%
Simplified97.3%
Taylor expanded in y around 0 58.2%
(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 2024186
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))