Python assignment作业代写,计算机作业高分包过!

  1. Write a Python program script to compute f(x) and f’(x) for the given decaying sine function on the domain interval x∈[0,6π] , where a = 0.25, and b = 1. Use arrays and NumPy functions to do the calculations.
  • The program will write a comma separated values (CSV) data file with three columns of comma separated data consisting of the domain values, function values, and the derivative values: x, f(x), and f’(x) respectively. File extension is csv. You may use savetxt from numpy.
  • Use scientific notation when writing your floating point values into the data file: as in %16.8e rather than %16.8f.
  • Use 201 equally spaced data points on the specified domain interval x∈[0,6π].
  • Use NumPy to compute the function values; use the supplied num_deriv UDF (user defined function) to compute the first derivative.

编写一个Python程序脚本,计算域间x∈[0,6π]上给定的衰减正弦函数的f(x)和f'(x),其中a = 0.25,b = 1。使用数组和NumPy函数来进行计算。

NumPy有创建和操作数组的函数。使用NumPy来计算函数值;使用提供的num_deriv UDF(用户定义的函数)来计算一阶导数。

2. Write a Python script to read the data file from the previous problem.

  • Read the data values from the file into three NumPy arrays. You may use loadtxt from numpy and array slicing.
  • Plot the function and its derivative. Use different colors for each function curve.
  • this plot title: f(x) = exp(-0.25*x)*sin(x) and f’(x)
  • Include a legend labeling the color for f(x) and f’(x).
  • Label the horizontal axis as the Time.
  • ·    Label the vertical axis as the Amplitude.


  • 将文件中的数据值读入三个NumPy数组。你可以使用numpy的loadtxt和数组切分法。
  • 绘制函数和它的导数。对每个函数曲线使用不同的颜色。
  • 提供这个绘图标题:f(x)=exp(-0.25x)sin(x)和f'(x)
  • 包括一个图例,标注f(x)和f'(x)的颜色。
  • 将横轴标记为时间。
  • 在纵轴上标明振幅。

4. Write a Python program script to:

  • Read all the data generated for the Gaussian Normal distribution into NumPy arrays.
  • plot the domain and f(x), f’(x), and f”(x).
  • Annotate the plot with a title, legend, and labels for both the vertical and horizontal axes. Label the vertical axis as the Range, and the Horizontal axis as the Domain.

5. Modify the previous program to make three separate Figures for the: (1) function, (2) derivative, and (3) 2nd derivative. Label the plots and axes. For example, plt.figure(1) creates a new figure 1.

6. Submit your plots, script and data files to Harvey-Blackboard for grading. PDF screenshots are acceptable for plots.

# Add this UDF to the beginning of your code
import numpy as np

def num_deriv(yvec,dx):
    # input: array of y values on domain of uniformly spaced points
    # input: dx spacing between x domain point
    # return: array of numerical first derivative values
    npts = len(yvec)
    ypr = np.zeros(xvec.shape)       # intialize all 0
    ypr[0] = (yvec[1]-yvec[0])/dx    # ypr of leftmost point, forward deriv
    for i in range(1,npts-1):        # ypr of middle points, central deriv
        ypr[i]=(yvec[i+1] - yvec[i-1])/(2*dx)  
    ypr[-1]= (yvec[-1]-yvec[-2])/dx  # ypr of rightmost point, backwards deriv


Assignment Exmaple

Recent Case

Service Scope

oop|Processing|JS|Ruby|Scala|Rust|Data Mining|数据库|Oracle|Mysql|Sqlite|IOS|Data Mining|网络编程|多线程编程|Linux编程操作系统|计算机网络|留学生|编程|程序|代写|加急|个人代写|作业代写|Assignment