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
  • i need Matlab code asap Write a program that evaluates the function f(x) = tan’x +...

    i need Matlab code asap Write a program that evaluates the function f(x) = tan’x + x - 2 between -27 and 27 in steps of 1/10 and plots the results. Create a function handle for your function, and use function feval to evaluate your function at the specified points. 2. Write a program that locates the zeros of the function f(x) = cos éx -0.25 between 0 and 27. Use the function fzero to actually locate the zeros of...

  • Python: using a stack, implement a function that takes in an arithmetic expression, and evaluates it,...

    Python: using a stack, implement a function that takes in an arithmetic expression, and evaluates it, supported operations are + and -, which have same precedence. Note: one way to do it is to scan the entire expr pushing numbers onto val-stack and operations on op-stack until tokens in expr are done. Then, use a loop to pop two numbers from val-stack and one operation from op-stack, evaluate, and push results back to val-stack, until op-stack is empty.

  • Define a Python function that takes a list and returns the length of the list using...

    Define a Python function that takes a list and returns the length of the list using map and sum.

  • Using python 3.6.0 Write a function, called cubic, which takes in two parameters, say x and...

    Using python 3.6.0 Write a function, called cubic, which takes in two parameters, say x and y and computes the following formula: x3 + x + y and returns the computed value. Sample output 1: Enter x: 2 Enter y: 1 The value of the function is : 11 Sample output 2: Enter x: 1 Enter y: 3 The value of the function is : 5

  • must be python programming. consider function f(x) = sin(x) in the range of 0to pi. create...

    must be python programming. consider function f(x) = sin(x) in the range of 0to pi. create a python code to calculate f’ (derivative of f(x)) in this range and plot these points. calculate the error at all the discrete points. Please do not use Numpy you can use matplotlib

  • Python code define a function car that takes 'swift' as a parameter function should count how...

    Python code define a function car that takes 'swift' as a parameter function should count how many letters in the string function should return a dictionary where key is lower case alpha caracter and value is the number of times that character appears in sentence. ex- input- that big car is so expensive output- 't':1, 'h':1, 'a':2, 'b':1, 'i':3,......

  • 3. Define the function f : R2 + R by 1 if x > 0 f(x)...

    3. Define the function f : R2 + R by 1 if x > 0 f(x) = { -1 if x >0 10 otherwise. and and X < y < x + 1, +1 < y < X + 2, Show that [ f(x,y) (da) \(dy) + | | f(x,y) A(dy) A(da). Why is this not a contradiction to Fubini's Theorem?

  • Using python, Write a function that takes 3 inputs, x, y, and z, but make y...

    Using python, Write a function that takes 3 inputs, x, y, and z, but make y and z default parameters, with initial values of 5 and 12. Have the function return the sum of x, y, and z

  • Problem 3. Define the function: 2+_ 0 if (z,y)#10.0) if (a,y)-(0,0) f(x, v)= (a) Graph the...

    Problem 3. Define the function: 2+_ 0 if (z,y)#10.0) if (a,y)-(0,0) f(x, v)= (a) Graph the top portion of the function using Geogebra. Does the function appear to be continuus at 0? (b) Find fz(z, y) and fy(z, y) when (z, y) #10.0) (c) Find f(0,0) and s,(0,0) using the limit definitions of partial derivatives and f,(0,0)-lim rah) - f(O,0) d) Use these limit definitions to show that fay(0,0)--1, while x(0,0)-1 (e) Can we conclude from Clairaut's theorem that()-yr(x,y) for...

  • With using Python . Write a function that: 1. Takes two arguments and returns the product...

    With using Python . Write a function that: 1. Takes two arguments and returns the product of the arguments. The return value should be of type integer. 2. Takes two arguments and returns the quotient of the arguments. The return value should be of type float. 3. Takes one argument and squares the argument. It then uses the two values and returns the product of the two arguments.(Reuse function in 1.) 4. Takes one argument and prints the argument. Use...

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