I'm coding a function for my TI-Nspire CAS calculator. I have two parts of an expression: (x+2)^2
and +3
. When the expressions are joined the result is expanded to x^2+4x+7
while I need it to remain as (x+2)^2+3
.
I've tried making both parts strings and them converting them back to expressions after joining but, this results in the same unwanted expansion.
The best I can do is return the two strings (each term) concatenated, which is gosh ugly: "(x+2)^2" + "3"
Is there anyway to prevent this expansion?
It undermines the entire function (which completes the square)!
For the record, the expression is expanded even if concatenated with a string.
(x+2)^2 + "3"
returns
x^2 + 2x + "3" + 4
(which I found really bizarre)