Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove simplify_radical() from simplify_full() #12737

Closed
orlitzky opened this issue Mar 23, 2012 · 44 comments
Closed

Remove simplify_radical() from simplify_full() #12737

orlitzky opened this issue Mar 23, 2012 · 44 comments

Comments

@orlitzky
Copy link
Contributor

There are a number of tickets open due to the use of simplify_radical() in simplify_full().

Removing it would fix at least,

Apply attachment: sage-trac_12737-rebased.patch and attachment: trac_12737-de.patch

CC: @jvkersch @sagetrac-navigium

Component: symbolics

Author: Michael Orlitzky

Reviewer: Karl-Dieter Crisman, Beni Keller

Merged: sage-5.12.beta0

Issue created by migration from https://trac.sagemath.org/ticket/12737

@orlitzky orlitzky added this to the sage-5.11 milestone Mar 23, 2012
@orlitzky orlitzky self-assigned this Mar 23, 2012
@orlitzky
Copy link
Contributor Author

Add the flag and update doctests.

@orlitzky
Copy link
Contributor Author

comment:1

Attachment: sage-trac_12737.patch.gz

@nbruin
Copy link
Contributor

nbruin commented Mar 23, 2012

comment:2

It's not entirely clear to me which simplifications are "safe" and which are not. Simplifying x^2/x to x is also not "safe" in the sense that equality does not hold for x=0. In many computer algebra systems, acceptable simplifications are not "safe" in this respect. By including a default unsafe=False I'm afraid you'll be raising expectations to a level that Sage does not attain (yet?).

@orlitzky
Copy link
Contributor Author

comment:3

Replying to @nbruin:

It's not entirely clear to me which simplifications are "safe" and which are not. Simplifying x^2/x to x is also not "safe" in the sense that equality does not hold for x=0. In many computer algebra systems, acceptable simplifications are not "safe" in this respect. By including a default unsafe=False I'm afraid you'll be raising expectations to a level that Sage does not attain (yet?).

It's completely heuristic: the four I chose nobody seems to have a problem with. simplify_radical, on the other hand, wreaks havoc on trivial functions and has been the cause of numerous bug reports and mailing list discussions.

In simplify, after #12650, I say that a safe simplification is one "for which we are reasonably sure that the input will be considered equivalent to the output." That's probably the best we can do for now, and I'm reasonably sure that most people would consider x^2/x equivalent to x.

As it stands, I think full_simplify sounds safe so people will assume that anyway. This fix, while not perfect, at least improves things.

@kcrisman
Copy link
Member

comment:4

It's not entirely clear to me which simplifications are "safe" and which are not. Simplifying x^2/x to x is also not "safe" in the sense that equality does not hold for x=0. In many computer algebra systems, acceptable simplifications are not "safe" in this respect. By including a default unsafe=False I'm afraid you'll be raising expectations to a level that Sage does not attain (yet?).

It's completely heuristic: the four I chose nobody seems to have a problem with.

Only in that we couldn't find Trac tickets about them.

simplify_radical, on the other hand, wreaks havoc on trivial functions and has been the cause of numerous bug reports and mailing list discussions.

In simplify, after #12650, I say that a safe simplification is one "for which we are reasonably sure that the input will be considered equivalent to the output." That's probably the best we can do for now, and I'm reasonably sure that most people would consider x^2/x equivalent to x.

I'm reasonably sure that no mathematician would consider them equivalent unless you add "almost everywhere". Simplification simplifies, hence makes it not actually the same (at least potentially). This shouldn't be controversial.

As it stands, I think full_simplify sounds safe so people will assume that anyway. This fix, while not perfect, at least improves things.

Well, everything sounds safe unless you put in the word "unsafe".

I'm pretty confused as to the relation of this to #12650. See my comments there.

I'm sympathetic to doing something about radcan, but simplification is simplification, not identity.

Doesn't it make more sense to either document fully what can go wrong with simplify_full, or to add a flag simplify_radicals or something? I think that changing behavior in this case is probably the best compromise, but probably unsafe is sending the wrong message. There isn't anything unsafe about radcan, it's just a different point of view than ours - symbolic expressions versus functions. Spend some time on the Maxima list :)

@orlitzky
Copy link
Contributor Author

comment:5

Replying to @kcrisman:

It's not entirely clear to me which simplifications are "safe" and which are not. Simplifying x^2/x to x is also not "safe" in the sense that equality does not hold for x=0. In many computer algebra systems, acceptable simplifications are not "safe" in this respect. By including a default unsafe=False I'm afraid you'll be raising expectations to a level that Sage does not attain (yet?).

It's completely heuristic: the four I chose nobody seems to have a problem with.

Only in that we couldn't find Trac tickets about them.

simplify_radical, on the other hand, wreaks havoc on trivial functions and has been the cause of numerous bug reports and mailing list discussions.

In simplify, after #12650, I say that a safe simplification is one "for which we are reasonably sure that the input will be considered equivalent to the output." That's probably the best we can do for now, and I'm reasonably sure that most people would consider x^2/x equivalent to x.

I'm reasonably sure that no mathematician would consider them equivalent unless you add "almost everywhere". Simplification simplifies, hence makes it not actually the same (at least potentially). This shouldn't be controversial.

Before our discussion on another one of these tickets, I had assumed it was not controversial that simplification had to return an equivalent expression. So it is at least a little controversial.

As it stands, I think full_simplify sounds safe so people will assume that anyway. This fix, while not perfect, at least improves things.

Well, everything sounds safe unless you put in the word "unsafe".

I'm pretty confused as to the relation of this to #12650. See my comments there.

I'm sympathetic to doing something about radcan, but simplification is simplification, not identity.

Doesn't it make more sense to either document fully what can go wrong with simplify_full, or to add a flag simplify_radicals or something? I think that changing behavior in this case is probably the best compromise, but probably unsafe is sending the wrong message. There isn't anything unsafe about radcan, it's just a different point of view than ours - symbolic expressions versus functions. Spend some time on the Maxima list :)

All expressions in sage are callable like functions, so if you have both radicals and a variable in an expression, simplify_radical() is unsafe. I.e. you're probably gonna get the wrong answer. I think marking it as unsafe is more likely to catch someone's attention than asking him to read the documentation. I almost certainly used full_simplify() for years without doing so, since I thought I knew what it was doing and had used similar functions in e.g. Mathematica. I think the problem is that it's called "simplification," not that it exists.

Either way, f.full_simplify(simplify_radicals=True) is not much better than f.full_simplify().simplify_radical()... the keyword argument is the easy way out, but I feel like it should control more than one method call if we do it. And if we remove the unsafe simplifications from full_simplify(), that seems to make simplify() redundant, too. That's the dual situation to what we'd have after #12650, but at least we could add more stuff to full_simplify() in the future to change that.

@orlitzky
Copy link
Contributor Author

comment:6

There is not consensus that this is even a good idea, so I'll leave it alone until we can discuss it further.

@orlitzky

This comment has been minimized.

@orlitzky
Copy link
Contributor Author

Changed dependencies from #12650 to none

@orlitzky
Copy link
Contributor Author

comment:7

This should be a more straight-forward proposal. I just removed simplify_radical() from simplify_full() and fixed a few doctests (details in the commit message).

One of the doctest fixes is duplicated in #12780; the doctest is wrong (missing assumptions) but we're masking that fact at the moment.

@orlitzky
Copy link
Contributor Author

Author: Michael Orlitzky

@orlitzky orlitzky changed the title Add an unsafe argument to Expression.simplify_full() Remove simplify_radical() from simplify_full() Apr 14, 2012
@orlitzky
Copy link
Contributor Author

Same patch with the functional.py doctest factored out

@orlitzky
Copy link
Contributor Author

comment:8

Attachment: sage-trac_12737-remove_radcan.patch.gz

I moved the common doctest to #12845 and removed it from this patch.

@orlitzky
Copy link
Contributor Author

Dependencies: #12845

@kcrisman
Copy link
Member

comment:9

Lest it seem weird that I'm adding to the list in the description, let it be known that I haven't necessarily changed my mind here, but fairness dictates that I point this additional example out!

@kcrisman

This comment has been minimized.

@kcrisman

This comment has been minimized.

@kcrisman

This comment has been minimized.

@orlitzky

This comment has been minimized.

@kcrisman
Copy link
Member

kcrisman commented Jul 3, 2013

Changed dependencies from #12845 to none

@kcrisman
Copy link
Member

kcrisman commented Jul 3, 2013

Reviewer: Karl-Dieter Crisman

@sagetrac-navigium
Copy link
Mannequin

sagetrac-navigium mannequin commented Jul 4, 2013

comment:22

I'm at the moment unsure how to fix this. I guess the first example that fails could just be removed since it can be numerically evaluated. But I think the second example should remain in the tutorial and should be fixed. At the moment I don't have the time to look into it. I won't be around till mid August.

@kcrisman Ich habe es vor allem als Vereinfachung bezeichnet, da es die notwendige Umformung ist, welche man für das Lösen von Exponentialgleichungen benötigt. Aus diesem Grund halte ich es auch für wichtig, dass man erwähnt, wie man eine solche Umformung machen kann.

Man könnte es aber natürlich umbennen. Ich würde es als "Zerlegung durch Benutzen der Logarithmengesetze" oder ähnlich nennen.

Natürlich wäre es schon, wenn man simplify_radical nicht separat aufführen muss, um die Sache einfach zu halten. Wenn es aber aus simplify_full fliegt, müsste man es wohl erwähnen.

@kcrisman
Copy link
Member

kcrisman commented Jul 4, 2013

comment:23

@kcrisman Ich habe es vor allem als Vereinfachung bezeichnet, da es die notwendige Umformung ist, welche man für das Lösen von Exponentialgleichungen benötigt. Aus diesem Grund halte ich es auch für wichtig, dass man erwähnt, wie man eine solche Umformung machen kann.

Man könnte es aber natürlich umbennen. Ich würde es als "Zerlegung durch Benutzen der Logarithmengesetze" oder ähnlich nennen.

Eigentlich genügt das!

Natürlich wäre es schon, wenn man simplify_radical nicht separat aufführen muss, um die Sache einfach zu halten. Wenn es aber aus simplify_full fliegt, müsste man es wohl erwähnen.

Tja...

Michael, I'll try to keep this on the front burner for finding a good fix - navigium has a good phrase we can use, and I don't really see any other way to fix this, since it does happen to be very convenient that we can use radcan in some cases to do log expansion.

@orlitzky
Copy link
Contributor Author

orlitzky commented Jul 6, 2013

comment:24

It is regrettable that there's no other way to get log simplification of things like log(8)/log(2), but simplify_radical() will do the same thing even when the argument to the log function is a complex function of, say, z.

It'd be nice to have something that worked for constants at least, but avoided e.g. #12322.

@kcrisman
Copy link
Member

kcrisman commented Jul 9, 2013

Changed reviewer from Karl-Dieter Crisman to Karl-Dieter Crisman, Beni Keller

@kcrisman

This comment has been minimized.

@kcrisman
Copy link
Member

kcrisman commented Jul 9, 2013

comment:25

I'd appreciate a quick review from navigium as to whether my German syntax is 100% correct, but this should take care of it, and conforms to what he suggested as a solution.

Patchbot, apply sage-trac_12737-rebased.patch and trac_12737-de.patch

@kcrisman
Copy link
Member

Attachment: trac_12737-de.patch.gz

@kcrisman
Copy link
Member

comment:26

Patchbot, apply sage-trac_12737-rebased.patch and trac_12737-de.patch

@sagetrac-navigium
Copy link
Mannequin

sagetrac-navigium mannequin commented Jul 10, 2013

comment:27

I think that's a great way to solve my document. Now the readers even get something extra because they are taught how to apply log rules both ways. Thanks @kcrisman for solving it.

@kcrisman
Copy link
Member

comment:28

Great. Now someone (other than me) just needs to check that it passes tests and they can set it to positive review.

@jvkersch
Copy link
Contributor

comment:29

make ptestlong does not report any errors so I'm setting this to positive review.

@jdemeyer
Copy link
Contributor

jdemeyer commented Aug 2, 2013

Merged: sage-5.12.beta0

@kcrisman

This comment has been minimized.

@kcrisman
Copy link
Member

kcrisman commented Nov 6, 2013

comment:32

Updates:

Removed

I posted updates on the ask.sagemath questions just now.

#11934 needs review.

#12322 needs to be reworded since we didn't use the "unsafe" parameter in simplify_full.

tscrim pushed a commit to tscrim/sage that referenced this issue Jun 1, 2023
* develop: (101 commits)
  Updated Sage version to 6.1.beta2
  fix latex
  fix documentation
  minor typography
  Trac 13101: mark doctest as "long time"
  trac 13101 better doctest
  Trac 13101: Fix bug in enumerate_totallyreal_fields_all
  sagemath#9706: review patch.
  trac 9706: Propose new class structure
  Symbolic Chebyshev polynomials: reviewer patch
  trac 9706: Collective patch. Bugfixes, extensions, optimizations, documentation, doctests for chebyshev_T, chebyshev_U and base class for ortho polys
  Fixing Whitespace errors
  Use bash as SHELL for build/Makefile
  allow numpy arrays in list_plot, line, points
  Trac sagemath#12322: Add a doctest for the correct behavior introduced in trac sagemath#12737.
  Trac sagemath#14186 coerce_binop errors with keyword arguments
  trac sagemath#15553: Broken links in the doc of graph/ and numerical/
  Improve handling of make targets sage, csage, extcode, scripts
  Reorded all.py to match original (so fewer changes).
  Fixed minor typo in cobminat/crystals/letters.pyx.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants