"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"import math\n",
"\n",
"A_p=250.0\n",
"A_p_dB=10*math.log10(A_p)\n",
"print('Power gain(dB) when power gain is 250 = %d'% math.ceil(A_p_dB));\n",
"A_p=100.0\n",
"A_p_dB=10*math.log10(A_p)\n",
"print('Power gain(dB) when power gain is 100 = %d'%A_p_dB)\n",
"A_p=10.0\n",
"A_p_dB=20*math.log10(A_p)\n",
"print('Voltage gain(dB) when Voltage gain is 10 = %d'%A_p_dB)\n",
"A_p=0.50\n",
"A_p_dB=10*math.log10(A_p)\n",
"print('Power gain(dB) when voltage gain is 0.50 = %d'%A_p_dB)\n",
"A_p=0.707\n",
"A_p_dB=20*math.log10(A_p)\n",
"print('Power gain(dB) when power gain is 0.707 = %d'%A_p_dB)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Power gain(dB) when power gain is 250 = 24\n",
"Power gain(dB) when power gain is 100 = 20\n",
"Voltage gain(dB) when Voltage gain is 10 = 20\n",
"Power gain(dB) when voltage gain is 0.50 = -3\n",
"Power gain(dB) when power gain is 0.707 = -3"
]
}
],
"prompt_number": 19
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
Example 10.2, Page Number: 313
"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"\n",
"\n",
"v_out=0.707*10;\n",
"print('output voltage in volts at -3dB gain = %.2f'%v_out)\n",
"#at -6dB voltage gain from table is 0.5\n",
"v_out=0.5*10;\n",
"print('output voltage in volts at -6dB gain = %d'%v_out)\n",
"#at -12dB voltage gain from table is 0.25\n",
"v_out=0.25*10;\n",
"print('output voltage in volts at -12dB gain = %.1f'%v_out)\n",
"#at -24dB voltage gain from table is 0.0625\n",
"v_out=0.0625*10;\n",
"print('output voltage in volts at -24dB gain = %.3f'%v_out)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"output voltage in volts at -3dB gain = 7.07\n",
"output voltage in volts at -6dB gain = 5\n",
"output voltage in volts at -12dB gain = 2.5\n",
"output voltage in volts at -24dB gain = 0.625"
]
}
],
"prompt_number": 20
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
Example 10.3, Page Number: 316
"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"import math\n",
"R_in=1.0*10**3;\n",
"C1=1.0*10**-6;\n",
"A_v_mid=100.0; #mid range voltage gain\n",
"f_c=1/(2*math.pi*R_in*C1);\n",
"#at f_c, capacitive reactance is equal to resistance(X_C1=R_in)\n",
"attenuation=0.707;\n",
"#A_v is gain at lower critical frequency\n",
"A_v=0.707*A_v_mid;\n",
"print('lower critical frequency = %f Hz'%f_c)\n",
"print('attenuation at lower critical frequency =%.3f'%attenuation)\n",
"print('gain at lower critical frequency = %.1f'%A_v)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"lower critical frequency = 159.154943 Hz\n",
"attenuation at lower critical frequency =0.707\n",
"gain at lower critical frequency = 70.7"
]
}
],
"prompt_number": 21
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
Example 10.4, Page Number: 317
"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"A_v_mid=100.0;\n",
"#At 1Hz frequency,voltage gain is 3 dB less than at midrange. At -3dB, the voltage is reduced by a factor of 0.707\n",
"A_v=0.707*A_v_mid;\n",
"print('actual voltage gain at 1Hz frequency = %.1f'%A_v)\n",
"#At 100Hz frequency,voltage gain is 20 dB less than at critical frequency (f_c ). At -20dB, the voltage is reduced by a factor of 0.1\n",
"A_v=0.1*A_v_mid;\n",
"print('actual voltage gain at 100Hz frequency = %d'%A_v)\n",
"#At 10Hz frequency,voltage gain is 40 dB less than at critical frequency (f_c). At -40dB, the voltage is reduced by a factor of 0.01\n",
"A_v=0.01*A_v_mid;\n",
"print('actual voltage gain at 10Hz frequency = %d'%A_v)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"actual voltage gain at 1Hz frequency = 70.7\n",
"actual voltage gain at 100Hz frequency = 10\n",
"actual voltage gain at 10Hz frequency = 1"
]
}
],
"prompt_number": 22
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
Example 10.5, Page Number: 319
"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"import math\n",
"R_C=10.0*10**3;\n",
"C3=0.1*10**-6;\n",
"R_L=10*10**3;\n",
"A_v_mid=50;\n",
"f_c=1/(2*math.pi*(R_L+R_C)*C3);\n",
"print('lower critical frequency = %f Hz'%f_c)\n",
"#at midrange capacitive reactance is zero\n",
"X_C3=0;\n",
"attenuation=R_L/(R_L+R_C); \n",
"print('attenuation at midrange frequency = %.1f'%attenuation)\n",
"#at critical frequency, capacitive reactance equals total resistance\n",
"X_C3=R_L+R_C;\n",
"attenuation=R_L/(math.sqrt((R_C+R_L)**2+X_C3**2));\n",
"print('attenuation at critical frequency = %f'%attenuation)\n",
"A_v=0.707*A_v_mid;\n",
"print('gain at critical frequency = %.2f'%A_v)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"lower critical frequency = 79.577472 Hz\n",
"attenuation at midrange frequency = 0.5\n",
"attenuation at critical frequency = 0.353553\n",
"gain at critical frequency = 35.35"
]
}
],
"prompt_number": 23
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"