Informatics2-2018/HW8

A MathWikiből
A lap korábbi változatát látod, amilyen Gaebor (vitalap | szerkesztései) 2018. május 14., 22:08-kor történt szerkesztése után volt.
(eltér) ←Régebbi változat | Aktuális változat (eltér) | Újabb változat→ (eltér)

Tartalomjegyzék

numpy Homework

numpy

Implement the following python functions. The name of the exercise should be the name of the function. You will need import numpy! On your own computer I recommend Anaconda because it is installed with numpy by default. Mind that you need the 2.7 version. Or you can use the leibniz.

integral (2p)

The function should have 3 parameters, two real numbers and one integer:

  a: the left-hand-side of the interval
  b: the right-hand-side of the interval
  n: the number of equally spaced points in the partition, including a and b

a < b and n > 1.

The output should be a real number: the integral of the function sin(x) / x on the interval [a,b] calculated with the trapezoidal rule.

derivative (3p)

A függvény bemenete legyen két valós szám és egy egész szám:

  a: tartomány eleje
  b: tartomány vége
  n: hány osztópont legyen véletlenszerűen , beleértve a végpontokat

a < b és n > 1.

  • Kimenete egy n-1 hosszú numpy vektor legyen, ami a sin(x) / x függvény numerikus deriváltját tartalmazza.
  • Az osztópontok véletlenül helyezkedjenek ez az [a,b] intervallumban, de a végpontok mindenképpen x0 = a,xn − 1 = b legyenek.
    • véletlen felosztást úgy generálhatunk, ha veszünk n-2 véletlen pontos és sorba rendezzük azokat, majd elé fűzzük a-t és utána b-t.
    • ehhez kellhet: numpy.sort és numpy.random.rand

Remember the (forward) finite difference:

{\Delta f}_i = \frac{f(x_{i+1})-f(x_i)}{x_{i+1}-x_i}

Handing-in

Send the exercises as a python code from your math email account to info1hazi@gmail.com

You should attach one python file containing the definition of the required functions without any test code or print command.

The file should be named:

  EN1_HF8_<user account>.py

the subject of the letter should be the same (without the extension). For me example:

  EN1_HF8_borbely.py

Deadline

20th of May, 29:59

Személyes eszközök