Skip to content

Conversation

@AleMorales
Copy link

I have added a few lines to differentiate.jl in order to support analytical differentiation of the ifelse function which can be used to define piecewise functions. It simply returns a new ifelse function with the derivative of the second and third arguments and it also works with nested ifelse.

It does not check whether the piecewise function is differentiable and continuous (it is up to the user to make sure that is the case).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use an in-line expression instead of parse, e.g.,

:(ifelse($(args[1]), $(differentiate(args[2],wrt)),$(differentiate(args[3],wrt))))

@AleMorales
Copy link
Author

I switched to using an expression as suggested, much more beautiful now, thanks.

@ivarne
Copy link
Collaborator

ivarne commented Dec 16, 2014

Looks good to me.

@johnmyleswhite
Copy link
Collaborator

Would you mind a quick squashing rebase? Happy to merge this right after.

…suming it was used to define piecewise functions).

Use inline expression instead of parse for differentiation of ifelse funtion
@AleMorales
Copy link
Author

Done, I "squashed" everything into a single commit.

johnmyleswhite added a commit that referenced this pull request Dec 16, 2014
Add support to calculate analytical derivative of ifelse function
@johnmyleswhite johnmyleswhite merged commit 0e0f775 into JuliaMath:master Dec 16, 2014
@johnmyleswhite
Copy link
Collaborator

Great. Thanks!

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.

4 participants