Skip to content

Instantly share code, notes, and snippets.

@tswedish
Last active May 26, 2020 20:39
Show Gist options
  • Save tswedish/1d85741021961a9f7015857912b7e530 to your computer and use it in GitHub Desktop.
Save tswedish/1d85741021961a9f7015857912b7e530 to your computer and use it in GitHub Desktop.
def __add__(self, other):
if isinstance(other, self.__class__):
return Dual(self.value + other.value, self.derivative + other.derivative)
else:
return self + Dual(other)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment