Question: Must be solved in python What I have so far and it works for part 1 but not part 2. aka it works when givin
Must be solved in python

What I have so far and it works for part 1 but not part 2. aka it works when givin a scalor but not an array
import math import numpy as np
def tanc(x): if x != 0: tanc = (np.tan(x)/x) return tanc else: tanc = 1.0 return tanc I get an error for "Unit test: tanc ufunc" that reads Fix the following exception (for tanc): The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Solve the following problems. Use numpy and numpy arrays when possible. tanc function Define the function tanca := as a Python function tanc(x). 1. Note that the function value at x = 0 is well defined lim tancc = 1. 20 Your function should take this into account. 2. Your function should behave like a numpy ufunc, i.e., it should be possible to use a numpy array as an argument and then it should return an array of the same size in which tanc() was applied element-wise. For example: >>> X = np.pi*np.array([0, 0.25, 1]) >>> tanc (X) array([ 1.0, 1.27323954e+00, -3.89817183e-17]) Note: Getting (2) to work is much harder than (1). Try to get (1) to work first (the initial tests only test scalar arguments)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
