frac
Fractional part of a symbolic number or expression.
Category: symbolic/symbolic
Syntax
f = frac(x)
Returns x - fix(x): the part after the decimal point, with the sign of x.
Description
The fractional part keeps the sign of the argument, so frac(7/3) is 1/3 and frac(-7/3) is -1/3. For a symbolic variable the result stays unevaluated as x - fix(x). Unlike mod(x, 1), which is never negative, frac is odd in its argument.
Input arguments
x- Symbolic number, variable or expression.
Output arguments
f- Symbolic result, exact for rational input.
Example
Fractional parts
frac(sym(7)/3)
frac(sym(-7)/3)
syms x
frac(x)
Output
ans = 1/3
ans = -1/3
ans = x - fix(x)
Notes
frac accepts only symbolic arguments in MatLivre; a plain double raises an error. Use sym first.