(FPCore (x) :precision binary64 (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))
(FPCore (x) :precision binary64 (+ (* -12.0 x) (+ 3.0 (* 9.0 (pow x 2.0)))))
double code(double x) {
return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
double code(double x) {
return (-12.0 * x) + (3.0 + (9.0 * pow(x, 2.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 3.0d0 * ((((x * 3.0d0) * x) - (x * 4.0d0)) + 1.0d0)
end function
real(8) function code(x)
real(8), intent (in) :: x
code = ((-12.0d0) * x) + (3.0d0 + (9.0d0 * (x ** 2.0d0)))
end function
public static double code(double x) {
return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
public static double code(double x) {
return (-12.0 * x) + (3.0 + (9.0 * Math.pow(x, 2.0)));
}
def code(x): return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)
def code(x): return (-12.0 * x) + (3.0 + (9.0 * math.pow(x, 2.0)))
function code(x) return Float64(3.0 * Float64(Float64(Float64(Float64(x * 3.0) * x) - Float64(x * 4.0)) + 1.0)) end
function code(x) return Float64(Float64(-12.0 * x) + Float64(3.0 + Float64(9.0 * (x ^ 2.0)))) end
function tmp = code(x) tmp = 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0); end
function tmp = code(x) tmp = (-12.0 * x) + (3.0 + (9.0 * (x ^ 2.0))); end
code[x_] := N[(3.0 * N[(N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] - N[(x * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(-12.0 * x), $MachinePrecision] + N[(3.0 + N[(9.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
-12 \cdot x + \left(3 + 9 \cdot {x}^{2}\right)
Results
| Original | 0.2 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
Initial program 0.2
Simplified0.1
Taylor expanded in x around 0 0.1
Final simplification0.1
herbie shell --seed 2022210
(FPCore (x)
:name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:herbie-target
(+ 3.0 (- (* (* 9.0 x) x) (* 12.0 x)))
(* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))