Does the equation

$$A\cos(\theta) + B\sin(\theta) = \sqrt{A^2+B^2}\cos(\theta + \gamma) \label{1} \tag{1}$$

with $\gamma = \arg(A-jB)$

require that $A$ and $B$ be real, or can they be complex?

Consider the case $B= jA$ which results in:

$$A\cos(\theta) + jA\sin(\theta) = Ae^{j\theta}$$

Using $\ref{1}$ this results in:

$$=\sqrt{A^2-A^2}\cos(\theta + arg(2A)) = 0$$

Which appears to confirm the answer is no. So then, is there a unified relationship for $A\cos(\theta) + B\sin(\theta)$ that is closest to the form of \ref{1} and allows $A$ and $B$ to be real, imaginary or complex: $A, B \in \mathbb{C}$, $\theta \in \mathbb{R}$ (and \ref{1} is just a simplification of this for A, B real)?

I got this far toward a geometric solution with two cases with A and B both real and with A real and B imaginary as shown below in case this helps toward the analytic result, along with subsequent more significant progress which I provided as an answer. However I would be very interested in a more concise formulation toward a solution or comments on how the answer I provided may be further simplified (toward the form in \ref{1}).

$$A\cos(\theta) + B\sin(\theta)$$

$$= \frac{A}{2}e^{j\theta} + \frac{A}{2}e^{-j\theta} + \frac{B}{2j}e^{j\theta} - \frac{B}{2j}e^{-j\theta}$$ $$= \frac{A}{2}e^{j\theta} + \frac{A}{2}e^{-j\theta} - \frac{jB}{2}e^{j\theta} + \frac{jB}{2}e^{-j\theta}$$

Case with A, B real to confirm known relationship resulting in $A\cos(\theta) + B\sin(\theta) = \sqrt{A^2+B^2}\cos(\theta + \gamma)$:

A, B real

Case with real A and imaginary B resulting in $\frac{A+jB}{2}\cos(\theta) - jBe^{j\theta}$:

A real, B imaginary

  • $\begingroup$ @OverLordGoldDragon Ah yes it does! thanks-- that's a little more mathematically comforting. $\endgroup$ Commented Sep 25, 2020 at 3:25
  • $\begingroup$ Somewhat related, I was playing around this this today; maybe it can help. Interesting question, I'll see if I find anything. $\endgroup$ Commented Sep 25, 2020 at 3:27
  • $\begingroup$ @OverLord What's interesting and perhaps a clue is the sinusoids with complex angles such as $cos(a+jb)$ and when the angle is completely complex it is $cosh(\theta)$. That's where I thought that maybe $A\cos(\theta)+jAsin(\theta)$ with real A which is equal to $Ae^{j\theta}$ could in fact be expressed as a single sinusoidal equation in the form of $Kcos(x)$ where $K$ and $x$ are complex. $\endgroup$ Commented Sep 25, 2020 at 3:57
  • 1
    $\begingroup$ Note that if $A$ and $B$ are complex numbers then $\sqrt{A^2 + B^2}$ is multi-valued. $\endgroup$
    – S.H.W
    Commented Sep 25, 2020 at 15:43
  • 1
    $\begingroup$ One more fact if it helps: $$A\cos(\theta) + B\sin(\theta) = (a+bj)\cos(\theta) + (c+dj)\sin(\theta) = (a\cos(\theta) + c\sin(\theta)) + j(b\cos(\theta) + d\sin(\theta)) = \sqrt{a^2 +c^2}\cos(\theta - x_1) + j\sqrt{b^2 +d^2}\cos(\theta - x_2)$$ Where $\tan(x_1) = \frac{c}{a}$ and $\tan(x_2) = \frac{d}{b}$. $\endgroup$
    – S.H.W
    Commented Sep 25, 2020 at 18:01

2 Answers 2


The relationship given in \ref{22} below (highlighted) is derived as follows:

$$\vec{Z} = \vec{A} \cos(\theta) + \vec{B} \sin(\theta) \tag{1} \label{1a}$$

With $ \vec{Z}, \vec{A}, \vec{B} \in \mathbb{C}$ as:

$$\vec{A} = \alpha + j\delta \tag{2} \label{2}$$ $$\vec{B} = \beta + j\epsilon \tag{3} \label{3}$$

With $\alpha, \beta, \delta, \epsilon, \theta \in \mathbb{R} $

Using the relationships $\cos(\theta) = (e^{j\theta}+e^{-j\theta})/2$ and $\sin(\theta) =(e^{j\theta}-e^{-j\theta})/(2j)$ in \ref{1a} results in:

$$Z = (\alpha + j\delta)\frac{e^{j\theta}+e^{-j\theta}}{2} + (\beta + j\epsilon)\frac{e^{j\theta}-e^{-j\theta}}{2j} $$

$$ = \frac{1}{2}e^{j\theta}((\alpha + \epsilon)+j(\delta-\beta)) + \frac{1}{2}e^{-j\theta}((\alpha - \epsilon)+j(\delta+\beta))$$

$$ = e^{j\theta}V_1e^{j\phi_1} + e^{-j\theta}V_2e^{j\phi_2} \tag{4} \label{4}$$

With $V_1, V_2 \in \mathbb{R}$ as

$$2V_1e^{j\phi_1} = ((\alpha + \epsilon)+j(\delta-\beta))\tag{5} \label{5}$$

$$2V_2e^{j\phi_2} = ((\alpha - \epsilon)+j(\delta+\beta))\tag{6} \label{6}$$

From \ref{5}, \ref{6}:

$$2V_1 = \sqrt{(\alpha+\epsilon)^2+(\delta-\beta)^2}\tag{7} \label{7}$$

$$\phi_1 = \text{atan2}(\delta-\beta, \alpha+ \epsilon)\tag{8} \label{8}$$

$$2V_2 = \sqrt{(\alpha-\epsilon)^2+(\delta+\beta)^2}\tag{9} \label{9}$$

$$\phi_2 = \text{atan2}(\delta+\beta, \alpha- \epsilon)\tag{10} \label{10}$$

Also note the following:

$$\vec{A}-j\vec{B} = \alpha + j\delta - j(\beta + j\epsilon) = (\alpha + \epsilon) + j(\delta - \beta) = 2V_1e^{j\phi_1} \tag{11} \label{11}$$

$$\vec{A}+j\vec{B} = \alpha + j\delta + j(\beta + j\epsilon) = (\alpha - \epsilon) + j(\delta + \beta) = 2V_2e^{j\phi_2} \tag{12} \label{12}$$

As a verification of the relationships derived thus far, we view the following geometric graphic showing an example $\vec{A}$, $\vec{B}$ in the first quadrant for $\theta = 0$ showing the resulting vectors from \ref{11} and \ref{12}:

theta = 0

Which is consistent with the the relationship from \ref{1a} and \ref{4} for $\theta =0$:

$$\vec{Z} = \vec{A}\cos(\theta)+\vec{B}\sin(\theta) = \vec{A}\cos(0)+B\sin(0) = \vec{A}$$ $$\vec{Z} = e^{j\theta}V_1e^{j\phi_1} + e^{-j\theta}V_2e^{j\phi_2} = e^{j0}V_1e^{j\phi_1} + e^{-j0}V_2e^{j\phi_2}= V_1e^{j\phi_1} + V_2e^{j\phi_2} $$

With $\theta =0$ the above solution is trivial resulting in $\vec{A}$ as expected, but we can use this graphic to recognize what would occur for increasing $\theta$ and how to then frame the problem to describe the final result as a sinusoid plus an exponential. This is demonstrated starting with the graphic immediately below which shows the vectors reduced by half as in the equation for $\vec{Z}$ and adds a positive valued $\theta$, where the final result $\vec{Z}$ would be the sum of the two blue vectors shown.

Z with theta

We can then decompose this into complex conjugate vectors (sinusoid), and complex phase components by viewing the larger of the two vectors as a sum of a vector of identical magnitude to the smaller vector plus a residual, and then finding the bisecting angle between these two vectors since they would be in complex conjugate phase from that angle:

identifying components

Resulting in the following decomposition:


As the above graphics illustrate,

$$\vec{Z} = e^{j\bar\phi}\big(2V_2\cos(\gamma)+(V_1-V_2)e^{-j\gamma}\big) \tag{13} \label{13}$$


$$\bar\phi = \frac{\phi_2+\phi_1}{2} \tag{14} \label{14}$$

$$\gamma = \phi_2+\theta - \bar\phi = \theta + \frac{\phi_2-\phi_1}{2} \tag{15} \label{15} $$

Using \ref{15} in \ref{13}:

$$ \vec{Z} = e^{j\bar\phi}\bigg(2V_2\cos(\theta + \phi_\Delta/2)+ (V_1-V_2)e^{-j(\theta + \phi_\Delta/2)}\bigg) \tag{16} \label{16}$$


$$\phi_\Delta = \phi_2-\phi_1$$

with $\phi_1$ and $\phi_2$ as given in \ref{8} and \ref{10}, and $V_1$ and $V_2$ as given in \ref{7} and \ref{9}.

From \ref{16}:

$$ \vec{Z} =2V_2 e^{j\bar\phi} \cos(\theta + \phi_\Delta/2) + (V_1-V_2)e^{-j(\theta + \phi_\Delta/2 - \bar\phi)}\tag{17} \label{17}$$

Note that the argument:

$$\theta + \phi_\Delta/2 - \bar\phi = \theta + \frac{(\phi_2-\phi_1)}{2} - \frac{(\phi_1+\phi_2)}{2} = \theta - \phi_1$$

Which is consistent with the figure, thus \ref{17} simplifies further to:

$$\vec{Z} = 2V_2 e^{j\bar\phi}\cos(\theta + \phi_\Delta/2) + (V_1-V_2)e^{-j(\theta -\phi_1)}\tag{18} \label{18}$$

This is put into the original units of $\vec{A}, \vec{B}$ as follows:

From \ref{11} and \ref{12} and depicted in the first graphic:

$$V_1 = \frac{\Vert\vec{A}-j\vec{B}\Vert}{2} \tag{19} \label{19}$$

$$V_2 = \frac{\Vert\vec{A}+j\vec{B}\Vert}{2}\tag{20} \label{20}$$

From which we get:

$$V_1-V_2 =\frac{\Vert\vec{A}-j\vec{B}\Vert-\Vert\vec{A}+j\vec{B}\Vert}{2}\tag{21} \label{21}$$

By substituting \ref{20} and \ref{21} in \ref{17} we get the final result:

$$ \bbox[yellow]{\vec{Z} =\vec{A}\cos(\theta)+\vec{B}\sin(\theta) = \\ \Vert\vec{A}+j\vec{B}\Vert e^{j\bar\phi}\cos(\theta + \phi_\Delta/2) + \frac{\Vert\vec{A}-j\vec{B}\Vert-\Vert\vec{A}+j\vec{B}\Vert}{2}e^{-j(\theta -\phi_1)}}\tag{22} \label{22}$$

The angle $\bar\phi$ is the bisecting angle of $V_1e^{j\phi_1}$ and $V_2e^{j\phi_2}$ which is determined by normalizing both:

$$\bar\phi = \frac{1}{2}\arg\bigg(\frac{\vec{A}-j\vec{B}}{\Vert\vec{A}-j\vec{B}\Vert}+\frac{\vec{A}+j\vec{B}}{\Vert\vec{A}+j\vec{B}\Vert}\bigg) \tag{23} \label{23}$$

Similarly we could multiply the inner expression by $\Vert\vec{A}+j\vec{B}\Vert \Vert\vec{A}-j\vec{B}\Vert$ which is just a scaling so does not change the argument but results in this alternate relationship:

$$\bar\phi = \frac{1}{2}\arg\bigg(\frac{\vec{A}-j\vec{B}}{\Vert\vec{A}+j\vec{B}\Vert} + \frac{\vec{A}+j\vec{B}}{\Vert\vec{A}-j\vec{B}\Vert}\bigg) \tag{24} \label{24}$$

Perhaps simpler is just the sum of the angles derived from \ref{11} and \ref{12} to be:

$$ \bar\phi = \frac{\arg(\vec{A}+j\vec{B})+\arg(\vec{A}-j\vec{B})}{2} \tag{25} \label{25}$$

resulting in:

$$\bbox[yellow]{\bar\phi = \frac{\text{atan2}(\delta+\beta, \alpha-\epsilon)+ \text{atan2}(\delta-\beta,\alpha+\epsilon)}{2}}\tag{26} \label{26}$$

And similarly for $\phi_\Delta$:

$$\frac{\phi_\Delta}{2} = \frac{1}{2}\arg\bigg(\frac{\vec{A}+j\vec{B}}{\Vert\vec{A}-j\vec{B}\Vert}-\frac{\vec{A}-j\vec{B}}{\Vert\vec{A}+j\vec{B}\Vert}\bigg) \tag{27} \label{27}$$

or equivalently from \ref{11} and {12} as done in \ref{26}:

$$\frac{\phi_\Delta}{2} = \frac{\arg(\vec{A}+j\vec{B})-\arg(\vec{A}-j\vec{B})}{2} \tag{28} \label{28}$$

resulting in:

$$\bbox[yellow]{\frac{\phi_\Delta}{2} = \frac{\text{atan2}(\delta+\beta, \alpha-\epsilon)- \text{atan2}(\delta-\beta,\alpha+\epsilon)}{2}}\tag{29} \label{29}$$

And from \ref{11}:

$$\bbox[yellow]{\phi_1 = \arg(\vec{A}-j\vec{B})=\text{atan2}(\delta-\beta,\alpha+\epsilon)}\tag{30} \label{30}$$

Thus \ref{22} with \ref{26}, \ref{29}, and \ref{30} we have a relationship similar to $A\cos(\theta) + B\sin(\theta)= \sqrt{A^2+B^2}cos(\theta + \gamma)$ expanded for complex $A, B$. I still need to confirm the final result is accurate and it can be further simplified. (so still working on it when I can get back to this, and encourage others to post other derivations that can get to this result more concisely).

UPDATE: S.H.W.'s solution is the simple and elegant solution I was looking for that this (if correct) will be equivalent to (I just couldn't see at first how simple it was). Note if we selected a circle or radius $(V_1+V_2)/2$ as reference in the red circled figure (third graphic) this would result in a rotated real and imaginary sine wave matching that result. I will eventually update this to show the graphics and the solution with a reference using the inner, outer and average radius.

Additional equations that may or may not help above:

I don't see how the following helps yet but including for reference case it leads to further simplification:

Note that the inner terms of \ref{22} and \ref{23} represent the sides of a parallelogram that have been normalized and therefore the magnitude of this summation from the generalized relationship $c^2 = a^2+b^2-2ab\cos(\text{angle})$ of the sides to the diagonal for a parallelogram equals:

$$\bigg\Vert\frac{\vec{A}-j\vec{B}}{\Vert\vec{A}+j\vec{B}\Vert} + \frac{\vec{A}+j\vec{B}}{\Vert\vec{A}-j\vec{B}\Vert}\bigg\Vert = \sqrt{ 2-2\cos(\bar\phi)} \tag{31} \label{31}$$

  • $\begingroup$ So the resulting format's in Eq 16, which uses complex sinusoids (would be useful to write the version in terms of A and B you found in later equations). And what's the utility of this relation? Perhaps the answer's in the diagrams which I've yet to explore, but an explicit statement would help. (Also, what software do you use for these diagrams?) $\endgroup$ Commented Sep 27, 2020 at 3:07
  • $\begingroup$ @OverLordGoldDragon yes that is ultimately what I want; in terms of A and B in its simplest form and closest to the form of the original relationship presented. I should do that to show where I left off but I feel those final relationships after 16 may still be further simplified. The diagrams were done in PowerPoint. I also still need to validate that it is correct- so in process. Also I wouldn’t be surprised if there is a much easier way to get to the same resulting equation. $\endgroup$ Commented Sep 27, 2020 at 12:15
  • $\begingroup$ @OverLordGoldDragon but Eq 18 is progressed beyond 16 so if anything that one would have been boxed. $\endgroup$ Commented Sep 27, 2020 at 12:27
  • 2
    $\begingroup$ @DanBoschen Nice answer and illustrations! Curiously your first formula which is $\vec{Z} = \vec{A} \cos(\theta) + \vec{B} \sin(\theta)$ isn't shown properly and I couldn't fix it. $\endgroup$
    – S.H.W
    Commented Sep 28, 2020 at 9:08
  • $\begingroup$ I see, so you found the general case in (22); may be interesting to see a magnitude/phase plot for A, B varying over the complex planes, but that makes the input space alone 5D. A trick would be plotting Acos and Bsin separately then relating via superposition, but $\theta$ demands a third spatial input dimension for each; slicing $\theta$ only reveals plane tilts -- Anyway, confirmed no Kcos(x) $\endgroup$ Commented Sep 29, 2020 at 6:55

Let $A , B \in \mathbb{C}$, we have $$Z = A\cos(\theta) + B\sin(\theta) = (a+bj)\cos(\theta) + (c+dj)\sin(\theta) = (a\cos(\theta) + c\sin(\theta)) + j(b\cos(\theta) + d\sin(\theta)) = \sqrt{a^2 +c^2}\cos(\theta - x_1) + j\sqrt{b^2 +d^2}\cos(\theta - x_2)$$

Where $\tan(x_1) = \frac{c}{a}$ and $\tan(x_2) = \frac{d}{b}$. Note that here real and imaginary parts are independent of each other and it's enough to study $$f(a,b ,\theta) = \sqrt{a^2+b^2}\cos(\theta - x) = \sqrt{a^2+b^2}\mathrm{Re} (e^{-jx}e^{j\theta}) ,\ \ \ \ \tan(x) = \frac{b}{a}$$ So we can represent each of $\mathrm{Re}(Z)$ and $\mathrm{Im}(Z)$ by a phasor.

  • $\begingroup$ I think $\mathrm{Re} (x)$ and $\text{Im} (y)$ looks better..... \mathrm or \text $\endgroup$ Commented Sep 29, 2020 at 12:21
  • 1
    $\begingroup$ @AnindyaPrithvi Thanks. $\endgroup$
    – S.H.W
    Commented Sep 29, 2020 at 15:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .