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

Passing function to derivative results in zero #1085

Open
kapple19 opened this issue Mar 7, 2024 · 5 comments · May be fixed by #1257
Open

Passing function to derivative results in zero #1085

kapple19 opened this issue Mar 7, 2024 · 5 comments · May be fixed by #1257

Comments

@kapple19
Copy link
Contributor

kapple19 commented Mar 7, 2024

Not sure if this is a bug, but I think this should either throw an error or be fixed.

Setup:

using Symbolics: derivative
f(x) = x^2
@variables x

and then

derivative(f, x)

gives 0,

derivative(f(x), x)

gives Num(2x).

The former should error or be fixed, right?

@ChrisRackauckas
Copy link
Member

Yes, we should make it error on non-Num or BasicSymbolic

@kapple19
Copy link
Contributor Author

Would it be appropriate to try and feed x to f instead of erroring?

@ChrisRackauckas
Copy link
Member

Yeah we can make a dispatch for ::Function that just feeds it in and then calls derivative. And then another catch-all dispatch for ::Any that checks if it's symbolic in some form and uses it, otherwise it errors saying derivative is not supported on typeof(f).

@kapple19
Copy link
Contributor Author

kapple19 commented Sep 3, 2024

What do you mean by "symbolic in some form"? Is Complex{Num} an example?

@ChrisRackauckas
Copy link
Member

Union{Num, BasicSymbolic}

ChrisRackauckas added a commit that referenced this issue Sep 4, 2024
Fix false positive result of passing a `Function` to `derivative`
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 a pull request may close this issue.

2 participants