Question

Using python 3 Define a Python function that takes in a value (x) and evaluates f(x):...

Using python 3

Define a Python function that takes in a value (x) and evaluates f(x):

f(x)=(1/(1+x^2))

Use this function to create a plot of f(x) for 0≤x≤10 using matplotlib.pyplot

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

import matplotlib.pyplot as plt #importing packages

import numpy as np

def f(x): #function f which takes parameter x

return 1/(1+x**2) #computinf f(x) and returns the value

x=np.arange(0,11,1) #parameter1 start parameter2 end parameter 3 step size

#generate values from 0 to 10 using numpy arange will generate list of numbers from start to end using step size

y=list(map(f,x))

#using map function call f map will take each value in list x and call the function with that value and stores the result

plt.plot(x,y) #finally plot the graph

plt.show()

Code and Output Screenshots:

Note : if you have any queries please post a comment thanks a lot..always available to help you..

Add a comment
Know the answer?
Add Answer to:
Using python 3 Define a Python function that takes in a value (x) and evaluates f(x):...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT