Docsity

Mathematics Homework: Integration, Python Programming, and Function Calculation, Exams of Programming Paradigms

Toggle sidebar
bg1
Homework 4
Exercise 1. Approximating the following integral:
โˆซ1
๐‘ฅ
๐‘
๐‘Ž๐‘‘๐‘ฅ
By formula
โˆซ๐‘Ž
๐‘โ€Š๐‘“(๐‘ฅ)๐‘‘๐‘ฅ โ‰ˆ ฮ”๐‘ฅ
3โˆ‘๐‘—=1
๐‘›/2โ€Š[๐‘“(๐‘ฅ2๐‘—โˆ’2)+4๐‘“(๐‘ฅ2๐‘—โˆ’1)+๐‘“(๐‘ฅ2๐‘—)]
= ฮ”๐‘ฅ
3[๐‘“(๐‘ฅ0)+4โˆ‘๐‘—=1
๐‘›/2โ€Š๐‘“(๐‘ฅ2๐‘—โˆ’1)+2โˆ‘๐‘—=1
๐‘›/2โˆ’1โ€Š๐‘“(๐‘ฅ2๐‘—)+ ๐‘“(๐‘ฅ๐‘›)],
where a,b, and even number n from the user (Donโ€™t use if statement.)
Exercise 2. Write a python program to check whether the credit card number is valid
or invalid by the Luhn algorithm (https://en.wikipedia.org/wiki/Luhn_algorithm)
Exercise 3. Let ๐ด(๐‘ฅ)= 1 +2๐‘ฅ + 3๐‘ฅ2+โ‹ฏ๐‘›๐‘ฅ๐‘›โˆ’1. For x and n from the user, calculate
A(x).
Exercise 4. Let the expression "A(x,y) =x^2+4x+y^2+7x-5" in latex form. For x, y
from the user, calculate A(x,y).

Partial preview of the text

Download Mathematics Homework: Integration, Python Programming, and Function Calculation and more Exams Programming Paradigms in PDF only on Docsity!

Homework 4

Exercise 1. Approximating the following integral:

๐‘

๐‘Ž

By formula

โˆซ

๐‘Ž

๐‘

๐‘“(๐‘ฅ)๐‘‘๐‘ฅ โ‰ˆ

ฮ”๐‘ฅ

3

โˆ‘

๐‘—= 1

๐‘›/ 2

[๐‘“(๐‘ฅ

2 ๐‘—โˆ’ 2

) + 4 ๐‘“(๐‘ฅ

2 ๐‘—โˆ’ 1

) + ๐‘“(๐‘ฅ

2 ๐‘—

)]

=

ฮ”๐‘ฅ

3

[๐‘“

( ๐‘ฅ

0

)

  • 4 โˆ‘

๐‘—= 1

๐‘›/ 2

๐‘“(๐‘ฅ

2 ๐‘—โˆ’ 1

) + 2 โˆ‘

๐‘—= 1

๐‘›/ 2 โˆ’ 1

๐‘“(๐‘ฅ

2 ๐‘—

) + ๐‘“

( ๐‘ฅ

๐‘›

) ],

where a,b, and even number n from the user (Donโ€™t use if statement.)

Exercise 2. Write a python program to check whether the credit card number is valid

or invalid by the Luhn algorithm (https://en.wikipedia.org/wiki/Luhn_algorithm)

Exercise 3. Let ๐ด

2

๐‘›โˆ’ 1

. For x and n from the user, calculate

A(x).

Exercise 4. Let the expression "A(x,y) =x^2+4x+y^2+7x-5" in latex form. For x, y

from the user, calculate A(x,y).