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

expand_derivatives returns float expression #1397

Open
karlwessel opened this issue Jan 8, 2025 · 0 comments
Open

expand_derivatives returns float expression #1397

karlwessel opened this issue Jan 8, 2025 · 0 comments

Comments

@karlwessel
Copy link
Contributor

karlwessel commented Jan 8, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant