Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ProgrammingC++ Please! Problem 1: Using good coding practices, design your own ComplexVector class for vectors whose el- ements are complex numbers. Provide an overloading implementation
C++ProgrammingC++ Please!
Problem 1: Using good coding practices, design your own ComplexVector class for vectors whose el- ements are complex numbers. Provide an overloading implementation for term by term addition, subtraction, multiplication, division, and the stream output operator. Such that if v1 and v2 are ComplexVector objects, then one can compute v1 + v2, etc. Hint : you may want to create a Complex class separately. Complex numbers are expressed in the form a+bi, where a is the real part, b is the imaginary part, and i is the imaginary unit satisfying i2 = -1. Print your complex numbers using this representation. When adding (or subtracting) two complex numbers, add or subtract) their real parts and imaginary parts separately. The multiplication of two complex numbers is defined by, (a + bi)(c + di) = (ac bd) + (bc + ad)i, while division is given by, a + bi ac + bd bc - ad c+di c2 + d2c2 + d2'. Using your newly defined ComplexVector class, write a recursive function to print the first 6 terms in the sequence from equation (3) to a file titled "ComplexSequence.txt. In+1 = (2+3i)n fn+1 = 7 + 5 m2 i In, fi=1+ Using the vectors v1 and v2 , v1 = { 2 + 4 i, 3 + 5 i, -1 - 3i, 8 + 10 i } v2 = { -10 + 3.5 i, 4 + 7.3 i, 2 - 8i, 10 -142 i}, write a main function that checks v1 + v2, v1 - v2, v1 * v2, and v1 / v2 by printing them to the console. Figure 1 shows the sample outputs. - O X .9 + + + C. C:\Windows\system32\cmd.exe v1 = { 2.0 + 4.8i v2 = {-10.0 + 3.5i v1 + v2 = ( -8.0 + 7.5i v1 12.0 + 0.5i, v1 * (-34.8 - 33.0i, v1 = -0.1 - 0.4i. 7.0 + | 5.0 7.31 12.3i, 2.3i, 41.9i, 6 .8 - 3.8i 8.0 + 18.8i} 2.0 - 8.0i, 18.0 -142.Bi) - 11.8i 18.8 -132.8i } -2.0 +152.8i} , 1588.8 -1836.8i} -0.1 + 0.1i } -1.0 WSSSSS 5.0i .5 + 0.7 + | 2.0i 0.2i B.Bi , Writing Complex Sequence to File ...Done Press any key to continue.. ComplexSequence - Notepad File Edit Format View Help K 1 + li , 0.243243 +0.5405413, 0.125925 +0.157587i, 0.0428685 +0.02139591 , 0.00859831 -0.000325121, 0.00104322 -0.0006684591 } Figure 1: Sample outputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started