Question

Write a program that plots two functions: f(x) = x2 and g(x) = ax. Write it in such a way that the intersection points are ma

Write the code in PYTHON and please provide the full code, thank you!

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

Here is te code for you problem.

# Importing Files

import numpy as np

import matplotlib.pyplot as plt

# assigning a an arbitrary value

a = 900

# Initializing functions

x = np.arange(-1000, 1000)

f = a * np.arange(-1000, 1000)      # ax

g = np.arange(-1000, 1000) ** 2     # x^2

# Plotting Functions

plt.plot(x, f, '-')

plt.plot(x, g, '-')

# calculating intersection points and displaying on graph as X

idx = np.argwhere(np.diff(np.sign(f - g))).flatten()

plt.plot(x[idx], f[idx], 'rx')

plt.show()

Here is the screenshot of the code if the indentation is not clear.

ovou # Importing Files import numpy as np import matplotlib.pyplot as plt # assigning a an arbitrary value a = 900 # Initiali

Here is the output of the code.


Hope this helps.

Please rate the answer if you like it.

Do leave a comment.Any suggestion/query is much appreciated.

Add a comment
Know the answer?
Add Answer to:
Write the code in PYTHON and please provide the full code, thank you! Write a program...
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
  • Write a C program as follows: Single source code file Calls a function with an arbitrary...

    Write a C program as follows: Single source code file Calls a function with an arbitrary name (i.e. you name it) that accepts two arrays of the same size The function should add each element in the arrays together and place the values in a third array Each array element, each array address, and the sum are printed to the screen in tabulated format with headersI also would like to request that LOTS of comments be included, as I need...

  • Please help with this python assignment. Thank you. question 1 Write a Python program to read...

    Please help with this python assignment. Thank you. question 1 Write a Python program to read a file line by line store it into a variable. question 2 Write a Python program to read a file line by line store it into an array. question 3 Write a python program to find the longest words. question 4 Write a Python program to count the number of lines in a text file. question 5 Write a Python program to count the...

  • Please write this code in python programming and provide a screen short of the code. Reading:...

    Please write this code in python programming and provide a screen short of the code. Reading: P4E 7; Tut 7.2, 7.2.1 Upload an original Python script that satisfies the following criteria: It has at least two functions Function 1: This function has one parameter, a string containing the path to an existing text file that will be read by your function Using a with statement, the function opens the file indicated by the parameter for reading The function counts the...

  • I need this in python thank you 10.3 Code Practice Instructions Write a program that creates...

    I need this in python thank you 10.3 Code Practice Instructions Write a program that creates a 4 x 5 array called numbers . The elements in your array should all be random numbers between -30 and 30, inclusive. Then, print the array as a grid. For instance, the 2 x 2 array [[1,2],[3,4]] as a grid could be printed as: 1 2 34 Sample Output 18 -18 10 0 -7 -20 0 17 29 -26 14 20 27 4...

  • Write Python code that uses the np.split function to break up the array z created in...

    Write Python code that uses the np.split function to break up the array z created in the previous problem into four arrays named with two columns each named zOne, zTwo, zThree, and zFour. The following is the code to get z: import numpy as np x = np.array ([4,4,11,11,0,7,10,6,9,11,14,6,4,5,6],dtype='int64').reshape((3, 5)) y = np.array ([6,7,4,2,2,7,5,2,3],dtype='int64').reshape((3, 3)) z = np.concatenate([x,y],axis=1)

  • please help with the marked ones the programming language is python code. 23.16 Write an RGB...

    please help with the marked ones the programming language is python code. 23.16 Write an RGB class that represents an RGB color. Store the red, green. and blue components. Include a _str_0 method and a luminance method that returns the luminance of the color. Write a main() function to test your code. 23.17 Write a CD class that represents a single music cd. Store the artist, title, genre, year of release, and playing time in minutes and seconds. However, instead...

  • Please write python code and please answer all parts and separate them into their parts, thank yo...

    Please write python code and please answer all parts and separate them into their parts, thank you.​​​​​​ Given the sequence: with the initial condition Xo chosen in the interval [0,1], and "a" is a given parameter between 0 and4 This sequence is a simple model to describe how a population (or civilization) evolves in a closed system with a finite amount of resources. The parameter "a" describes the rate of development and expansion of the civilization. The population is described...

  • Write a program that demonstrates use of programmer - defined data structures. Please provide code! Thank...

    Write a program that demonstrates use of programmer - defined data structures. Please provide code! Thank you. Here are the temps given: January 47 36 February 51 37 March 57 39 April 62 43 May 69 48 June 73 52 July 81 56 August 83 57 September 81 52 October 64 46 November 52 41 December 45 35 Janual line Iranin Note: This program is similar to another recently assigned program, except that it uses struct and an array of...

  • #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a...

    #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a list of up to 10 players and their high scores in the computer's memory. Use two arrays to manage the list. One array should store the players' names, and the other array should store the players' high scores. Use the index of the arrays to correlate the names with the scores. Your program should support the following features: a. Add a new player and...

  • Python code please!! Provide code and screenshots to both code and its output!!! Write a program...

    Python code please!! Provide code and screenshots to both code and its output!!! Write a program that prompts the user to select either Miles-to-Kilometers or Kilometers-to-Miles, then asks the user to enter the distance they wish to convert. The conversion formula is: Miles = Kilometers X 0.6214 Kilometers = Miles / 0.6214 Write two functions that each accept a distance as an argument, one that converts from Miles-to-Kilometers and another that converts from Kilometers-to-Miles The conversion MUST be done as...

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