MATLAB: Indefinite integral of a reciprocal function

absoluteindefinite integralMATLABreciprocal functionSymbolic Math Toolbox

I'd like to numerically solve an integral of the form of 1/x, by using the symbolic toolbox. The answer be ln|x| + c. When I however use the symbolic toolbox to integrate the function:
syms x
integral = int(@(x) 1/x, x)
integral =
log(x)
which is clearly not the answer, as it misses the absolute signs. Am I missing something or is it otherwise possible to include the absolute signs?
I'll appreciate for any help. Thanks!

Best Answer

>> syms x real ; integral = real( int(@(x) 1/x, x) )
integral =
log(abs(x))
Related Question