Solution to POJ 1045
The problem is on here.
Analysis
It is hard to go with the direct fomular, because there is no build-in way to
calculate a differential. However, we can apporach it with the defination of
differential: $\frac{df(x)}{dx} = \lim_{\Delta x \to +\infty}\frac{f(x+\Delta x)-f(x)}{\Delta x}$. Usually make $\Delta x$ equal to DOUBLE_EPSILON.
The first thing we should do is to simplification the fomulars. From $v_1=V_S\cos{\omega t}$, $v_2=V_R\cos(\omega t + \theta)$, $v_2=iR$, and $i=C\frac{d(v_1-v_2)}{dt}$, we could come out an equation shown below:
$$V_R\cos(\omega t+\theta)=CR(\frac{d v_1}{dt}-\frac{d v_2}{dt})$$
After simplification, it would turn into the equation shown below:
$$V_R\cos(\omega t+\theta)=\omega CR[V_R\sin(\omega t+\theta)-V_S\sin{\omega t}]$$
When $\omega t+\theta=0$, it would show us:
$$V_R=\omega CRV_S\sin\theta$$
When $\omega t=0$, it would show us:
$$V_R\cos\theta=\omega CRV_R\sin\theta$$
which would further lead to $\tan\theta=\frac{1}{\omega CR}$.
As a consequence, we know how to calculate $V_R$.
Easy Solution
|
Please pay more attention about “… output should be rounded to three digits after the decimal point.”.