Skip to content

.is_zero() method raises error for symbolic expression involving derivative #6523

@golam-m-hossain

Description

@golam-m-hossain

If a symbolic expression contains  symbolic derivative then
checking whether it is zero, raises error:

sage: x.diff(x,2).is_zero()
True

sage: f(x) = function('f',x)
sage: f(x).diff(x).is_zero()
....
NotImplementedError: derivative

This fails because new symbolics tries to convert it to maxima
expression for checking the relation.

Update:

***** A patch to fix the issue is attached. The patch
adds a new method ".has_fderivative()" for symbolic expressions
and in __nonzero__ method adds a check whether it has fderivative.

Comments (for future works):
A simple timing comparison that illustrates why we should
avoid calling maxima to assert nonzero even for symbolic
functions

sage: f(x) = function('f',x)
sage: timeit('sin(f(x)).is_zero()')
5 loops, best of 3: 85.8 ms per loop
sage: timeit('sin(f(x).diff(x)).is_zero()')
625 loops, best of 3: 132 µs per loop

It seems pynac is 400 times faster than maxima in this case.

CC: @mwhansen

Component: symbolics

Author: Burcin Erocal

Reviewer: Mike Hansen

Merged: sage-4.3.rc0

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions