Description
Consider the AC circuit below. We'll assume that the circuit are in steady-state. Thus, the voltage at nodes 1 and 2 is given by V1= VSCOSWT and V2= VRcos (WT + q) where VSis the voltage of the source, W is the frequency (in radians per second), and T is time. VRIs the magnitude of the voltage drop across the resistor, and q are its phase.
You is to write a program to determine VRFor different values of W. You'll need the laws of electricity to solve this problem. The first is Ohm's law, which states v2= IR where I am the current in the circuit, oriented clockwise. The second is i = C D/dt (v1-V2) which relates the current to the voltage on either side of the capacitor. "D/dt" indicates the derivative with respect to T.
Input
The input would consist of one or more lines. The first line contains three real numbers and a non-negative integer. The real numbers is VS, R, and C, in that order. The integer, n, is the number of test cases. The following n lines of the input would have one real number per line. Each of these numbers is the angular frequency, W.
Output
For each angular frequency in the input is to output its corresponding VROn a. Each VRValue output should is rounded to three digits after the decimal point.
Sample Input
1.0 1.0 1.0 90.010.0316230.10.316231.03.162310.031.623100.0
Test instructions: Gives the formula V2=IR,V2=VR * cos (WT + q), V1=vs * cos (WT), i = C * d (V1-V2)/dt; D is the meaning of the derivative number. Known Vs,r,c,w, seeking VR.
Analysis: Using V2 respectively equals two formulas, bringing i,v2 and V1 into the equation: r*c*d (Vs * cos (WT)-VR * cos (WT + q))/DT = VR * cos (WT + q)
According to the derivation formula: D (cos (x))/dx =-sinx can be the original equation: r*c*w* (vr*sin (WT + q)-vs*sin (WT)) = Vr * cos (WT + q)
Here the trigonometric function parameters are two: wt+q and WT, we make them 0, respectively, the equation can be changed to: R*c *w*vs*sin (q) = Vr; R*c * W*sin (q) = cos (q)
Made from 2: cot (q) = R * C * W.
By formula: sin^2 (a) = 1/(cot ^2 (a) + 1)
Available: sin (q) =sqrt (1/(cot^2 (q) + 1))
namely: sin (q) =sqrt (1/(r^2*c^2*w^2 + 1))
#include <iomanip> #include <iostream> #include <cmath>using namespace Std;int main () { double vs, R,c,w; int n; cin>>vs>>r>>c>>n; while (n--) { cin>>w; Cout<<fixed<<setprecision (3) <<r*c*w*vs*sqrt (1/(r*r*c*c*w*w+1)) <<endl; } return 0;}
Substituting 1 available: Vr = R * C * w * Vs * sqrt (1/(r^2*c^2*w^2 + 1))
poj-1045 (maths is not my fault)