# variable frequency oscillator
import math
#Variable declaration
fc=1.3*10**6 #centre frequency
fsignal=1*10**6 #frequency of the signal
fvfo=0.3*10**6 #frequency of variable frequency oscillator
#Calculations
per=(fvfo/fc)*100
#Result
print("percent variation:")
print("per = %.2f%%"%(math.floor(per*100)/100))
# DFT coefficients
import math
#Variable declaration
N=22.0 #no. of acquistioned data
delt=2*10**-3 #time period
n=4.0 #4th DFT coeff.
q=3.0 #no. of discrete points
#Calculations
#An=(2/N)*V(n)*cos((2*%pi*n*q)/N)
#Bn=(2/N)*V(n)*sin((2*%pi*n*q)/N)
#Result
print("A4=(1/11)V(4)cos(12pi/11)\n")
print("B4=(1/11)V(4)sin(12pi/11)\n")
# find improvement ratio
import math
#Variable declaration
N=64.0 #data units
#implimentation steps for DFT=64^2
#Calculations
#for FFT
r= math.log(N,2)/N #implimentation ratio
#Result
print("implimentation ratio:")
print("r = %.5f or (3/32)"%r)
# find distortion factor
import math
#Variable declaration
D3=1.3*10**-2 #3rd harmonic(unit value)
D5=0.31*10**-2 #5th harmonic(unit value)
D7=0.04*10**-2 #7th harmonic(unit value)
#Calculations
Dt=math.sqrt((D3**2)+(D5**2)+(D7**2))
#Result
print("distortion ratio:")
print("Dt = %.5f "%Dt)
# find percentage change in feedback
import math
#Variable declaration
Q=10.0 #Q-factor
m=5.0 #improvement factor
a=(1.0/((3*Q)-1)) #filter factor
#Calculations
Qr=Q*m #rejection Q-factor
ar=(1.0/((3*Qr)-1)) #rejection filter factor
perf=((a-ar)/a)*100 #percent change in feedback
#Result
print("percent change in feedback:")
print("perf = %.2f "%perf)
# time uncertainity and measurable time
import math
#Variable declaration
fc=100.0*10**6 #clock frequency
Nm=4.0*10**6 #memory size
#Calculations
Te=(1.0/fc) #timing uncertainity
Tm=(Nm/fc) #measurable time
#Result
print("timing uncertainity:")
print("Te = %.f ns\n"%(Te*10**9))
print("measurable time:")
print("Tm = %.f m"%(Tm*10**3))