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

Differentiating nested pow calls #6

Open
SergeiOssokine opened this issue Aug 4, 2021 · 2 comments
Open

Differentiating nested pow calls #6

SergeiOssokine opened this issue Aug 4, 2021 · 2 comments
Assignees

Comments

@SergeiOssokine
Copy link

Dear devs,

recently I have been trying to differentiate complicated expressions that eventually result in nested calls to pow. I find that the forward mode derivative for these cases is not taken correctly. Here is the MWE:

c_function = """
function_test(double x){
double x2 = pow(x,2);
double H = pow(x2,2);
}

deriv = acorns.autodiff(c_function, 'H', ['x'], func = 'function_test', output_filename = 'test',
     output_func = 'compute_grad_nested_pow')

This gives as the derivative (pow(pow,(2-1)) * (2 * 0 + pow * 0 * log(pow))) which looks like it's using pow as a variable instead of a function.

Computing directly the derivative of

c_function = """
function_test(double x){
double H = pow(x,4);
}

gives the correct result, (pow(x,(4-1)) * (4 * 1 + x * 0 * log(x))). Unfortunately my expressions are complicated enough that no such simplifications are possible.

@deshanadesai deshanadesai self-assigned this Aug 4, 2021
@SergeiOssokine
Copy link
Author

Dear devs,

have you had a chance to look at this?

Thanks again!

@deshanadesai
Copy link
Owner

deshanadesai commented Sep 10, 2021

Hi @SergeiOssokine , I sincerely apologize for the delay. You are right, this needs an extension to the current code to include catching FuncCall expressions. We are working on it and should be updating this soon. My apologies!

Also, please feel free to contribute: https://github.com/deshanadesai/acorns/blob/master/CONTRIBUTING.md

We would highly appreciate any help!

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

2 participants