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

fix: define derivatives of ssqrt, scbrt, slog #1273

Merged

Conversation

AayushSabharwal
Copy link
Contributor

Expressions returned from symbolic_solve would not work with expand_derivatives prior to this change.

@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.45%. Comparing base (47cfd60) to head (6aa6759).
Report is 110 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1273       +/-   ##
===========================================
+ Coverage    8.30%   80.45%   +72.14%     
===========================================
  Files          46       47        +1     
  Lines        4549     4641       +92     
===========================================
+ Hits          378     3734     +3356     
+ Misses       4171      907     -3264     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChrisRackauckas
Copy link
Member

Expressions returned from symbolic_solve

Why not fix that?

@AayushSabharwal
Copy link
Contributor Author

AayushSabharwal commented Sep 14, 2024

This does fix the derivatives. The intention with ssqrt etc being used in symbolic_solve (as per the comment) is to represent the sqrt of negative/complex numbers covariantly. For example, the roots of a quadratic could by complex depending on the coefficients, and if sqrt is used it would just error if evaluated with coefficients that result in complex roots.

@ChrisRackauckas
Copy link
Member

The problem isn't the derivatives, so why does this fix the derivatives?

@AayushSabharwal
Copy link
Contributor Author

The implicit constraints are a different issue. This fixes taking the derivative of expressions returned from symbolic_solve.

Before:

julia> Symbolics.derivative_idx((Symbolics.ssqrt(64+ 64z^2)), 1)
Symbolics.NoDeriv()

After:

julia> Symbolics.derivative_idx((Symbolics.ssqrt(64+ 64z^2)), 1)
1 / (2(64 + 64(z^2))

@ChrisRackauckas
Copy link
Member

Why just the derivative expressions instead of the expressions?

@AayushSabharwal
Copy link
Contributor Author

I'm not sure I follow 😅 the expressions themselves are fine, ssqrt is necessary to handle complex roots.

@ChrisRackauckas ChrisRackauckas merged commit 499a98b into JuliaSymbolics:master Oct 6, 2024
11 checks passed
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

Successfully merging this pull request may close these issues.

3 participants