Skip to content

expand_derivatives returns float expression #736

Open
@karlwessel

Description

@karlwessel

The following MWE demonstrates a case where expand_derivatives returns a floating point constant instead of a rational:

julia> using Symbolics

julia> @variables a x
2-element Vector{Num}:
 a
 x

julia> ex = exp(a*x)/(2a)
exp(a*x) / (2a)

julia> D = Differential(x)
Differential(x)

julia> expand_derivatives(D(D(ex)))
0.5a*exp(a*x)

Note that expanding the derivative of the manual input of the result of the inner derivative correctly uses an rational:

julia> expand_derivatives(D(ex))
exp(a*x) / 2

julia> expand_derivatives(D(exp(a*x)/2))
(1//2)*a*exp(a*x)

This is likely because the manual input gets automatically changed to $\frac 12 \exp(ax)$ but the result of the expanded inner derivative is $\exp(ax)/2$.

Tested with Symbolics v6.22.1 and v6.10.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions