Professional Documents
Culture Documents
Where a and b are positive. Find a weighted inner product such that the graph
represents a unit circle as
In that inner product space, reflect that unit circle about an input plane.
1. Theory:
a. Inner product:
Let V be a vector space. The inner product of 2 vectors u, v ∈ V is a real number
satisfying 4 following axioms:
- 1 ∀u ∈ V : (u, u) ≥ 0, ” = ” occurs ⇔ u = 0
- 2 ∀α ∈ K, u, v ∈ V : (αu, v) = α(u, v)
- 3 ∀u, v ∈ V : (u, v) = (v, u)
- 4 ∀u, v, w ∈ V : (u + v, w) = (u, w) + (v, w)
A vector space V + inner product = inner product space
b. Norm of a vector:
- ‖u‖ = √ ( u ,u )
2. Algorithm :
Given data : ⟨ x , y ⟩ = ax1y1 + bx2y2
Where a and b are positive, ‖u‖ = 1
( a 0)
we have x(x1; x2) = (-2; 2) ⇒ ⟨ x , y ⟩ = 0 b
⇒ ⟨ x , x ⟩ = ax1y1 + bx2y2 = 4a + 4b
( a 0)
we have y(y1; y2) = (-3; 3) ⇒ ⟨ x , y ⟩ = 0 b
⇒ ⟨ y , y ⟩ = 9a + 9b
⇒ √ ( 4 a+4 b )2 + ( 9 a+ 9 b )2 = ‖u‖ = 1
3. Code :
import math
print('We have: <x,y> = ax1y2 + bx2y2 ')
m = [['a',0],[0,'b']]
print('<x,y> =')
for i in range(2):
for j in range(2):
print(m[i][j],end = ' ')
print()
print('x(x1,x2)')
x1 = int(input('Please enter x1: '))
x2 = int(input('Please enter x2: '))
print('<x,x> = ax1x2 + bx2x2 = ',x1*x1,'a','+',x2*x2,'b')
print('y(y1,y2)')
y1 = int(input('Please enter y1: '))
y2 = int(input('Please enter y2: ')) #
print('<y,y> = ay1y2 + by2y2 = ',y1*y1,'a','+',y2*y2,'b')
print('=>
sqrt[(',x1*x1,'a','+',x2*x2,'b',')^2','+','(',y1*y1,'a','+',y2*y2,'b',')^2]=1')
print('to solve a or b we this to slove this function: ')
print(' (',x1*x1,'a','+',x2*x2,'b',')^2','+','(',y1*y1,'a','+',y2*y2,'b',')^2] = 1^2 =
1')
z =int(input('if find a enter :1,find b enter : 2 '))
t1= pow(x1,4) + pow(y1,4)
t2= pow(x2,4) + pow(y2,4)
t3= pow(x1,2)*pow(x2,2) + pow(y1,2)*pow(y2,2)
if z == 1:
b = float(input('please enter b: '))
delta = pow(2*b*t3,2)-4*(t1*(pow(b,2)*t2-1))
if delta == 0:
a1=a2=(-2*b*t3)/(2*t1)
print('value : ',a1)
elif delta < 0:
print('no value')
elif delta > 0:
a1 = (-2 * b * t3 + math.sqrt(delta)) / (2 * t1)
a2 = (-2 * b * t3 - math.sqrt(delta)) / (2 * t1)
print('a1 value: ', a1, ' ', 'a2 value: ', a2)
elif z == 2:
a = float(input('please enter a: '))
delta = pow(2 * a * t3, 2) - 4 *( t2 *(pow(a, 2)*t1-1))
if delta == 0:
b1=b2=(-2*a*t3)/(2*t2)
print('value : ',b1)
elif delta < 0:
print('no value')
else:
b1 = (-2 * a * t3 + math.sqrt(delta)) / (2 * t2)
b2 = (-2 * a * t3 - math.sqrt(delta)) / (2 * t2)
print('a1 value: ', b1, ' ', 'a2 value: ', b2)
4. Explaination:
The provided code is Python script that solves linear algebra equation
involving variables ' a ' and ' b '.
16) Finally, the code outputs the calculated values of ‘a’ or ‘b’ based
on the user's choice.
It's worth noting that the code assumes valid input values and does not
include extensive error handling or input validation. If incorrect or invalid
input is provided, the script may encounter errors or produce unexpected
results.