# AC circuit relationship between impedance, current and supplied voltage

I am a high school student and currently studying AC basics. In an AC (sinusoidal supplied voltage and current) circuit, resistor voltage and current are always in phase, the supplied voltage and current are not always in phase. But the current can still be calculated using I = V/Z, where Z is the impedance of the circuit. I don't understand this. How could the current be calculated using I = V/Z, even though I and source V are not in phase?

It will be appreciated if you could answer this question.

Edit: I know some basic complex number and some differential equations.

Following is my assumption:

Say we have a unit circle, with $$\arg(V(r)) = 0 \\arg(V(l)) = \pi/2 \\ arg(V(c)) = -\pi/2 \\|V(s)| = 1\$$

Therefore $$\arg(V(s)) = \arctan((V(l)-V(c))/V(r))\$$

I assume that $$\I\$$ is purely real(?) And just like resistance, the mathematical meaning of impedance is simply the ratio between $$\V(s)\$$ and $$\I\$$. Because it's a quotient of a complex number and a real number, the impedance is complex too. So rather than asking why $$\I = V(s)/Z\$$, I should think $$\Z\$$ as a constant, regardless of the phase.

• Oh boy, this is NOT obvious and don't feel bad you're having trouble. What you need to learn about is "Phasors". Google that term, you'll have no end of information about it. This is representation of voltage & current, but not in the "DC" sense that you are imaging them. . "Z" is a "complex impedance", it involves squareroot of -1 (i.e. imaginary numbers). When your smart-ass classmate asks the math teacher why study "i" (sqrt of -1), tell him it actually has real applications in EE. Here's a reasonably basic intro: electronics-tutorials.ws/accircuits/phasors.html Oct 27, 2021 at 6:04
• Either you go RMS (the electrician way) or consider Z as complex number and properly use the AC Ohm's law and consider the quantities as vector. See also skm-eleksys.com/2010/05/phasors-in-ac-circuit-analysis.html Why it works is not completely trivial but it's quite easy once you learn the trick Oct 27, 2021 at 6:07
• BTW....  >> How could the current be calculated using I = V/Z, even though I and source V are not in phase?  Great insight. Very impressive for a self-taught high schooler! Oct 27, 2021 at 6:14
• When you say voltage and current are in phase, you are saying that the particular component cannot store energy. A resistor responds instantaneously and cannot store energy; therefore the voltage across it and the current through it are in phase. The situation changes with inductors and capacitors that can store energy (in magnetic and electric fields respectively).
– Syed
Oct 27, 2021 at 7:07
• Would you consider looking at this? Not a full answer to your question, but may help. Oct 27, 2021 at 12:07

I should think Z as a constant, regardless of the phase

This is not true, impedance Z is a function of frequency $$\\omega\$$:

$$Z = j\omega+r$$

Perhaps this would better illustrate my point:

$$Z(\omega) = j\omega+r$$

Z is a complex value, with real part $$\r\$$ and imaginary part $$\\omega\$$. From this you can see that both argument and magnitude of this function are dependent on frequency.

For any particular values of $$\\omega\$$ and $$\r\$$, yes, Z evaluates to a particular complex number, with a particular argument and particular magnitude, but the impedance function Z itself is not a constant.

As you correctly pointed out, the relationship between current through and voltage across a resistor is completely proportional, and if a circuit contained only resistive elements, this relationship would be enough to completely describe the behaviour of the circuit. Time and frquency will have no bearing on that behaviour.

However, this is not the case for capacitors and inductors, because (also as you noted) the relationship is not proportional, and time becomes a factor in the equations.

It can seem daunting at first, when someone tells you the relationship between current through and voltage across a capacitor, because it's a differential equation:

$$I = C\frac{dV}{dt}$$

I don't know how much you know, and maybe you already knew and understood this, but I'll describe its meaning anyway. This translates to: the time rate of change of voltage across a capacitor is directly proportional to the current through it, and the constant of proportionality is the capacitance C.

One solution to this equation, is when I is constant, and that solution amounts to this observation: the voltage across a capacitor will rise (or fall) at a steady rate if there is a constant current through it.

Another solution, for when the current I is a sinusoid, like I=sin(t), is that V is also a sinusoid, but 90° out of phase with the current. An inverted cosine, in fact.

In the case of a single capacitor and some simple constant or sinusoidal current source, this equation is easy to solve, but it's rarely that simple. In reality there are many resistances, many capacitances and many inductances present in a circuit, and all the combined simultaneous differential equations describing that circuit's behaviour are always unwieldy.

So we turn to Laplace transforms, which greatly simplify sovling the equations. Laplace transforms are ways to represent differential equations in a form which represents not the evolution of voltages and currents in time, but rather the relationship between the frequency and phase difference of some voltage or current. The mathematics behind this is exquisite, and I strongly recommend that you watch the videos by Khan Academy and 3Blue1Brown on this and related topics.

For now, though, it is probably sufficient to state that in Laplace transforms, instead of the variable $$\t\$$ (time) the variable is $$\s\$$ which can be thought of as the frequency-domain equivalent of $$\t\$$ in the regular time-domain differential equations. This value is not a simple real number; it's complex.

In a generalisation, $$\s\$$ can be written as $$\j\omega\$$. $$\j\$$ is the constant $$\\sqrt{-1}\$$ (usually written $$\i\$$, but engineers use $$\j\$$ to avoid ambiguity when $$\i\$$ is used to represent current). $$\\omega\$$ is angular frequency, in radians per second. Perhaps you are familiar with the relationship between frequency $$\f\$$ (in cycles per second, or $$\Hz\$$), and angular frequency $$\\omega\$$:

$$\omega = 2\pi f$$

This brings us to the term "impedance", which, like resistance, is a representation of the relationship between current through and voltage across something, but where that something is capacitive or inductive, or has some degree of capacitive or inductive behaviour. In other words, elements of a circuit which exhibit time-dependent behaviour, resulting in a phase difference between current and voltage.

Where we call "resistance" the relationship between current and voltage in a resistor (where there's no time dependant aspect, and no phase shift), the name given to that relationship in a capcacitor or inductor is called "reactance". All elements of a circuit will have some combination of resistance and reactance, and that combination is called "impedance".

Impedance is a complex value, with real and imaginary parts. The real part of impedance represents the resistive behaviour of some element, and the imaginary part corresponds to the reactance of the element.

Impedance, being complex, "encodes" two pieces of information. When you plot complex numbers on a graph of the complex plane, it becomes a vector of sorts, with a length (magnitude) and direction (angle, or "argument"). The angle represents the phase difference between current and voltage at some frequency, and magnitude is the ratio between the amplitudes of current and voltage.

Usually pure resistance is quoted as just real number, a single scalar quantity of "ohms", but you may consider it to be complex too, just with zero imaginary part, no time dependent, reactive behaviour. Reactance, on the other hand is defined in terms of $$\j\omega\$$, which is the imaginary part of impedance.

To recap, then, impedance of an element is a complex value consisting of a real part which represents the resistive aspect of the element, and an imaginary part representing the reactive aspect. Because this value is complex, it has a magnitude which tells you the ratio between the current and voltage amplitudes at some given frequency, and an angle, which tells you the phase relationship between current and voltage.

As I mentioned, an ideal resistance R is purely real, with no imaginary part, so the impedance $$\Z_R\$$ of a resistor of value R is:

\begin{aligned} Z_R &= 0j + R \\ \\ &= R \\ \\ \end{aligned}

The impedances $$\Z_C\$$ of an ideal capacitor C, and $$\Z_L\$$ of an ideal inductor L, are purely imaginary:

\begin{aligned} Z_C &= \frac{1}{j\omega C} \\ \\ Z_L &= j\omega L \\ \\ \end{aligned}

Here's where your question actually gets answered. Since these values are all complex (albeit with zero imaginary or real parts), they have magnitude and direction, and thereby carry more information than just a scalar "resistance".

So there is subtle but crucial distinction between these two versions of Ohm's law:

\begin{aligned} R &= \frac{V}{I} \\ \\ Z &= \frac{v}{i} \\ \\ \end{aligned}

R represents a purely resistive element, and is a scalar real value, but Z means impedance, which is complex, and contains more information than just magnitude. Impedance Z contains enough information for you to be able to extract not only how the amplitudes of current and voltage compare, but also the phase relationship between current and voltage.

Also, since impedance Z is in terms of frequency $$\\omega\$$, it's essential to understand that $$\i\$$ and $$\v\$$ are referring to amplitudes of sinusoidal components of current and voltage at that particular frequency. The orignal, famous Ohm's law in terms of resistance R can also be used to describe static DC voltages and currents, but impedance cannot. Impedance is talking about AC, and in particular amplitudes only, ignoring DC offsets.

The nature of the Laplace transform is such that you may combine impedances exactly as you would combine simple resistances, in a circuit, using the same formulae. You can add impedances in series, to find their combined impedance. You can combine parallel-connected impedances as you would combine parallel resistances. The result will always be a complex expression that will correctly describe the magnitude and phase relationships between current through and voltage across the compound element:

simulate this circuit – Schematic created using CircuitLab

In the circuit P, we have a reactance in series with a resistance. The total impedance between A and B is simply the sum of the individual impedances:

\begin{aligned} Z_{AB} &= Z_L + Z_R \\ \\ &= j\omega L + R \\ \\ &= 100 + j(\omega \cdot 10^{-6}) \\ \\ \end{aligned}

For the parallel combination in circuit Q, we simply find the reciprocal of the sum of reciprocals, as you would for a pair of resistors. There will have to be some manipulation (using a complex conjugate) to reveal a regular complex result:

\begin{aligned} Z_{CD} &= \frac{1}{\frac{1}{\frac{1}{j\omega C}}+\frac{1}{R}} \\ \\ &= \frac{1}{j\omega C+\frac{1}{R}} \\ \\ &= \frac{R}{j\omega CR+1} \cdot \frac{j\omega CR-1}{j\omega CR-1} \\ \\ &= \frac{j\omega CR^2 - R}{-\omega ^2C^2R^2 - 1} \\ \\ &= \frac{R}{\omega ^2C^2R^2+1} + j(\frac{-\omega CR^2}{\omega ^2C^2R^2+1}) \end{aligned}

Look's horrendous, and it is.

Circuit R is the same as Q, except for an inductor in series. We can add the impedance of that inductor to the total impedance of circuit Q:

\begin{aligned} Z_{EF} &= Z_{CD} + Z_L \\ \\ &= \frac{R}{\omega ^2C^2R^2+1} + j(\frac{-\omega CR^2}{\omega ^2C^2R^2+1}) + j\omega L \\ \\ &= \frac{R}{\omega ^2C^2R^2+1} + j(\omega L - \frac{\omega CR^2}{\omega ^2C^2R^2+1}) \end{aligned}

The point I am trying to make with all this is that each of the above calculations yields a complex number, and the argument (angle) of that number is telling you phase information, and the magnitude of that number is telling you about relative amplitudes.

Lastly, to illustrate this, let's take circuit P and simulate it. I'll connect a sinusoidal voltage source of amplitude 10V, and of frequency 16Mhz, and compare the resulting current and voltage waveforms.

The angular frequency corresponding to 16Mhz is:

\begin{aligned} \omega &= 2\pi f \\ \\ &= 2\pi \times 16MHz \\ \\ &= 100\times10^6 rad/s \\ \\ \end{aligned}

The impedance of circuit P, between A and B, is:

$$Z_{AB} = R + j(\omega L)$$

The real and imaginary parts of this impedance are:

\begin{aligned} Re(Z_{AB}) &= R \\ \\ &= 100 \\ \\ Im(Z_{AB}) &= \omega L \\ \\ &= 100\times10^6 \cdot 1\times 10^{-6} \\ \\ &= 100 \\ \\ \end{aligned}

The argument of $$\Z_{AB}\$$ is:

\begin{aligned} \phi &= \angle Z_{AB} \\ \\ &= tan^{-1}(\frac{Im(Z_{AB})}{Re(Z_{AB})}) \\ \\ &= tan^{-1}(\frac{100}{100}) \\ \\ &= 45° \end{aligned}

The magnitude of $$\Z_{AB}\$$ is:

\begin{aligned} F &= \lvert Z_{AB} \rvert \\ \\ &= \sqrt{Im(Z_{AB})^2 + Re(Z_{AB})^2} \\ \\ &= \sqrt{100^2 + 100^2} \\ \\ &= 100\sqrt{2} \\ \\ &= 141 \\ \\ \end{aligned}

Since the definition of impedance is the ratio of amplitudes of voltage and current

$$\frac{v}{i} = Z_{AB}$$

We can expect the amplitude of current through R and L to be a factor of 141 smaller than the voltage across them, with a phase difference of 45°:

Here's the CircuitLab simulation I used:

simulate this circuit

• "This value is not a simple real number; it's imaginary." // Actually, $s$ is in general complex, not purely imaginary. Oct 28, 2021 at 4:32
• "A real number cannot represent reactance, because reactance consists of two parts" // Actually, a real number can and does represent reactance. Reactance is a real number, despite being the imaginary part of impedance, the latter being a complex number. (Yes, the imaginary part of an imaginary or complex number is a real number.) Oct 28, 2021 at 4:37
• @AlejandroNava yeah, thanks, you're right, I've made changes. Oct 28, 2021 at 13:57

While you're trying to grok this, you may have to take several different approaches and see what works for you. Try this one.

In a resistive circuit, V is always proportional to I, with the ratio being the resistance, V=IR, with arbitrary signals. R is a pure number, though at this point we probably don't even think to make that observation. R is a ratio, it's the ratio of V to I, V/I.

In the particular case of a sinusoidal signal, Vt = Acos(2pift+phase), we can talk about its phase, at least with respect to another waveform of the same frequency. There's no need to do this in the resistive case of course because V=IR is always true.

When the circuit has an inductor or capacitor in it, then we notice the current through that component has a different phase to the voltage across it. It's a consistent phase difference, at any given frequency anyway.

If it's consistent, can we say anything about it mathematically? Well, let's just invent a number with phase, and see where it takes us, so we write V=IZ, where Z is our number with phase, and we've extended the concept of resistance into having a phase.

When complex numbers were first invented, there were howls of anguish and derision from mathematicians. That's one of the reasons the parts of a complex number are call real and imaginary. They were pointing out that these were not 'real' numbers and had just been imagined. So you're by no means the first person to find these an unsettling construct.

But if you just buckle in, and use them as they are defined, they simplify whole areas of mathematics and in particular electrical theory, with its inductors and capacitors.

I'm not sure I understand why electrical theory maps so nicely onto a 2D plane, but it does. Perhaps it's when you couple an inductor and a capacitor and let them resonate, then if the voltage is sine, the current is cosine, and plotting one against the other requires 2 dimensions, and you get a circle when you do it.

It's just so easy and intuitively informative to be able to add series impedances graphically by placing impedance vectors nose to tail on an Argand diagram.

They might click as you simply grind through equations, and you notice they always work. They might click when you notice that sine and cosine take you round a circle on the complex plane, on an Argand diagram. But hopefully, eventually they will click, because it will save you complexity when you can write out relationships between voltage and current as a single complex number, rather than having to resolve it onto orthogonal axes and use sine and cosine separately, or grapple with adding R-theta vector representations together.

Z as a complex impedance contains a "real" and an "imaginary" component. The monikers "real" and "imaginary" (numbers are after all concepts and thus a product of imagination anyway) already indicate that the imaginary part serves a specifically invented role different from the standard role.

When complex numbers are being used in physics, more often than not the imaginary component does not correspond to an actually measured quantity but is tacked on tracking something differently because the usual algebraic manipulations happen to do just the right thing when using complex number manipulation rules on the combined real and imaginary parts rather than just the real part.

Assuming 50 Hz AC, it turns out that if we turn Ohm's law $$\U = IR\$$ into $$\U = IZ\$$, then we can turn a capacitor's $$U = \int I \times C\ \mathrm{dt}$$ into $$\U = IZ_c\$$ with $$Z_c=\frac{1}{2\pi \times j \times 50\text{ Hz} \times C}$$ (I am using $$\j = \sqrt{-1}\$$ here, the EE convention) and turn an inductor's $$U = \mathrm{\frac{d}{dt}} I \times L$$ into $$\U = I Z_l\$$ with $$\Z_l=2 \pi \times j \times 50\text{ Hz} \times L\$$. And magically our algebraic equations covering resistor networks actually perfectly well predict the behavior of a network also containing inductors and capacitors when fed by voltages/currents of 50 Hz (not for any other frequency, but you can replace 50 Hz with a generic $$\f\$$ and at least get an answer in terms of $$\f\$$).

It is important to realise that this is nothing other than sleight of hand: any harmonic oscillation contains two forms of energy periodically getting converted into one another and when keeping track of those two components by putting them into one complex number, we can pretend to just track one component and store what is missing in the picture (but will return periodically) in the imaginary component.

While this trick only works at one frequency at a time, it works reliably enough that people trust it.

Even though it does break down.

Here is one example: Amplifiers will get rated with the output impedance they are designed to drive. Assuming analog technology, you can use that for calculating the maximum amount of current that the power transistors will have to provide. The problem is that the power transistors are delivering this current from power rails and the voltage across them is of opposite sign to the voltage on the speaker. So with a resistive load, they have the largest currents while having the lowest voltage across them, and they are turned off (in lieu of their counterpart on the other power rail doing the work) when the voltage on the output is of the opposite polarity.

While the output impedance at a given frequency correctly predicts the maximum currents into the speaker, the maximum power drawn from the power transistors can be determined only with the assumption that the load is mainly resistive.

This assumption falls down with significantly inductive or capacitive loads, like a bass speaker crossover with the actual speaker missing, leaving only a reactive load. Near the crossover frequency, the impedance will then be close to zero while voltages and currents will be out of phase: this can actually blow up an amplifier that is designed to withstand a short circuited output.

In AC circuits with constant frequency and without a DC voltage different from 0 V, the complex impedances tell the story so well that people put a similar amount of trust in them as the do in the real resistances.

• "Assuming 50 Hz AC, it turns out that if we turn Ohm's law $U = I \, R$ into $U = I \, Z$, then we can turn a capacitor's $U =\int I \times C \, \mathrm dt$ into $U = I \, Z_c$" // The equation containing the integral has instantaneous values for voltage and current, while the equation containing impedance has either phasors and (complex) impedance, or, the peak value or RMS value of the instantaneous voltage and current and the magnitude of the (complex) impedance. Oct 29, 2021 at 1:36

Impedance is the generalization of resistance, with reactive elements: inductance and capacitance.

How do these reactive elements ... ‘react’?

• Capacitors react to changes in voltage with an opposing current:
• faster voltage changes => higher current ($$\I = C {dV \over dt}\$$)
• higher frequency => lower impedance ($$\X_C = {1\over 2 \pi fC})\$$
• Inductors react to changes in current with an opposing voltage:
• faster current changes => greater voltage ($$\V = L{dI \over dt}\$$; $$\ I = {1 \over L} \int_0^T Vdt + I_0\$$)
• higher frequency => higher impedance ($$\X_L = 2\pi fL)\$$

(A wee bit o' math background... here.)

The effects of these elements will indeed change the relationship of AC voltage to current. So with each, they respond to a simple AC sine as follows:

• Capacitor: AC current will lead voltage
• Inductor: AC current will lag voltage
• and... Resistor: AC current will be in phase with voltage

You can find the detailed equations for these using complex math (complex in the real + imaginary sense) that are eye-watering at first if you’re not familiar with them. Such math-centric tutorials have their place, and as your knowledge and math skills grow they will make more sense.

But rather than drown in that math, here's an online simulator that will let you see how reactive circuits work.

The first sim shows how each type of impedance behaves. Feel free to edit the sim to your heart’s content, and check out the other examples.

But the current can still be calculated using I = V/Z, where Z is the impedance of the circuit. I don't understand this. How could the current be calculated using I = V/Z, even though I and source V are not in phase?

Think about a mechanical analogy of a resistor and a capacitor in series. For this analogy I'm going to use fluids and, in particular I'm asking you to consider a river or canal with a leaky lock-gate (many, many small holes). If the water levels on both side are the same then there is no flow of water through the lock-gate and, this is equivalent to a voltage source feeding a capacitor via a resistor. The capacitor voltage is the fluid level on the other side of the leaky lock-gate and, the flow of water is basically current.

If suddenly a whole load of water was emptied into the feed-side of the lock-gate, the in-feed level would rise instantly but, the level on the "capacitor" side would slowly rise and, after some time, it would reach the same level as the feed-side. This is the same as charging a capacitor via a resistor. I think you may already understand this mathematical exponential analogy.

But now, consider the fluid level on the in-feed side is varying in level sinusoidally. You don't have to figure out how that can be achieved so just assume it is done by special pumps that go in forward and reverse.

If the frequency of that changing fluid level is high, the fluid level changes on the capacitor side will be sinusoidal but, those changes will be clearly lower in amplitude compared to the in-feed side and there will be a clear time-lag between the in-feed side hitting maximum and the capacitor side hitting maximum. This is true of the resistor capacitor circuit mentioned previously.

But, that doesn't mean we can't ascribe a value of impedance to the flow through the leaky lock-gate caused by the in-feed level changes. Clearly the flow through the lock-gate is not "in-phase" with the in-feed water level and, this is because the flow is also governed by the out-feed level as well. This is also true for the resistor and capacitor.

We can define the impedance of the fluid system described above as the peak-to-peak fluid level change on the in-feed divided by the peak-to-peak water flow into the out-feed and, we don't have to care about the phase relationship between the two.

For this answer, whenever I say current, I specifically mean conventional current; and whenever I say resistor, capacitor or inductor, I specifically mean constant-resistance resistor, constant-capacitance capacitor and constant-inductance inductor, respectively. Since you're studying AC circuits, I'll assume you've already individually studied resistors, capacitors and inductors. I'll also assume you're familiar with derivatives, and with certain trigonometric identities.

First, let's recall some equations.

In a resistor, the instantaneous current through the resistor is directly proportional to the instantaneous voltage across the resistor:

$$\v(t) = R \, i(t) \tag 1\$$

In a capacitor, the instantaneous current through the capacitor is directly proportional to the time rate of change of the instantaneous voltage across the capacitor:

$$\i(t) = C \, \dfrac{\mathrm dv(t)}{\mathrm dt} \tag 2\$$

In an inductor, the instantaneous voltage across the inductor is directly proportional to the time rate of change of the instantaneous current through the inductor:

$$\v(t) = L \, \dfrac{\mathrm di(t)}{\mathrm dt} \tag 3\$$

Let's consider a resistor. Let's assume the instantaneous current through it is a sinusoid of the form $$\i(t) = I_\text{m} \cos{(\omega t + \phi_i)}\$$. Then, from equation (1), the instantaneous voltage across it is:

\\begin{align} v(t) &= R \, [I_\text{m} \cos{(\omega t + \phi_i)}] \\ &= R \, I_\text{m} \cos{(\omega t + \phi_i)} \tag 4 \end{align}\

that is, it is also a sinusoid of same frequency as the instantaneous current. The current is in phase in time with the voltage.

Next, in a capacitor, let's assume the instantaneous voltage across it is a sinusoid of the form $$\v(t) = V_\text{m} \cos{(\omega t + \phi_v)}\$$. Then, from equation (2), the instantaneous current through it is:

\\begin{align} i(t) &= C \, \dfrac{\mathrm d}{\mathrm dt} [V_\text{m} \cos{(\omega t + \phi_v)}] \\ &= C \, [- \omega \, V_\text{m} \sin{(\omega t + \phi_v)}] \\ &= - C \, \omega \, V_\text{m} \cos{(\omega t + \phi_v - 90^\circ)} \\ &= C \, \omega \, V_\text{m} \cos{(\omega t + \phi_v - 90^\circ + 180^\circ)} \\ &= C \, \omega \, V_\text{m} \cos{(\omega t + \phi_v + 90^\circ)} \tag 5 \end{align}\

that is, it is also a sinusoid of same frequency as the instantaneous voltage. The current leads the voltage by 90° in time.

Next, in an inductor, let's assume the instantaneous current through it is a sinusoid of the form $$\i(t) = I_\text{m} \cos{(\omega t + \phi_i)}\$$. Then, from equation (3), the instantaneous voltage across it is:

\\begin{align} v(t) &= L \, \dfrac{\mathrm d}{\mathrm dt} [I_\text{m} \cos{(\omega t + \phi_i)}] \\ &= L \, [- \omega \, I_\text{m} \sin{(\omega t + \phi_i)}] \\ &= - L \, \omega \, I_\text{m} \cos{(\omega t + \phi_i - 90^\circ)} \\ &= L \, \omega \, I_\text{m} \cos{(\omega t + \phi_i - 90^\circ + 180^\circ)} \\ &= L \, \omega \, I_\text{m} \cos{(\omega t + \phi_i + 90^\circ)} \tag 6 \end{align}\

that is, it is also a sinusoid of same frequency as the instantaneous current. The voltage leads the current by 90° in time, or equivalently the current lags the voltage by 90° in time.

From equations (4) to (6), we can see that whenever we apply a sinusoidal current or voltage to a resistor, capacitor or inductor, the resulting voltage or current is also sinusoidal of same frequency. Keep this fact in mind. Let's call this observation #1. (Actually, this is true after some time has passed, and the so-called transients have decayed to zero and steady-state has been reached, but let's ignore this.)

Also, as you may know, we can combine sinusoids of different amplitude and different phase angle but same frequency into one sinusoid of different amplitude, different phase angle but also same frequency. Read this page if you don't know. Let's call this observation #2.

Kirchhoff's voltage law states that a sum of instantaneous voltages is zero, and Kirchhoff's current law states that a sum of instantaneous currents is zero:

$$\\displaystyle\sum_{n=1}^{N} v_n(t) = 0 \tag 7\$$

$$\\displaystyle\sum_{n=1}^{N} i_n(t) = 0 \tag 8\$$

In a circuit that consists only of resistors, inductors, capacitors, and independent sinusoidal voltage and current sources of same frequency, Kirchhoff's laws along with observation #1 indicate that in AC circuits, we will be summing instantaneous voltages and currents of same frequency. Let's call this observation #3. These sums of sinusoidal signals will result in signals that are also sinusoidal and of same frequency, as we saw in observation #2.

As you may know, a sinusoidal signal of the form $$\x(t) = X_\text{m} \cos{(\omega t + \phi)}\$$, which is really a real function of real variable, can be partially represented as a complex constant of the form $$\{\tilde X} = X_\text{m} e^{j \phi} = X_\text{m} \, \angle \phi = X_\text{m} \cos{(\phi)} + j \sin{(\phi)}\$$, called a phasor. The relationship between a phasor and its corresponding signal is $$\x(t) = \Re{[{\tilde X} \, e^{j \omega t}]}\$$.

Notice the phasor does not include the cyclic frequency or angular frequency of the signal, and thus, doesn't completely represent the signal. But this doesn't matter because as we saw, all signals in an AC circuit consisting of independent sources of same frequency, resistors, capacitors and inductors, will have the same frequency.

(Complex) impedance is defined as the ratio of phasor voltage to phasor current:

$$\{\hat Z} = \dfrac{\tilde V}{\tilde I} \tag 9\$$

Let's find the (complex) impedance of the three passive elements.

For a resistor, in equation (4), the instantaneous current is $$\i(t) = I_\text{m} \cos{(\omega t + \phi_i)}\$$, which can be written as $$\i(t) = \Re{[{\tilde I} \, e^{j \omega t}]}\$$, where the phasor current is:

$$\{\tilde I} = I_\text{m} \, e^{j \phi_i}; \tag*{}\$$

and the instantaneous voltage is $$\v(t) = R \, I_\text{m} \cos{(\omega t + \phi_i)}\$$, which can be written as $$\v(t) = \Re{[{\tilde V} \, e^{j \omega t}]}\$$, where the phasor voltage is:

$$\{\tilde V} = R \, I_\text{m} \, e^{j \phi_i}. \tag*{}\$$

Thus, the (complex) impedance of a resistor is:

\\begin{align} {\hat Z} &= \dfrac{R \, I_\text{m} \, e^{j \phi_i}}{I_\text{m} \, e^{j \phi_i}} \\ &= R = R \, \angle 0^\circ \tag {10} \end{align}\

Next, for a capacitor, in equation (5) the instantaneous voltage is $$\v(t) = V_\text{m} \cos{(\omega t + \phi_v)}\$$, which can be written as $$\v(t) = \Re{[{\tilde V} \, e^{j \omega t}]}\$$, where the phasor voltage is:

$$\{\tilde V} = V_\text{m} \, e^{j \phi_v}; \tag*{}\$$

and the instantaneous current is $$\i(t) = C \, \omega \, V_\text{m} \cos{(\omega t + \phi_v + 90^\circ)}\$$, which can be written as $$\i(t) = \Re{[{\tilde I} e^{j \omega t}]}\$$, where the phasor current is:

$$\{\tilde I} = C \, \omega \, V_\text{m} e^{j (\phi_v + 90^\circ)}. \tag*{}\$$

Thus, the (complex) impedance of a capacitor is:

\\begin{align} {\hat Z} &= \dfrac{V_\text{m} \, e^{j \phi_v}}{C \, \omega \, V_\text{m} \, e^{j (\phi_v + 90^\circ)}} \\ &= \dfrac{1}{C \, \omega \, e^{j 90^\circ}} \\ &= \dfrac{1}{j \, \omega \, C} = -\dfrac{j}{\omega \, C} = \dfrac{1}{\omega \, C} \, \angle -90^\circ \tag {11} \end{align}\

Next, for an inductor, in equation (6) the instantaneous current is $$\i(t) = I_\text{m} \cos{(\omega t + \phi_i)}\$$, which can be written as $$\i(t) = \Re{[{\tilde I} \, e^{j \omega t}]}\$$, where the phasor current is:

$$\{\tilde I} = I_\text{m} \, e^{j \phi_i}; \tag*{}\$$

and the instantaneous voltage is $$\v(t) = L \, \omega \, I_\text{m} \cos{(\omega t + \phi_i + 90^\circ)}\$$, which can be written as $$\v(t) = \Re{[{\tilde V} e^{j \omega t}]}\$$, where the phasor voltage is:

$$\{\tilde V} = L \, \omega \, I_\text{m} \, e^{j (\phi_i + 90^\circ)}. \tag*{}\$$

Thus, the (complex) impedance of an inductor is:

\\begin{align} {\hat Z} &= \dfrac{L \, \omega \, I_\text{m} \, e^{j (\phi_i + 90^\circ)}}{I_\text{m} \, e^{j \phi_i}} \\ &= L \, \omega \, e^{j 90^\circ} \\ &= j \, \omega \, L = \omega \, L \, \angle 90^\circ \tag {12} \end{align}\

If you inspect equations (10) to (12), you'll see in equation (9), the phase angle between the instantaneous current and instantaneous voltage of a resistor, capacitor and inductor is taken into account in the phase angle of the (complex) impedance. I think this answers your question:

How could the current be calculated using I = V/Z, even though I and source V are not in phase?

In case you're referring to the amplitudes/peak values/maximum values, then take the magnitude of the (complex) impedance of equation (9):

\\begin{align}|{\hat Z}| &= \left| \dfrac{\tilde V}{\tilde I} \right| \\ &= \dfrac{|\tilde V|}{|\tilde I|} \\ &= \dfrac{|V_\text{m} \, e^{j \phi_v}|}{|I_\text{m} \, e^{j \phi_i}|} \\ &= \dfrac{V_\text{m}}{I_\text{m}} \tag {13} \end{align},\

and there you have it, the previous equation shows that we can calculate the magnitude of the (complex) impedance simply as the ratio of the peak voltage to the peak current.

In case you're referring to the RMS/effective values, then recall the RMS value of a sinusoidal signal is $$\X_\text{RMS} = X_\text{m}/\sqrt{2}\$$, from which we get the peak value as $$\X_\text{m} = \sqrt{2} \, X_\text{RMS}\$$. Substituting this in equation (13):

\\begin{align}|{\hat Z}| &= \dfrac{\sqrt{2} \, V_\text{RMS}}{\sqrt{2} \, I_\text{RMS}} \\ &= \dfrac{V_\text{RMS}}{I_\text{RMS}} \tag {14} \end{align},\

and there you have it, the previous equation shows that we can calculate the magnitude of the (complex) impedance simply as the ratio of the RMS voltage to the RMS current.

Note that in equations (13) and (14), the phase angles aren't needed; we only work with magnitudes in those equations.

Equation (9) is Ohm's law generalized to the phasor domain. Let's check if Kirchhoff's laws generalize to the phasor domain. KVL states that:

$$\\displaystyle\sum_{n=1}^{N} v_n(t) = v_1(t) + v_2(t) + \cdots + v_N(t) = 0 \tag*{}\$$

In AC circuits, as we saw all voltages will have the same frequency, so we can write the previous instantaneous voltages in terms of their phasors:

\\begin{align} 0 &= \Re[{\tilde V_1} \, e^{j \omega t}] + \Re[{\tilde V_2} \, e^{j \omega t}] + \cdots + \Re[{\tilde V_N} \, e^{j \omega t}] \\ &= \Re[{\tilde V_1} \, e^{j \omega t} + {\tilde V_2} \, e^{j \omega t} + \cdots + {\tilde V_N} \, e^{j \omega t}] \\ &= \Re[({\tilde V_1} + {\tilde V_2} + \cdots + {\tilde V_N}) e^{j \omega t}] \tag*{} \end{align}\

The previous equation says that (the real part of) the product of the factors $$\({\tilde V_1} + {\tilde V_2} + \cdots + {\tilde V_N})\$$ and $$\e^{j \omega t}\$$ is zero, therefore one (or both) of those factors must be zero. But $$\e^{j \omega t}\$$ is never zero, so the first factor must be zero:

$$\{\tilde V_1} + {\tilde V_2} + \cdots + {\tilde V_N} = \displaystyle\sum_{n=1}^{N} {\tilde V}_n = 0, \tag*{}\$$

which has the same form as KVL for instantaneous voltages! So KVL holds true for phasors. The same can be said about KCL.

So, we can use generalized Ohm's law and Kirchhoff's laws to analyze and design AC circuits, by using complex numbers.