MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __pow__

Method __pow__

maths/dual_number_automatic_differentiation.py:82–92  ·  view source on GitHub ↗
(self, n)

Source from the content-addressed store, hash-verified

80 raise ValueError
81
82 def __pow__(self, n):
83 if n < 0 or isinstance(n, float):
84 raise ValueError("power must be a positive integer")
85 if n == 0:
86 return 1
87 if n == 1:
88 return self
89 x = self
90 for _ in range(n - 1):
91 x *= self
92 return x
93
94
95def differentiate(func, position, order):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected