Assuming you are asking the question in the title (and assuming that you
can somehow use this answer written in english):
I suspect the issue here is that the engine responsible for simplifying
symbolic expressions prefers the denominator to be "monic" and that it
orders the variables alphabetically. Hence, it wants the coefficient in
front of "k" to be 1 in the denominator and not the one in front of "n". If
you change your example to
```
var("n,p")
-(n+1)/(p-n-1)
```
you see that it rewrites it in the form you desire (albeit with a p in the
place of k).
On Tuesday, 15 July 2025 at 23:09:01 UTC-7 [email protected] wrote:
> 我想知道为什么下面的代码以 -(n + 1)/(k - n - 1) 的形式计算结果。有没有办法让它返回类似于 (n + 1)/(n - k +
> 1) 的形式?
> '''python
> _ = var('k n')
> 假设 (n > k)
> 假设 (n - k + 1 > 0)
> 结果 = (n + 1)/(n - k + 1)
> 结果
> ```
> 提前感谢您的帮助!
>
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/sage-support/a4a1b05c-18dc-44fc-b6d1-73413853d1c0n%40googlegroups.com.