← Back to R Course | Chapter 2: Variables & Types | Lesson 6 of 7

Complex Type क्या है

Complex numbers के दो parts होते हैं, एक everyday part और एक imaginary part, दो coordinates वाले एक treasure map की तरह। R इनके साथ directly math कर सकता है, जो science और engineering में useful है।

In this page:

  1. Complex Type
Syntax
r
z <- 3+2i
Re(z)
Im(z)

Complex Type

R complex type के साथ natively complex numbers support करता है, a+bi की तरह लिखे गए imaginary unit के लिए i इस्तेमाल करते हुए, जैसे 3+4i।

Standard arithmetic operators complex numbers पर directly काम करते हैं। यह दूसरे basic types से कम commonly इस्तेमाल होता है लेकिन scientific और engineering computation के लिए पूरी तरह built in है।

Note: Mod() एक complex number की magnitude compute करता है, और Re()/Im() इसके real और imaginary parts extract करते हैं।

उदाहरण: Complex Type

markup
z <- 3 + 4i

cat(class(z), "\n")
cat("Magnitude:", Mod(z), "\n")
cat("Real part:", Re(z), "Imaginary part:", Im(z), "\n")
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. 3 + 4i की बजाय 3 + i4 या 3 + 4*i लिखना, जो fail होता है क्योंकि i को directly number के बाद आना ज़रूरी है।
  2. यह उम्मीद करना कि sqrt(-1) 1i देगा, जब यह एक warning के साथ NaN return करता है जब तक आप sqrt(as.complex(-1)) इस्तेमाल न करें।
  3. complex numbers को < या > से compare करना, जो एक error है क्योंकि इनका कोई order नहीं।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.