Skip to content

implement SymPy Piecewise equivalent #20191

Closed
@rwst

Description

@rwst

This shows an equivalent to SymPy's Piecewise is missing in Sage:

        sage: _ = var('y, z')
        sage: (x^y - z).integrate(y)
        -y*z + x^y/log(x)
        sage: (x^y - z).integrate(y, algorithm="sympy")  # see Trac #14694
        Traceback (most recent call last):
        ...
        AttributeError: 'ExprCondPair' object has no attribute '_sage_'

SymPy-1.0:
>>> integrate(x**y-z,y)
       ⎛⎧  y     for log(x) = 0⎞
       ⎜⎪                      ⎟
       ⎜⎪   y                  ⎟
 -y⋅z + ⎜⎨  x                   ⎟
       ⎜⎪──────    otherwise   ⎟
       ⎜⎪log(x)                ⎟
       ⎝⎩                      ⎠

Piecewise in SymPy is a held function of ExprCondPair arguments. It would be a superset of our piecewise. The name should not be confusable, a suggestion is if_then([(log(x)==0, y), (x^y/log(x), 1)]).

When it is implemented a SymPy patch should be done for the _sage_ method.

EDIT: Maxima 5.38.1 returns a similar function for some integrals.

Depends on #23820

CC: @mforets

Component: symbolics

Author: Ralf Stephan

Branch/Commit: 1929337

Reviewer: Travis Scrimshaw

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions