Partial derivative at a given point >>> func = lambda x, y: x*y + sin(x) >>> point = (2.5, 3.5) >>> partial(func, point, 0) # Partial with respect to x 2.6988563844530664 >>> partial(func, point, 1) # Partial with respect to y
(func, point, index)
| 179 | ## Vector Functions ###################################################### |
| 180 | |
| 181 | def partial(func, point, index): |
| 182 | ''' Partial derivative at a given point |
| 183 | |
| 184 | >>> func = lambda x, y: x*y + sin(x) |
| 185 | >>> point = (2.5, 3.5) |
| 186 | >>> partial(func, point, 0) # Partial with respect to x |
| 187 | 2.6988563844530664 |
| 188 | >>> partial(func, point, 1) # Partial with respect to y |
| 189 | 2.5 |
| 190 | |
| 191 | ''' |
| 192 | return d(func(*[Num(x, i==index) for i, x in enumerate(point)])) |
| 193 | |
| 194 | def gradient(func, point): |
| 195 | ''' Vector of the partial derivatives of a scalar field |
no test coverage detected