First time here? Check out the FAQ!

Ask Your Question
0

Simplify_full() and collect() together

asked 2 years ago

Boyko_Bu gravatar image

updated 2 years ago

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.

Preview: (hide)

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 ( 2 years ago )

I meant the former, I corrected

Boyko_Bu gravatar imageBoyko_Bu ( 2 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 2 years ago

Emmanuel Charpentier gravatar image

updated 2 years ago

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 :

(cf22cf+f2c2f)(f22f1)2cf22cf+f2cf2

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 ?

Preview: (hide)
link

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 ( 2 years ago )

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 ( 2 years ago )

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 ( 2 years ago )

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 ( 2 years ago )

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: 2 years ago

Seen: 491 times

Last updated: Dec 15 '22