Ask Your Question
0

why is sqrt(factorial(l)*factorial(l))-factorial(l) not 0

asked 2025-03-07 12:08:14 +0100

AstroG gravatar image

updated 2025-03-07 12:39:41 +0100

Emmanuel Charpentier gravatar image

I am checking solutions of some field equations. The check requires at some point the calculation of something like sqrt(factorial(l)*factorial(l))-factorial(l) where l is a positive integer . Sage gives |l!| - l! rather than 0. It works for explicit values of l. I have also tried declaring l as a positive integer and using .canonicalize_radical() and .simplify_full() as shown in the code snippet below, which has some of the lines commented out. I'm using Sagemath 10.5 on a MacBook Pro with Sequoia 15.3.1

version()
var('l')
assume(l, 'integer')
assume(l>0)

# l = 273
x = sqrt(factorial(l)*factorial(l))-factorial(l)
#y = x.expand().canonicalize_radical().simplify_full()
#z = x.expand().simplify_full().canonicalize_radical()
pretty_print('x = \t', x)
pretty_print('y = \t' ,y)
pretty_print('z = \t', z)

How might I get round this issue, please?

edit retag flag offensive close merge delete

Comments

Edited for legibility.

If you want to quote code, indent it by four spaces (or ise the "101010" button).

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2025-03-07 12:40:47 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2025-03-07 13:17:35 +0100

Emmanuel Charpentier gravatar image

updated 2025-03-07 13:28:37 +0100

$\sqrt{x^2}$ is $x$ if and only if $x> 0$. See illustration on Sagecell.

edit flag offensive delete link more

Comments

Thank you for your help Emmanuel. That information solved my problem. Much appreciated.

AstroG gravatar imageAstroG ( 2025-03-12 20:35:14 +0100 )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

1 follower

Stats

Asked: 2025-03-07 12:08:14 +0100

Seen: 34 times

Last updated: Mar 07