# calc and evaluation of rational fractions

I am new to using calc. Is it possible that the evaluation of ((x-1)/(x+1))+((x+1)/(x-1))=> returns ((x-1)/(x+1))+((x+1)/(x-1))=>(2 x^2 + 2) / (x^2 - 1)

• Looking at the Simplifying Formulas chapter of the Calc manual, I didn't find anything that would do that. Jun 26 '19 at 19:19
• I think it should be possible since nrat can produce the output. Jun 27 '19 at 7:13
• Indeed - I didn't find nrat because I didn't look at the right place - of course, after @Tobias pointed it out, my hindsight increased to 20/20 :-). Jun 27 '19 at 13:26

Original question:

Is it possible that the evaluation of ((x-1)/(x+1))+((x+1)/(x-1))=> returns ((x-1)/(x+1))+((x+1)/(x-1))=>(2 x^2 + 2) / (x^2 - 1)

The calc function nrat transforms its expression argument to a rational expression.

You can try nrat(((x-1)/(x+1))+((x+1)/(x-1))) with
M-: (calc-eval "nrat(((x-1)/(x+1))+((x+1)/(x-1)))")

The result is:

(2*x^2 + 2) / (x^2 - 1)


If you prefer to work with the Calc stack you can put ((x-1)/(x+1))+((x+1)/(x-1)) on the stack with the help of algebraic input '. Afterwards type a for Algebraic simplifications and n for Normalize rational expression.

• Nice! I missed that. Jun 27 '19 at 4:43
• I know that, but that doesnt answer my question. I want to have an output like 2:3+3:4=> : \evalto \frac{2}{3} + \frac{3}{4} \to \frac{17}{12} in LaTeX mode. Jun 27 '19 at 6:32
• But that is NOT what you asked. Jun 27 '19 at 13:28
• Sorry, but I do not speak English fluently. The workaround I found is to evaluate (for example) $((x - 1) / (x + 1)) + ((x + 1) / (x - 1)) = nrat (((x - 1) / (x + 1)) + ((x + 1) / (x - 1)))$ which returns $frac {x - 1} {x + 1} + \ frac {x + 1} {x - 1} = \ frac {2 x ^ 2 + 2} {x ^ 2 - 1}$ in a LaTeX document with embedded calc. I think it can exist better solution. Jun 30 '19 at 14:20