Professional Documents
Culture Documents
Major Assignment1
Major Assignment1
1. A function to calculate the batting average of a batsman. The function will consist of two
variables Total runs scored (T) and Number of times he gets out (O).
So it will,
F(t,o) = T/O
If a batsman scores T= 660 runs and gets out O= 5 times
The average will = 132avg
2. Function to calculate profit and loss. Consists of two variable cost price (c) and selling price (s).
So it will be,
F(c,s)= s-c
if the final product is > than Cost price it will be gain if < than loss.
If we have selling price S = 45 and Cost price C = 40
Then we’ll have a gain of 5rs.
3. Function to calculate area of a rectangle. We’ll have two variables a it depends on length (l) and
width (w) of the rectangle.
So it will be,
f(l,w)= l x b
f(x) = x+2
Example: Z= f(x,y),
f(x,y) = 1/ x*y
(x, y, z) ∈ D a unique Z ∈ ℝ.
Example: f(x,y,z) = √ x 2+ y 2 + z 2
Example: S = F(x1,x2,x3…….xn)
Q1
Q2
Q3
Q4
Q5
Q6
Q7
Q8
Q9 AND Q12
Q4. Write the algorithm for the domain of Functions in Q5 to Q12. Code
the algorithims in any Software Language.
import math
print("Question no.5 in Ex:14.1 of the book.\n"
"f(x,y)= √(y-x-2)\n"
"Domain = {(x,y)∈R|y≥ x+2}")
x = int(input("Enter value for x: "))
y = int(input("Enter value for y: "))
if y >= x+2:
a = (y-x-2)
z = math.sqrt(a)
print("The output of the function is: ",z)
else:
print("The values you entered is not in the range.\nPlease input again.")
#--------------------------------------
print("Question no.6 in Ex:14.1 of the book.\n"
"f(x,y)=ln(x^2+y^2-4)\n"
"Domain = {(x,y)∈ R^2 | x^2+y^2>4}")
x = int(input("Enter value for x: "))
y = int(input("Enter value for y: "))
if (x^2 + y^2) > 4:
a = x^2 + y^2 - 4
z = math.log(z)
print("The output of the function is: ",z)
else:
print("The values you entered is not in the range.\nPlease input again.")
#---------------------------------------
print("Question no.7 in Ex:14.1 of the book.\n"
" f(x,y)=((x-1)(y+2))/((y-x)(y-x^3))\n"
"Domain = {(x,y)∈ R^2 ┤|y≠x,y≠x^3}")
x = int(input("Enter value for x: "))
y = int(input("Enter value for y: "))
if x != y and y != x^3:
a = ((x-1)*(y+2))/((y-x)*(y-x^3))
print("The output of the function is: ",a)
else:
print("The values you entered is not in the range.\nPlease input again.")
#---------------------------------------
print("Question no.8 in Ex:14.1 of the book.\n"
"f(x,y)=(sin(xy))/(x^2+y^2-25)\n"
"Domain = {(x,y)∈ R^2 ┤| x^2+y^2≠25}")
x = int(input("Enter value for x: "))
y = int(input("Enter value for y: "))
if (x*2 + y^2) != 25:
p = x*y
a = math.sin(p)/(x^2 + Y^2 - 25)
print("The output of the function is: ",a)
else:
print("The values you entered is not in the range.\nPlease input again.")
#--------------------------------------
print("Question no.9 in Ex:14.1 of the book.\n"
" f(x,y)=〖cos〗^(-1)〖(y-x^2)〗\n"
"Domain = {(x,y)∈ R^2 |x^2-1≤y≤x^2+1}")
x = int(input("Enter value for x: "))
y = int(input("Enter value for y: "))
if y >= (x^2 - 1) and y <= (x^2 + 1):
p = y - x^2
a = math.acos(p)
print("The output of the function is: ",a)
else:
print("The values you entered is not in the range.\nPlease input again.")
#--------------------------------------
print("Question no.10 in Ex:14.1 of the book.\n"
" f(x,y)=ln(xy+x-y-1)\n"
"Domain = {(x,y)∈R^2 |(xy+x-y-1)>0}")
x = int(input("Enter value for x: "))
y = int(input("Enter value for y: "))
if ((y+1)*(x-1)) > 0:
p = (x*y) + x - y - 1
a = math.log(p)
print("The output of the function is: ",a)
else:
print("The values you entered is not in the range.\nPlease input again.")
#--------------------------------------
print("Question no.11 in Ex:14.1 of the book.\n"
" f(x,y)= √((x^2-4)(y^2-9))\n"
"Domain = {(x,y)∈R^2 |〖(x〗^2-4)(y^2-9)≥0}")
x = int(input("Enter value for x: "))
y = int(input("Enter value for y: "))
if ((x^2 - 4)*(y^2 - 9)) >= 0:
p = ((x^2 - 4)*(y^2 - 9))
a = math.sqrt(p)
print("The output of the function is: ",a)
else:
print("The values you entered is not in the range.\nPlease input again.")
#--------------------------------------
print("Question no.12 in Ex:14.1 of the book.\n"
" f(x,y)=1/(ln(4-x^2-y^2))\n"
"Domain = {(x,y)∈R^2│x^2+y^2<4,x^2+y^2≠3}")
x = int(input("Enter value for x: "))
y = int(input("Enter value for y: "))
if (x^2 + y^2) < 4 and (x^2 + y^2) != 3:
p = (4 - x^2 - y^2)
a = 1 / math.log(p)
print("The output of the function is: ",a)
else:
print("The values you entered is not in the range.\nPlease input again.")
#--------------------------------------