Skip to content

Commit

Permalink
Merge a2d0ed7 into d3840c1
Browse files Browse the repository at this point in the history
  • Loading branch information
BGroever committed Dec 9, 2018
2 parents d3840c1 + a2d0ed7 commit 9911d5c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 190 deletions.
189 changes: 0 additions & 189 deletions Test.ipynb

This file was deleted.

19 changes: 18 additions & 1 deletion autodiff/admath/admath.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def sin(x):
def cos(x):
"""Calculate cosine of the input
Keyword arguments:
Keyword arguments:numpy.tan
x -- a real number or a dual number
Return:
Expand All @@ -33,6 +33,23 @@ def cos(x):
else:
return np.cos(x)

def tan(x):
"""Calculate tangent of the input
Keyword arguments:
x -- a real number or a dual number
Return:
the tanget value
"""
if (isinstance(x,Dual)):
x.der = 1/np.cos(x.val)**2*x.der
x.val = np.tan(x.val)
return x
else:
return np.tan(x)


def log(x):
"""Calculate the natural log of the input
Expand Down
7 changes: 7 additions & 0 deletions test/test_admath.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def test2__cos_fn__():
assert np.cos(test) == f.val
assert -1*np.sin(test) == f.der

def test1__tan_fn__():
x = Dual(0)
f = admath.tan(x)
assert f.val == 0
assert f.der == 1
assert admath.tan(0) == 0


def test_log_fn__():
tests = np.linspace(1,100,15)
Expand Down

0 comments on commit 9911d5c

Please sign in to comment.