exp neg sub

Percentage Accurate: 100.0% → 100.0%
Time: 1.8s
Alternatives: 6
Speedup: 0.9×

Specification

?
\[e^{-\left(1 - x \cdot x\right)} \]
(FPCore (x)
  :precision binary64
  (exp (- (- 1.0 (* x x)))))
double code(double x) {
	return exp(-(1.0 - (x * x)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = exp(-(1.0d0 - (x * x)))
end function
public static double code(double x) {
	return Math.exp(-(1.0 - (x * x)));
}
def code(x):
	return math.exp(-(1.0 - (x * x)))
function code(x)
	return exp(Float64(-Float64(1.0 - Float64(x * x))))
end
function tmp = code(x)
	tmp = exp(-(1.0 - (x * x)));
end
code[x_] := N[Exp[(-N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]
e^{-\left(1 - x \cdot x\right)}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

\[e^{-\left(1 - x \cdot x\right)} \]
(FPCore (x)
  :precision binary64
  (exp (- (- 1.0 (* x x)))))
double code(double x) {
	return exp(-(1.0 - (x * x)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = exp(-(1.0d0 - (x * x)))
end function
public static double code(double x) {
	return Math.exp(-(1.0 - (x * x)));
}
def code(x):
	return math.exp(-(1.0 - (x * x)))
function code(x)
	return exp(Float64(-Float64(1.0 - Float64(x * x))))
end
function tmp = code(x)
	tmp = exp(-(1.0 - (x * x)));
end
code[x_] := N[Exp[(-N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]
e^{-\left(1 - x \cdot x\right)}

Alternative 1: 100.0% accurate, 0.9× speedup?

\[\frac{e^{x \cdot x}}{e} \]
(FPCore (x)
  :precision binary64
  (/ (exp (* x x)) E))
double code(double x) {
	return exp((x * x)) / ((double) M_E);
}
public static double code(double x) {
	return Math.exp((x * x)) / Math.E;
}
def code(x):
	return math.exp((x * x)) / math.e
function code(x)
	return Float64(exp(Float64(x * x)) / exp(1))
end
function tmp = code(x)
	tmp = exp((x * x)) / 2.71828182845904523536;
end
code[x_] := N[(N[Exp[N[(x * x), $MachinePrecision]], $MachinePrecision] / E), $MachinePrecision]
\frac{e^{x \cdot x}}{e}
Derivation
  1. Initial program 100.0%

    \[e^{-\left(1 - x \cdot x\right)} \]
  2. Step-by-step derivation
    1. lift-exp.f64N/A

      \[\leadsto \color{blue}{e^{-\left(1 - x \cdot x\right)}} \]
    2. lift-neg.f64N/A

      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}} \]
    3. lift--.f64N/A

      \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(1 - x \cdot x\right)}\right)} \]
    4. sub-negateN/A

      \[\leadsto e^{\color{blue}{x \cdot x - 1}} \]
    5. exp-diffN/A

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e^{1}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e^{1}}} \]
    7. lower-exp.f64N/A

      \[\leadsto \frac{\color{blue}{e^{x \cdot x}}}{e^{1}} \]
    8. exp-1-eN/A

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{\mathsf{E}\left(\right)}} \]
    9. lower-E.f64100.0%

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{e}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e}} \]
  4. Add Preprocessing

Alternative 2: 100.0% accurate, 1.0× speedup?

\[e^{x \cdot x - 1} \]
(FPCore (x)
  :precision binary64
  (exp (- (* x x) 1.0)))
double code(double x) {
	return exp(((x * x) - 1.0));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = exp(((x * x) - 1.0d0))
end function
public static double code(double x) {
	return Math.exp(((x * x) - 1.0));
}
def code(x):
	return math.exp(((x * x) - 1.0))
function code(x)
	return exp(Float64(Float64(x * x) - 1.0))
end
function tmp = code(x)
	tmp = exp(((x * x) - 1.0));
end
code[x_] := N[Exp[N[(N[(x * x), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision]
e^{x \cdot x - 1}
Derivation
  1. Initial program 100.0%

    \[e^{-\left(1 - x \cdot x\right)} \]
  2. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}} \]
    2. lift--.f64N/A

      \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(1 - x \cdot x\right)}\right)} \]
    3. sub-negateN/A

      \[\leadsto e^{\color{blue}{x \cdot x - 1}} \]
    4. lower--.f64100.0%

      \[\leadsto e^{\color{blue}{x \cdot x - 1}} \]
  3. Applied rewrites100.0%

    \[\leadsto e^{\color{blue}{x \cdot x - 1}} \]
  4. Add Preprocessing

Alternative 3: 93.6% accurate, 1.6× speedup?

\[\begin{array}{l} t_0 := \left(\left(x \cdot x\right) \cdot x\right) \cdot x\\ \frac{1 + \sqrt{\sqrt{t\_0 \cdot t\_0}}}{e} \end{array} \]
(FPCore (x)
  :precision binary64
  (let* ((t_0 (* (* (* x x) x) x)))
  (/ (+ 1.0 (sqrt (sqrt (* t_0 t_0)))) E)))
double code(double x) {
	double t_0 = ((x * x) * x) * x;
	return (1.0 + sqrt(sqrt((t_0 * t_0)))) / ((double) M_E);
}
public static double code(double x) {
	double t_0 = ((x * x) * x) * x;
	return (1.0 + Math.sqrt(Math.sqrt((t_0 * t_0)))) / Math.E;
}
def code(x):
	t_0 = ((x * x) * x) * x
	return (1.0 + math.sqrt(math.sqrt((t_0 * t_0)))) / math.e
function code(x)
	t_0 = Float64(Float64(Float64(x * x) * x) * x)
	return Float64(Float64(1.0 + sqrt(sqrt(Float64(t_0 * t_0)))) / exp(1))
end
function tmp = code(x)
	t_0 = ((x * x) * x) * x;
	tmp = (1.0 + sqrt(sqrt((t_0 * t_0)))) / 2.71828182845904523536;
end
code[x_] := Block[{t$95$0 = N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]}, N[(N[(1.0 + N[Sqrt[N[Sqrt[N[(t$95$0 * t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / E), $MachinePrecision]]
\begin{array}{l}
t_0 := \left(\left(x \cdot x\right) \cdot x\right) \cdot x\\
\frac{1 + \sqrt{\sqrt{t\_0 \cdot t\_0}}}{e}
\end{array}
Derivation
  1. Initial program 100.0%

    \[e^{-\left(1 - x \cdot x\right)} \]
  2. Step-by-step derivation
    1. lift-exp.f64N/A

      \[\leadsto \color{blue}{e^{-\left(1 - x \cdot x\right)}} \]
    2. lift-neg.f64N/A

      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}} \]
    3. lift--.f64N/A

      \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(1 - x \cdot x\right)}\right)} \]
    4. sub-negateN/A

      \[\leadsto e^{\color{blue}{x \cdot x - 1}} \]
    5. exp-diffN/A

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e^{1}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e^{1}}} \]
    7. lower-exp.f64N/A

      \[\leadsto \frac{\color{blue}{e^{x \cdot x}}}{e^{1}} \]
    8. exp-1-eN/A

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{\mathsf{E}\left(\right)}} \]
    9. lower-E.f64100.0%

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{e}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e}} \]
  4. Taylor expanded in x around 0

    \[\leadsto \frac{\color{blue}{1 + {x}^{2}}}{e} \]
  5. Step-by-step derivation
    1. lower-+.f64N/A

      \[\leadsto \frac{1 + \color{blue}{{x}^{2}}}{e} \]
    2. lower-pow.f6476.0%

      \[\leadsto \frac{1 + {x}^{\color{blue}{2}}}{e} \]
  6. Applied rewrites76.0%

    \[\leadsto \frac{\color{blue}{1 + {x}^{2}}}{e} \]
  7. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto \frac{1 + {x}^{\color{blue}{2}}}{e} \]
    2. pow2N/A

      \[\leadsto \frac{1 + x \cdot \color{blue}{x}}{e} \]
    3. fabs-sqrN/A

      \[\leadsto \frac{1 + \left|x \cdot x\right|}{e} \]
    4. rem-sqrt-square-revN/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    5. lower-*.f32N/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    6. lower-unsound-*.f32N/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    7. lower-sqrt.f64N/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    8. lower-unsound-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    9. lower-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    10. lower-*.f6487.3%

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
  8. Applied rewrites87.3%

    \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
  9. Step-by-step derivation
    1. rem-square-sqrtN/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \cdot \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}}{e} \]
    2. sqrt-unprodN/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    3. lower-sqrt.f64N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    4. lower-*.f6493.6%

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    6. lift-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    7. associate-*l*N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    8. *-commutativeN/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(x \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    9. lift-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(x \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    10. cube-unmultN/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left({x}^{3} \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    11. lower-pow.f32N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left({x}^{3} \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    12. lower-unsound-pow.f32N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left({x}^{3} \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    13. lower-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left({x}^{3} \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    14. lower-unsound-pow.f3297.7%

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left( {x}^{3} \right)_{\text{binary32}} \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    15. lower-pow.f32N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left({x}^{3} \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    16. pow3N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    17. lift-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    18. lower-*.f6493.6%

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    19. lift-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    20. lift-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}}{e} \]
    21. associate-*l*N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)}}}{e} \]
    22. *-commutativeN/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot x\right)}}}{e} \]
    23. lift-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot x\right)}}}{e} \]
    24. cube-unmultN/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left({x}^{3} \cdot x\right)}}}{e} \]
    25. lower-pow.f32N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left({x}^{3} \cdot x\right)}}}{e} \]
    26. lower-unsound-pow.f32N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left({x}^{3} \cdot x\right)}}}{e} \]
    27. lower-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left({x}^{3} \cdot x\right)}}}{e} \]
  10. Applied rewrites93.6%

    \[\leadsto \frac{1 + \sqrt{\sqrt{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right)}}}{e} \]
  11. Add Preprocessing

Alternative 4: 87.3% accurate, 2.8× speedup?

\[\frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
(FPCore (x)
  :precision binary64
  (/ (+ 1.0 (sqrt (* (* x x) (* x x)))) E))
double code(double x) {
	return (1.0 + sqrt(((x * x) * (x * x)))) / ((double) M_E);
}
public static double code(double x) {
	return (1.0 + Math.sqrt(((x * x) * (x * x)))) / Math.E;
}
def code(x):
	return (1.0 + math.sqrt(((x * x) * (x * x)))) / math.e
function code(x)
	return Float64(Float64(1.0 + sqrt(Float64(Float64(x * x) * Float64(x * x)))) / exp(1))
end
function tmp = code(x)
	tmp = (1.0 + sqrt(((x * x) * (x * x)))) / 2.71828182845904523536;
end
code[x_] := N[(N[(1.0 + N[Sqrt[N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / E), $MachinePrecision]
\frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e}
Derivation
  1. Initial program 100.0%

    \[e^{-\left(1 - x \cdot x\right)} \]
  2. Step-by-step derivation
    1. lift-exp.f64N/A

      \[\leadsto \color{blue}{e^{-\left(1 - x \cdot x\right)}} \]
    2. lift-neg.f64N/A

      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}} \]
    3. lift--.f64N/A

      \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(1 - x \cdot x\right)}\right)} \]
    4. sub-negateN/A

      \[\leadsto e^{\color{blue}{x \cdot x - 1}} \]
    5. exp-diffN/A

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e^{1}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e^{1}}} \]
    7. lower-exp.f64N/A

      \[\leadsto \frac{\color{blue}{e^{x \cdot x}}}{e^{1}} \]
    8. exp-1-eN/A

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{\mathsf{E}\left(\right)}} \]
    9. lower-E.f64100.0%

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{e}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e}} \]
  4. Taylor expanded in x around 0

    \[\leadsto \frac{\color{blue}{1 + {x}^{2}}}{e} \]
  5. Step-by-step derivation
    1. lower-+.f64N/A

      \[\leadsto \frac{1 + \color{blue}{{x}^{2}}}{e} \]
    2. lower-pow.f6476.0%

      \[\leadsto \frac{1 + {x}^{\color{blue}{2}}}{e} \]
  6. Applied rewrites76.0%

    \[\leadsto \frac{\color{blue}{1 + {x}^{2}}}{e} \]
  7. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto \frac{1 + {x}^{\color{blue}{2}}}{e} \]
    2. pow2N/A

      \[\leadsto \frac{1 + x \cdot \color{blue}{x}}{e} \]
    3. fabs-sqrN/A

      \[\leadsto \frac{1 + \left|x \cdot x\right|}{e} \]
    4. rem-sqrt-square-revN/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    5. lower-*.f32N/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    6. lower-unsound-*.f32N/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    7. lower-sqrt.f64N/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    8. lower-unsound-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    9. lower-*.f64N/A

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
    10. lower-*.f6487.3%

      \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
  8. Applied rewrites87.3%

    \[\leadsto \frac{1 + \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{e} \]
  9. Add Preprocessing

Alternative 5: 76.0% accurate, 5.6× speedup?

\[\frac{x \cdot x - -1}{e} \]
(FPCore (x)
  :precision binary64
  (/ (- (* x x) -1.0) E))
double code(double x) {
	return ((x * x) - -1.0) / ((double) M_E);
}
public static double code(double x) {
	return ((x * x) - -1.0) / Math.E;
}
def code(x):
	return ((x * x) - -1.0) / math.e
function code(x)
	return Float64(Float64(Float64(x * x) - -1.0) / exp(1))
end
function tmp = code(x)
	tmp = ((x * x) - -1.0) / 2.71828182845904523536;
end
code[x_] := N[(N[(N[(x * x), $MachinePrecision] - -1.0), $MachinePrecision] / E), $MachinePrecision]
\frac{x \cdot x - -1}{e}
Derivation
  1. Initial program 100.0%

    \[e^{-\left(1 - x \cdot x\right)} \]
  2. Step-by-step derivation
    1. lift-exp.f64N/A

      \[\leadsto \color{blue}{e^{-\left(1 - x \cdot x\right)}} \]
    2. lift-neg.f64N/A

      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}} \]
    3. lift--.f64N/A

      \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(1 - x \cdot x\right)}\right)} \]
    4. sub-negateN/A

      \[\leadsto e^{\color{blue}{x \cdot x - 1}} \]
    5. exp-diffN/A

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e^{1}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e^{1}}} \]
    7. lower-exp.f64N/A

      \[\leadsto \frac{\color{blue}{e^{x \cdot x}}}{e^{1}} \]
    8. exp-1-eN/A

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{\mathsf{E}\left(\right)}} \]
    9. lower-E.f64100.0%

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{e}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e}} \]
  4. Taylor expanded in x around 0

    \[\leadsto \frac{\color{blue}{1 + {x}^{2}}}{e} \]
  5. Step-by-step derivation
    1. lower-+.f64N/A

      \[\leadsto \frac{1 + \color{blue}{{x}^{2}}}{e} \]
    2. lower-pow.f6476.0%

      \[\leadsto \frac{1 + {x}^{\color{blue}{2}}}{e} \]
  6. Applied rewrites76.0%

    \[\leadsto \frac{\color{blue}{1 + {x}^{2}}}{e} \]
  7. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \frac{1 + \color{blue}{{x}^{2}}}{e} \]
    2. lift-pow.f64N/A

      \[\leadsto \frac{1 + {x}^{\color{blue}{2}}}{e} \]
    3. pow2N/A

      \[\leadsto \frac{1 + x \cdot \color{blue}{x}}{e} \]
    4. +-commutativeN/A

      \[\leadsto \frac{x \cdot x + \color{blue}{1}}{e} \]
    5. add-flipN/A

      \[\leadsto \frac{x \cdot x - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}}{e} \]
    6. metadata-evalN/A

      \[\leadsto \frac{x \cdot x - -1}{e} \]
    7. lower--.f64N/A

      \[\leadsto \frac{x \cdot x - \color{blue}{-1}}{e} \]
    8. lower-*.f6476.0%

      \[\leadsto \frac{x \cdot x - -1}{e} \]
  8. Applied rewrites76.0%

    \[\leadsto \frac{x \cdot x - \color{blue}{-1}}{e} \]
  9. Add Preprocessing

Alternative 6: 50.8% accurate, 9.3× speedup?

\[\frac{1}{e} \]
(FPCore (x)
  :precision binary64
  (/ 1.0 E))
double code(double x) {
	return 1.0 / ((double) M_E);
}
public static double code(double x) {
	return 1.0 / Math.E;
}
def code(x):
	return 1.0 / math.e
function code(x)
	return Float64(1.0 / exp(1))
end
function tmp = code(x)
	tmp = 1.0 / 2.71828182845904523536;
end
code[x_] := N[(1.0 / E), $MachinePrecision]
\frac{1}{e}
Derivation
  1. Initial program 100.0%

    \[e^{-\left(1 - x \cdot x\right)} \]
  2. Step-by-step derivation
    1. lift-exp.f64N/A

      \[\leadsto \color{blue}{e^{-\left(1 - x \cdot x\right)}} \]
    2. lift-neg.f64N/A

      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}} \]
    3. lift--.f64N/A

      \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(1 - x \cdot x\right)}\right)} \]
    4. sub-negateN/A

      \[\leadsto e^{\color{blue}{x \cdot x - 1}} \]
    5. exp-diffN/A

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e^{1}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e^{1}}} \]
    7. lower-exp.f64N/A

      \[\leadsto \frac{\color{blue}{e^{x \cdot x}}}{e^{1}} \]
    8. exp-1-eN/A

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{\mathsf{E}\left(\right)}} \]
    9. lower-E.f64100.0%

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{e}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e}} \]
  4. Taylor expanded in x around 0

    \[\leadsto \frac{\color{blue}{1}}{e} \]
  5. Step-by-step derivation
    1. Applied rewrites50.8%

      \[\leadsto \frac{\color{blue}{1}}{e} \]
    2. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2025258 
    (FPCore (x)
      :name "exp neg sub"
      :precision binary64
      (exp (- (- 1.0 (* x x)))))