Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions

Question

Evaluate employees readiness for training. page 275

Answered: 1 week ago