Ask Your Question
0

Simplify_full() and collect() together

asked 2022-12-15 11:06:06 +0200

Boyko_Bu gravatar image

updated 2022-12-15 18:18:13 +0200

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 flag offensive close merge delete

Comments

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... `

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-12-15 13:33:49 +0200 )edit

I meant the former, I corrected

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

1 Answer

Sort by » oldest newest most voted
0

answered 2022-12-15 17:57:36 +0200

Emmanuel Charpentier gravatar image

updated 2022-12-15 17:58:05 +0200

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 ?

edit flag offensive delete link more

Comments

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.

Boyko_Bu gravatar imageBoyko_Bu ( 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>

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 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.

Boyko_Bu gravatar imageBoyko_Bu ( 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...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-12-17 07:49:39 +0200 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2022-12-15 11:06:06 +0200

Seen: 327 times

Last updated: Dec 15 '22