How to Use SymPy to calculate definite integral for Absolute value function / |x|?

Hi all,

another integral problem, I thought this could be done to calculate the simple:

\int_{-2}^{2} |x| \ dx

with this code:


x = symbols("x")

f(x) = abs(x)
integrate(f, (x, -2, 2))

The errors:

LoadError: MethodError: no method matching integrate(::typeof(f), ::Tuple{Sym, Int64, Int64})
Closest candidates are:
** integrate(::Function) at ~/.julia/packages/SymPy/7cg6m/src/mathfuns.jl:80**
** integrate(::Function, ::Number, ::Number) at ~/.julia/packages/SymPy/7cg6m/src/mathfuns.jl:76**
** integrate(::SymPy.SymbolicObject, ::Any…; kwargs…) at ~/.julia/packages/SymPy/7cg6m/src/importexport.jl:102**

x = symbols("x")

f(x) = abs(x)

integrate(f(x), (x, -2, 2))
4