Complex Number Calculator

#cd-complex-number-calculator{max-width:980px;margin:0 auto;font-family:Arial,sans-serif;color:#1f2937;line-height:1.65}#cd-complex-number-calculator *{box-sizing:border-box}#cd-complex-number-calculator h2,#cd-complex-number-calculator h3{color:#111827;line-height:1.3}#cd-complex-number-calculator h2{margin:0 0 10px;font-size:28px}#cd-complex-number-calculator h3{margin:28px 0 10px;font-size:21px}#cd-complex-number-calculator p{margin:8px 0 14px}#cd-complex-number-calculator .cd-cn-category{display:inline-block;margin:0 0 14px;padding:4px 10px;border-radius:999px;background:#eef2ff;color:#3730a3;font-size:13px;font-weight:700}#cd-complex-number-calculator .cd-cn-tool{background:#f8fafc;border:1px solid #dbe2ea;border-radius:14px;padding:22px;margin:14px 0 26px}#cd-complex-number-calculator .cd-cn-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}#cd-complex-number-calculator .cd-cn-number{background:#fff;border:1px solid #e2e8f0;border-radius:10px;padding:16px}#cd-complex-number-calculator .cd-cn-number h3{font-size:17px;margin:0 0 12px}#cd-complex-number-calculator .cd-cn-fields{display:grid;grid-template-columns:1fr 1fr;gap:12px}#cd-complex-number-calculator label{display:block;font-size:14px;font-weight:700;margin-bottom:5px}#cd-complex-number-calculator input,#cd-complex-number-calculator select{width:100%;min-height:46px;padding:10px 12px;border:1px solid #b8c2ce;border-radius:8px;background:#fff;color:#111827;font-size:16px}#cd-complex-number-calculator input:focus,#cd-complex-number-calculator select:focus{outline:2px solid #6366f1;outline-offset:1px;border-color:#6366f1}#cd-complex-number-calculator .cd-cn-controls{display:grid;grid-template-columns:2fr 1fr;gap:14px;margin-top:18px}#cd-complex-number-calculator .cd-cn-buttons{display:flex;flex-wrap:wrap;gap:10px;margin-top:18px}#cd-complex-number-calculator button{min-height:44px;padding:10px 16px;border:0;border-radius:8px;font-size:15px;font-weight:700;cursor:pointer}#cd-complex-number-calculator .cd-cn-calc{background:#3730a3;color:#fff}#cd-complex-number-calculator .cd-cn-secondary{background:#e5e7eb;color:#1f2937}#cd-complex-number-calculator .cd-cn-copy{background:#e0e7ff;color:#312e81}#cd-complex-number-calculator button:hover{filter:brightness(.97)}#cd-complex-number-calculator .cd-cn-error{display:none;margin-top:16px;padding:11px 13px;border-radius:8px;background:#fff1f2;border:1px solid #fecdd3;color:#9f1239;font-weight:600}#cd-complex-number-calculator .cd-cn-result{margin-top:18px;padding:20px;border-radius:12px;background:#eef2ff;border:1px solid #c7d2fe}#cd-complex-number-calculator .cd-cn-result-label{font-size:13px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:#4338ca}#cd-complex-number-calculator .cd-cn-main-result{font-size:30px;font-weight:800;color:#1e1b4b;margin:5px 0 12px;overflow-wrap:anywhere}#cd-complex-number-calculator .cd-cn-result-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:9px 18px}#cd-complex-number-calculator .cd-cn-result-item{background:#fff;border-radius:7px;padding:9px 11px;border:1px solid #e0e7ff;overflow-wrap:anywhere}#cd-complex-number-calculator .cd-cn-result-item span{display:block;font-size:12px;color:#64748b;margin-bottom:2px}#cd-complex-number-calculator .cd-cn-section{border-top:1px solid #e5e7eb;padding-top:3px;margin-top:24px}#cd-complex-number-calculator .cd-cn-formula{background:#f8fafc;border-left:4px solid #6366f1;padding:13px 15px;margin:10px 0;border-radius:0 8px 8px 0;overflow-wrap:anywhere}#cd-complex-number-calculator ul,#cd-complex-number-calculator ol{padding-left:23px}#cd-complex-number-calculator li{margin:6px 0}#cd-complex-number-calculator details{border:1px solid #dbe2ea;border-radius:8px;padding:0 14px;margin:9px 0;background:#fff}#cd-complex-number-calculator summary{cursor:pointer;font-weight:700;padding:13px 0;color:#111827}#cd-complex-number-calculator details p{padding-bottom:12px;margin:0}#cd-complex-number-calculator .cd-cn-related a{font-weight:700;color:#3730a3;text-decoration:underline}#cd-complex-number-calculator .cd-cn-note{font-size:14px;color:#64748b}@media(max-width:680px){#cd-complex-number-calculator h2{font-size:24px}#cd-complex-number-calculator .cd-cn-tool{padding:15px}#cd-complex-number-calculator .cd-cn-grid,#cd-complex-number-calculator .cd-cn-fields,#cd-complex-number-calculator .cd-cn-controls,#cd-complex-number-calculator .cd-cn-result-grid{grid-template-columns:1fr}#cd-complex-number-calculator .cd-cn-buttons{display:grid;grid-template-columns:1fr 1fr}#cd-complex-number-calculator button{width:100%}#cd-complex-number-calculator .cd-cn-main-result{font-size:25px}}

Complex Number Calculator

Use this Complex Number Calculator to add, subtract, multiply, or divide two complex numbers written in the form a + bi. The result also includes its conjugate, magnitude, argument, and polar form.

Algebra

First complex number: z₁ = a + bi

Second complex number: z₂ = c + di

Add: z₁ + z₂ Subtract: z₁ − z₂ Multiply: z₁ × z₂ Divide: z₁ ÷ z₂
2 4 6 10
Multiplication result
11 − 2i
Real part11
Imaginary part-2
Conjugate11 + 2i
Magnitude |z|11.18034
Argument-10.304846°
Polar form11.18034(cos(-10.304846°) + i sin(-10.304846°))

What the result means

A complex number has a real part and an imaginary part. If the calculator returns 11 − 2i, the real part is 11 and the imaginary coefficient is −2.

The magnitude measures the distance from the origin to the complex number on the complex plane. The argument gives its direction as an angle measured from the positive real axis.

Complex number formulas

Let the two numbers be z₁ = a + bi and z₂ = c + di, where i² = −1.

Addition:
(a + bi) + (c + di) = (a + c) + (b + d)i
Subtraction:
(a + bi) − (c + di) = (a − c) + (b − d)i
Multiplication:
(a + bi)(c + di) = (ac − bd) + (ad + bc)i
Division:
(a + bi) ÷ (c + di) = [(ac + bd) + (bc − ad)i] ÷ (c² + d²)
Magnitude:
|z| = √(x² + y²), for z = x + yi
Argument:
θ = atan2(y, x)
Polar form:
z = r(cos θ + i sin θ), where r = |z|

How to use the calculator

  1. Enter the real and imaginary parts of the first complex number.
  2. Enter the real and imaginary parts of the second complex number.
  3. Select addition, subtraction, multiplication, or division.
  4. Choose how many decimal places you want displayed.
  5. Select Calculate to see the rectangular and polar results.
  6. Use Copy Result when you want to copy the displayed complex number.

You do not need to type the letter i. Enter only its numerical coefficient in the imaginary-part field. For example, enter −5 for the imaginary part of 2 − 5i.

Worked example: multiplying two complex numbers

Suppose z₁ = 3 + 4i and z₂ = 1 − 2i.

Using the multiplication formula:

(3 + 4i)(1 − 2i)

The real part is:

(3 × 1) − (4 × −2) = 3 + 8 = 11

The imaginary part is:

(3 × −2) + (4 × 1) = −6 + 4 = −2

Therefore, the product is 11 − 2i. Its magnitude is √125, or about 11.18034.

Where complex number calculations are used

  • Algebra: solving equations that have no real-number solution.
  • Electrical calculations: representing quantities with magnitude and phase.
  • Signal analysis: working with sinusoidal signals and frequency-domain values.
  • Geometry: representing rotations, positions, and transformations on a plane.
  • Education: checking arithmetic while learning rectangular and polar forms.

Common input and interpretation mistakes

  • Enter the coefficient of i, not the letter i itself.
  • Keep the sign with the imaginary coefficient. For 7 − 3i, enter −3.
  • Remember that i² = −1 when multiplying complex numbers.
  • A complex number with real part 0 is still valid, such as 5i.
  • A complex number with imaginary part 0 is simply a real number.
  • Division by 0 + 0i is undefined and is rejected by the calculator.

Limits and rounding

The calculator accepts integers, negative values, decimals, and standard numeric notation supported by the browser. Displayed values are rounded to the number of decimal places selected, while calculations use the unrounded numeric values internally.

Very large calculations can exceed the numerical range available in browser JavaScript. If that occurs, the calculator shows an error instead of returning an infinite value.

The argument of 0 + 0i is undefined because the zero complex number has no direction on the complex plane.

Complex Number Calculator FAQ

What is a complex number?

A complex number has the form a + bi, where a is the real part, b is the imaginary coefficient, and i² = −1.

How do I enter a number such as 4 − 7i?

Enter 4 in the real-part field and −7 in the imaginary-part field. The letter i is added automatically when the result is displayed.

Can I divide complex numbers with this calculator?

Yes. Select division from the operation menu. The only invalid divisor is 0 + 0i.

What is the conjugate of a complex number?

The conjugate changes the sign of the imaginary part. The conjugate of 3 + 4i is 3 − 4i.

What is the magnitude of a complex number?

For z = a + bi, the magnitude is √(a² + b²). It represents the distance from the origin to the point representing z on the complex plane.

Why does the calculator show an angle?

The angle is the argument of the result. Together with the magnitude, it allows the same complex number to be written in polar form.

(function(){ “use strict”; function cdCnInit(){ var root=document.getElementById(“cd-complex-number-calculator”); if(!root){return;} var aInput=document.getElementById(“cd-cn-a”); var bInput=document.getElementById(“cd-cn-b”); var cInput=document.getElementById(“cd-cn-c”); var dInput=document.getElementById(“cd-cn-d”); var operation=document.getElementById(“cd-cn-operation”); var precision=document.getElementById(“cd-cn-precision”); var errorBox=document.getElementById(“cd-cn-error”); var resultBox=document.getElementById(“cd-cn-result”); var mainResult=document.getElementById(“cd-cn-main-result”); var realResult=document.getElementById(“cd-cn-real-result”); var imagResult=document.getElementById(“cd-cn-imag-result”); var conjugateResult=document.getElementById(“cd-cn-conjugate”); var magnitudeResult=document.getElementById(“cd-cn-magnitude”); var argumentResult=document.getElementById(“cd-cn-argument”); var polarResult=document.getElementById(“cd-cn-polar”); var operationLabel=document.getElementById(“cd-cn-operation-label”); var calculateButton=document.getElementById(“cd-cn-calculate”); var exampleButton=document.getElementById(“cd-cn-example”); var copyButton=document.getElementById(“cd-cn-copy”); var clearButton=document.getElementById(“cd-cn-clear”);function showError(message){ errorBox.textContent=message; errorBox.style.display=”block”; }function hideError(){ errorBox.textContent=””; errorBox.style.display=”none”; }function parseField(input,label){ var raw=input.value.trim(); if(raw===””){ return {ok:false,message:”Enter a value for “+label+”.”}; } var value=Number(raw); if(!Number.isFinite(value)){ return {ok:false,message:label+” must be a valid finite number.”}; } if(Math.abs(value)>1e150){ return {ok:false,message:label+” is too large for a reliable browser calculation.”}; } return {ok:true,value:value}; }function cleanZero(value){ if(Object.is(value,-0)){return 0;} if(Math.abs(value)=1e12){return value.toExponential(Math.min(places,10));} if(absValue0){ if(imagAbs===1){return realText+” + i”;} return realText+” + “+imagText+”i”; } if(imagAbs===1){return realText+” – i”;} return realText+” – “+imagText+”i”; }function getOperationName(value){ if(value===”add”){return “Addition result”;} if(value===”subtract”){return “Subtraction result”;} if(value===”multiply”){return “Multiplication result”;} return “Division result”; }function calculate(){ try{ hideError(); var aData=parseField(aInput,”the first real part”); var bData=parseField(bInput,”the first imaginary part”); var cData=parseField(cInput,”the second real part”); var dData=parseField(dInput,”the second imaginary part”); var valid=[aData.ok,bData.ok,cData.ok,dData.ok].every(Boolean); if(!valid){ var entries=[aData,bData,cData,dData]; var message=”Check the entered values.”; for(var i=0;i=absD){ var ratioOne=d/c; var denominatorOne=c+(d*ratioOne); real=(a+(b*ratioOne))/denominatorOne; imag=(b-(a*ratioOne))/denominatorOne; }else{ var ratioTwo=c/d; var denominatorTwo=d+(c*ratioTwo); real=((a*ratioTwo)+b)/denominatorTwo; imag=((b*ratioTwo)-a)/denominatorTwo; } }real=cleanZero(real); imag=cleanZero(imag); var finiteResult=[real,imag].every(Number.isFinite); if(!finiteResult){ showError(“The result is outside the numerical range supported by the browser. Try smaller input values.”); resultBox.style.display=”none”; return; }var magnitude=Math.hypot(real,imag); var conjugate=formatComplex(real,-imag,places); var complexText=formatComplex(real,imag,places); var angleDegrees=0; var angleRadians=0; var argumentText=””; var polarText=””;if(magnitude===0){ argumentText=”Undefined for 0 + 0i”; polarText=”0″; }else{ angleRadians=Math.atan2(imag,real); angleDegrees=angleRadians*180/Math.PI; argumentText=formatNumber(angleDegrees,places)+” degrees (“+formatNumber(angleRadians,places)+” rad)”; polarText=formatNumber(magnitude,places)+”(cos(“+formatNumber(angleDegrees,places)+” degrees) + i sin(“+formatNumber(angleDegrees,places)+” degrees))”; }operationLabel.textContent=getOperationName(op); mainResult.textContent=complexText; realResult.textContent=formatNumber(real,places); imagResult.textContent=formatNumber(imag,places); conjugateResult.textContent=conjugate; magnitudeResult.textContent=formatNumber(magnitude,places); argumentResult.textContent=argumentText; polarResult.textContent=polarText; resultBox.style.display=”block”; }catch(error){ showError(“The calculation could not be completed. Check the input values and try again.”); resultBox.style.display=”none”; } }function loadExample(){ aInput.value=”3″; bInput.value=”4″; cInput.value=”1″; dInput.value=”-2″; operation.value=”multiply”; precision.value=”6″; calculate(); }function clearAll(){ aInput.value=””; bInput.value=””; cInput.value=””; dInput.value=””; operation.value=”add”; precision.value=”6″; hideError(); mainResult.textContent=””; realResult.textContent=””; imagResult.textContent=””; conjugateResult.textContent=””; magnitudeResult.textContent=””; argumentResult.textContent=””; polarResult.textContent=””; resultBox.style.display=”none”; aInput.focus(); }function fallbackCopy(text){ var temp=document.createElement(“textarea”); temp.value=text; temp.setAttribute(“readonly”,””); temp.style.position=”fixed”; temp.style.opacity=”0″; document.body.appendChild(temp); temp.select(); try{ document.execCommand(“copy”); copyButton.textContent=”Copied”; setTimeout(function(){copyButton.textContent=”Copy Result”;},1200); }catch(error){ showError(“Copying is not available in this browser. Select the result manually.”); } document.body.removeChild(temp); }function copyResult(){ var text=mainResult.textContent.trim(); if(text===””){ showError(“Calculate a result before copying.”); return; } if(navigator.clipboard){ navigator.clipboard.writeText(text).then(function(){ copyButton.textContent=”Copied”; setTimeout(function(){copyButton.textContent=”Copy Result”;},1200); }).catch(function(){ fallbackCopy(text); }); return; } fallbackCopy(text); }calculateButton.addEventListener(“click”,calculate); exampleButton.addEventListener(“click”,loadExample); copyButton.addEventListener(“click”,copyResult); clearButton.addEventListener(“click”,clearAll); operation.addEventListener(“change”,calculate); precision.addEventListener(“change”,calculate); calculate(); }if(document.readyState===”loading”){ document.addEventListener(“DOMContentLoaded”,cdCnInit); }else{ cdCnInit(); } })();

Similar Calculations