Ask Your Question

# Run LCM fractions

I am doing some matrix multiplications, and as result I get Now see position 1,1 of the matrix: I want SageMath to return me a result that has only one fraction (using LCM), not two fractions. Which command should I use?

edit retag close merge delete

## 1 answer

Sort by » oldest newest most voted

Rational fractions are not simplified by default

sage: x = SR.var('x')
sage:  f = 1/(x-2) + 1/(x-3)
sage: f
1/(x - 2) + 1/(x - 3)


If you want to get one fraction just do

sage: f.simplify_rational()
(2*x - 5)/(x^2 - 5*x + 6)


The same manipulation applies for matrices

sage: m = matrix(2, [1/x, 1/(x+1), 1/(x+1), 1/x])
sage: m2 = m*m
sage: m2
[1/(x + 1)^2 + 1/x^2       2/((x + 1)*x)]
[      2/((x + 1)*x) 1/(x + 1)^2 + 1/x^2]
sage: m2.simplify_rational()
[(2*x^2 + 2*x + 1)/(x^4 + 2*x^3 + x^2)                           2/(x^2 + x)]
[                          2/(x^2 + x) (2*x^2 + 2*x + 1)/(x^4 + 2*x^3 + x^2)]

more

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2015-12-30 09:12:07 -0500

Seen: 53 times

Last updated: Dec 30 '15