Multiple cases

Report a typo

In her program, Kate wants to use the following function:

f(x)={x2+1if x01x2if 0<x<1x21if x1f(x) = \begin{cases} x ^ 2 + 1 & \quad \text{if } x \leq 0\\ 1\over{x ^ 2} & \quad \text{if } 0 < x < 1\\ x^ 2 - 1 & \quad \text{if } x \geq 1 \end{cases}

The template for this function is defined below. Your task is to create additional functions (one for each case) and complete f(x) by calling the additional functions and returning their values. The additional functions are named f1(x), f2(x), and f3(x).

You need to return the values returned by additional functions. You do NOT need to work with the input or print anything.

Sample Input 1:

1

Sample Output 1:

0.0

Sample Input 2:

0.1

Sample Output 2:

99.99999999999999
Write a program in Python 3
def f1(x):
...


def f2(x):
...


def f3(x):
...


def f(x):
if x <= 0:
...
elif 0 < x < 1:
...
else:
...
___

Create a free account to access the full topic