Skip to content

Symbolic min/max #21945

@pelegm

Description

@pelegm

The Python builtins max and min are not user-friendly because they give totally wrong results on symbolic input:

sage: max(1/(1-x), 1/x)
-1/(x - 1)

There exist functions max_symbolic and min_symbolic but people generally don't know those functions. They expect max and min to "just work".

One way this puzzles users is when plotting eg the following:

sage: plot(max(1/(1-x), 1/x), (x, 0, 1), ymin=0, ymax=10))

... for which a workaround is to plot using a lambda function:

sage: plot(lambda x: max(1/(1-x), 1/x), (0, 1), ymin=0, ymax=10)

Depends on #24838

CC: @mathzeta @slel

Component: symbolics

Keywords: min, max, days79

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions