
(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 8 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.45e+138)
(fma (* y z) (- t_1 (tanh (/ x y))) x)
(+ 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.45e+138) {
tmp = fma((y * z), (t_1 - tanh((x / y))), x);
} 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.45e+138) tmp = fma(Float64(y * z), Float64(t_1 - tanh(Float64(x / y))), x); else tmp = Float64(x + Float64(z * Float64(Float64(y * 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[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 1.45e+138], N[(N[(y * z), $MachinePrecision] * N[(t$95$1 - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + x), $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.45 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, t_1 - \tanh \left(\frac{x}{y}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 1.45000000000000005e138Initial program 95.5%
+-commutative95.5%
fma-def95.5%
Simplified95.5%
if 1.45000000000000005e138 < y Initial program 80.9%
Taylor expanded in x around 0 55.5%
+-commutative55.5%
Simplified96.2%
add-sqr-sqrt56.2%
sqrt-unprod79.2%
pow279.2%
Applied egg-rr79.2%
unpow279.2%
rem-sqrt-square78.9%
Simplified78.9%
Taylor expanded in z around 0 78.9%
expm1-log1p-u77.3%
expm1-udef77.4%
add-sqr-sqrt54.6%
fabs-sqr54.6%
add-sqr-sqrt61.3%
Applied egg-rr61.3%
expm1-def66.6%
expm1-log1p96.2%
Simplified96.2%
Final simplification95.5%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 4e+138)
(+ 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 <= 4e+138) {
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 <= 4d+138) 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 <= 4e+138) {
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 <= 4e+138: 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 <= 4e+138) tmp = Float64(x + Float64(Float64(y * 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 <= 4e+138) 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, 4e+138], N[(x + N[(N[(y * z), $MachinePrecision] * N[(t$95$1 - N[Tanh[N[(x / y), $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 4 \cdot 10^{+138}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(t_1 - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 4.0000000000000001e138Initial program 95.5%
if 4.0000000000000001e138 < y Initial program 80.9%
Taylor expanded in x around 0 55.5%
+-commutative55.5%
Simplified96.2%
add-sqr-sqrt56.2%
sqrt-unprod79.2%
pow279.2%
Applied egg-rr79.2%
unpow279.2%
rem-sqrt-square78.9%
Simplified78.9%
Taylor expanded in z around 0 78.9%
expm1-log1p-u77.3%
expm1-udef77.4%
add-sqr-sqrt54.6%
fabs-sqr54.6%
add-sqr-sqrt61.3%
Applied egg-rr61.3%
expm1-def66.6%
expm1-log1p96.2%
Simplified96.2%
Final simplification95.5%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 6.4e+16) (+ x (* y (* z t_1))) (+ 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 <= 6.4e+16) {
tmp = x + (y * (z * t_1));
} 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 <= 6.4d+16) then
tmp = x + (y * (z * t_1))
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 <= 6.4e+16) {
tmp = x + (y * (z * t_1));
} 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 <= 6.4e+16: tmp = x + (y * (z * t_1)) 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 <= 6.4e+16) tmp = Float64(x + Float64(y * Float64(z * t_1))); 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 <= 6.4e+16) tmp = x + (y * (z * t_1)); 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, 6.4e+16], N[(x + N[(y * N[(z * t$95$1), $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 6.4 \cdot 10^{+16}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 6.4e16Initial program 95.3%
Taylor expanded in x around 0 26.0%
associate-/r*26.0%
div-sub26.0%
rec-exp26.0%
rec-exp26.0%
tanh-def-a81.1%
Simplified81.1%
if 6.4e16 < y Initial program 89.4%
Taylor expanded in x around 0 47.5%
+-commutative47.5%
Simplified84.6%
add-sqr-sqrt53.4%
sqrt-unprod73.3%
pow273.3%
Applied egg-rr73.3%
unpow273.3%
rem-sqrt-square73.2%
Simplified73.2%
Taylor expanded in z around 0 73.2%
expm1-log1p-u72.1%
expm1-udef72.1%
add-sqr-sqrt52.4%
fabs-sqr52.4%
add-sqr-sqrt59.2%
Applied egg-rr59.2%
expm1-def61.6%
expm1-log1p84.6%
Simplified84.6%
Final simplification81.9%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 5.2e+145) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.2e+145) {
tmp = x + (y * (z * tanh((t / y))));
} 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 <= 5.2d+145) then
tmp = x + (y * (z * tanh((t / y))))
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 <= 5.2e+145) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 5.2e+145: tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 5.2e+145) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); 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 <= 5.2e+145) tmp = x + (y * (z * tanh((t / y)))); 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, 5.2e+145], 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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.2 \cdot 10^{+145}:\\
\;\;\;\;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 < 5.20000000000000005e145Initial program 95.5%
Taylor expanded in x around 0 26.5%
associate-/r*26.5%
div-sub26.5%
rec-exp26.5%
rec-exp26.5%
tanh-def-a79.3%
Simplified79.3%
if 5.20000000000000005e145 < y Initial program 79.2%
Taylor expanded in y around inf 87.8%
Final simplification80.1%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(if (<= y 2.65e+17)
x
(if (or (<= y 3.55e+189) (not (<= y 4.1e+301)))
(- x (* z x))
(+ x (* z t)))))y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.65e+17) {
tmp = x;
} else if ((y <= 3.55e+189) || !(y <= 4.1e+301)) {
tmp = x - (z * 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 <= 2.65d+17) then
tmp = x
else if ((y <= 3.55d+189) .or. (.not. (y <= 4.1d+301))) then
tmp = x - (z * 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 <= 2.65e+17) {
tmp = x;
} else if ((y <= 3.55e+189) || !(y <= 4.1e+301)) {
tmp = x - (z * x);
} else {
tmp = x + (z * t);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 2.65e+17: tmp = x elif (y <= 3.55e+189) or not (y <= 4.1e+301): tmp = x - (z * x) else: tmp = x + (z * t) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 2.65e+17) tmp = x; elseif ((y <= 3.55e+189) || !(y <= 4.1e+301)) tmp = Float64(x - Float64(z * 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 <= 2.65e+17) tmp = x; elseif ((y <= 3.55e+189) || ~((y <= 4.1e+301))) tmp = x - (z * 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, 2.65e+17], x, If[Or[LessEqual[y, 3.55e+189], N[Not[LessEqual[y, 4.1e+301]], $MachinePrecision]], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.65 \cdot 10^{+17}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.55 \cdot 10^{+189} \lor \neg \left(y \leq 4.1 \cdot 10^{+301}\right):\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 2.65e17Initial program 95.3%
+-commutative95.3%
fma-def95.3%
Simplified95.3%
Taylor expanded in y around 0 66.7%
if 2.65e17 < y < 3.55e189 or 4.0999999999999998e301 < y Initial program 95.0%
Taylor expanded in x around 0 48.1%
+-commutative48.1%
Simplified81.2%
Taylor expanded in x around inf 64.3%
distribute-lft-in64.3%
*-rgt-identity64.3%
mul-1-neg64.3%
distribute-rgt-neg-in64.3%
unsub-neg64.3%
*-commutative64.3%
Simplified64.3%
if 3.55e189 < y < 4.0999999999999998e301Initial program 74.5%
Taylor expanded in x around 0 28.3%
associate-/r*28.3%
div-sub28.3%
rec-exp28.3%
rec-exp28.3%
tanh-def-a61.5%
Simplified61.5%
Taylor expanded in y around inf 74.6%
+-commutative74.6%
*-commutative74.6%
Simplified74.6%
Final simplification66.8%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 6.6e+15) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.6e+15) {
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 <= 6.6d+15) 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 <= 6.6e+15) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 6.6e+15: tmp = x else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 6.6e+15) 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 <= 6.6e+15) 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, 6.6e+15], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.6 \cdot 10^{+15}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 6.6e15Initial program 95.3%
+-commutative95.3%
fma-def95.3%
Simplified95.3%
Taylor expanded in y around 0 66.7%
if 6.6e15 < y Initial program 89.4%
Taylor expanded in y around inf 71.9%
Final simplification67.8%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 4.2e+90) x (+ x (* z t))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.2e+90) {
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 <= 4.2d+90) 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 <= 4.2e+90) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 4.2e+90: tmp = x else: tmp = x + (z * t) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 4.2e+90) 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 <= 4.2e+90) 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, 4.2e+90], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.2 \cdot 10^{+90}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 4.19999999999999961e90Initial program 95.3%
+-commutative95.3%
fma-def95.3%
Simplified95.3%
Taylor expanded in y around 0 64.9%
if 4.19999999999999961e90 < y Initial program 85.1%
Taylor expanded in x around 0 38.6%
associate-/r*38.6%
div-sub38.6%
rec-exp38.6%
rec-exp38.6%
tanh-def-a69.7%
Simplified69.7%
Taylor expanded in y around inf 66.1%
+-commutative66.1%
*-commutative66.1%
Simplified66.1%
Final simplification65.1%
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 94.0%
+-commutative94.0%
fma-def94.1%
Simplified94.1%
Taylor expanded in y around 0 62.1%
Final simplification62.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 2023287
(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))))))