# Simplify_full() and collect() together

Dear all,

I am a novice with sagemath, and I use only a very small subset of its functionalities. I need to simplify the following expression, without using definitions:

var('c,f')
p_star_1 = ( (c+1)*f^2 - (2*c +1)*f - c - f ) / 2*(f^2-*2*f-1)

Here, I report the output of  p_star_1, which in the real program is p_star_1 = something.simplify_full(). I would like to express this as:

p_star_1 = c/2 + (2-f)*(1+ f)/(2*(1+2*f-f^2))

But using collect.(c) is not sufficient! How can I do this?

EDIT: I corrected the expression again, sorry.

edit retag close merge delete

Your expression p_star_1 = ( (c+1)*f^2 - (2*c +1)*f - c - f ) / 2*(f^2-*2f-1) is not accepted by Sage. Do you mean p_star_1 = ( (c+1)*f^2 - (2*c +1)*f - c - f ) / 2*(f^2-2*f-1) ? Or perhaps p_star_1 = ( (c+1)*f^2 - (2*c +1)*f - c - f ) / 2*(f^2-2*f(-1)) (not quite the same thing...).

I am not a Sibyl... `

( 2022-12-15 13:33:49 +0200 )edit

I meant the former, I corrected

( 2022-12-15 15:41:17 +0200 )edit

Sort by » oldest newest most voted

p_star_1 znd the expression you seek are not equal :

sage: SEx=c/2 + (f^2  - f - 2)/(2*(f^2  - 2*f - 1 ))
sage: (p_star_1-SEx).expand().is_zero()
False

which is more obvious if you ask a typeset form :

sage: view((p_star_1/SEx).expand().factor())

which displays :

$$\frac{{\left(c f^{2} - 2 \, c f + f^{2} - c - 2 \, f\right)} {\left(f^{2} - 2 \, f - 1\right)}^{2}}{c f^{2} - 2 \, c f + f^{2} - c - f - 2}$$

The problem might be

sage: p_star_1.operands()
[(c + 1)*f^2 - (2*c + 1)*f - c - f, f^2 - 2*f - 1, 1/2]
sage: p_star_1.operands()[0].collect(f)
(c + 1)*f^2 - 2*(c + 1)*f - c

Maybe another typo ?

more

Yeah, probably, I updated, I am copying manually from Jupyter to here, not simple, let me know if now works, I can't see any other error at the moment.

( 2022-12-15 18:19:46 +0200 )edit

I am copying manually from Jupyter to here

Copy 'n paste doesn't work ?

let me know if now works.

<fuming>

The present site lets you expect that some people will take time to build answers to your questions. YOU CAN'T expect them to guess what the question is...

</fuming>

( 2022-12-16 08:22:16 +0200 )edit

You can fume as much as you want, OR, you can imagine do I feel losing A WHOLE DAY working with software that CANNOT RECOGNIZE that two terms that sum to one ARE a simplification. Hence, DON'T be arrogant just because you know I am a newbie, understand my position, and look at the question now. If it still doesn't work, I'll update again.

( 2022-12-16 11:01:40 +0200 )edit

The two expressions (in their various versions) you gave us are NOT a simplification of each other.

Try to copy'n paste the expressions printed in Jupyter to your message.

Yelling I'm arrogant won't fix your copy n'paste result...

( 2022-12-17 07:49:39 +0200 )edit