Home /
Expert Answers /
Computer Science /
tasks-you-are-to-create-a-python-code-that-will-plot-contours-and-line-plots-of-the-following-func-pa436
(Solved):
Tasks You are to create a Python code that will plot contours and line plots of the following func ...
Tasks You are to create a Python code that will plot contours and line plots of the following function. \[ f(x)=A \sin (n \pi x)+B \sin (m \pi y) \] Your code should: - Have a header describing the code and be liberally documented. - Interact with the user by printing to the screen a description of what the code can do. - Request input of \( A, B, n \), and \( m \) to define the function, it should then report out what was entered and ask for confirmation or reentry. - Continually ask whether you want a contour plot or a line plot or want to end. - When a contour plot is demanded by the user, your code should request the \( x \) and \( y \) range of the desired contour plot, and the plot should be generated to both the screen and a file. - When a line plot is demanded, your code should ask whether a vertical or horizontal plot is required and once told, should ask for the value of the fixed variable and the range of the other. It should generate the plot to both the screen and a file. - When the code is told to stop, it should let the user know what files the resulting plots can be found in. - The code should employ at a minimum: Arrays One or more functions A while or for loop And be well documented - Following the Assignment Preparation Rules, upload the code and output files for the specific case of \( A=1, B=3, m=1, n=1 / 2 \) and plot contours over a range of \( 0-10 \pi \) in both \( x \) and \( y \) and produce line plots at \( x=5 \pi \) and \( y=5 \pi \) across the full range of the other variable (i.e., for the \( x=5 \pi \) plot use y values from \( 0-10 \pi \) ).
1) I have used PrettyTable for displaying data in tabular form. 2) Code is well commented kindly refer that CODE: from math import * import numpy as np from prettytable import PrettyTable #definig function to get value of Sin(x) from taylor serie