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

Ln1Exp and other numerical optimizations #4

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Federerer
Copy link
Contributor

Hi, I remember that one time we had a conversation about how to handle numerical optimizations e.g. for ln(1 + exp(x)) stuff. So, I tested it. Implementation is rather simplistic, and I've just added some code to the CompileExpression visitor, but it should be probably done in some more organized way (e.g. separate visitor per optimization). I was wondering if it's possible to use SubstituteTransform for that? But this is more like a run-time optimization, and it fits better for the compilation step. I've also tried adding Ln1Exp function to the global namespace directly, so it can be used in models, but it causes many problems (e.g. with differentiation). BTW, that's why I had to add a linear extension to the exp function, because without Call.If in triode models, Computer Algebra produces different results, containing exp function calls in derivatives, which wasn't the case in old version because of how derivatives are handled for function containing if expression 😉

new SubstituteTransform("D[If[c, t, f], x]", "If[c, D[t, x], D[f, x]]")

Anyway, I hope that you can point me in the right direction with this 😄

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.

1 participant