# Defining a complex variable

**URL:** <https://community.wolfram.com/t/defining-a-complex-variable/5597>\
**Category:** Questions\
**Created:** [May 2, 2015, 6:22am UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597 "2015-05-02T06:22:29Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![knazar](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@knazar](https://community.wolfram.com/u/knazar)\
**Post date:** [May 2, 2015, 6:22am UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/1 "2015-05-02T06:22:29Z")

</div>

In the following two equations with two variables “b” and “c”. In my theory if i solve these two equations then i dont get required results, BUT if i explicitly write both variables b and c as complex numbers,i.e,. “b=x1+i y1” and " c= x2+ i y2 " and solve 4 equations like below then i get my required results, but i need to have previous form as it reduces time. CAN ANYONE GUIDE ME ?  
THANKS

eq1 = -2.6496569219504336` + 2.3827335619844803`/(  
1.29731758306921` + (0.7463275363988051` - b)^2) - (  
0.7684079898461433` b)/( 1.29731758306921` + (0.7463275363988051` - b)^2) + 2.3827335619844803`/(  
1.29731758306921` + (0.7463275363988051` - c)^2) - (  
0.7684079898461433` c)/( 1.29731758306921` + (0.7463275363988051` - c)^2)

eq2 = 0.37580644282399783` + 0.013774982050389344`/(  
0.21352891577655558` + (0.34484941659029344` - b)^2) + (  
0.1448494165902934` b)/( 0.21352891577655558` + (0.34484941659029344` - b)^2) + 0.013774982050389344`/(  
0.21352891577655558` + (0.34484941659029344` - c)^2) + (  
0.1448494165902934` c)/( 0.21352891577655558` + (0.34484941659029344` - c)^2)

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [May 2, 2015, 12:55pm UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/2 "2015-05-02T12:55:53Z")

</div>

NSolve says your equations have an infinite number of solutions.

```
In[1]:= eq1 = -2.6496569219504336 + 
   2.3827335619844803/(1.29731758306921 + (0.7463275363988051 - 
         b)^2) - (0.7684079898461433 b)/(1.29731758306921 + \
(0.7463275363988051 - b)^2) + 
   2.3827335619844803/(1.29731758306921 + (0.7463275363988051 - 
         c)^2) - (0.7684079898461433 c)/(1.29731758306921 + \
(0.7463275363988051` - c)^2);

In[2]:= eq2 = 
  0.37580644282399783 + 
   0.013774982050389344/(0.21352891577655558 + (0.34484941659029344 - 
         b)^2) + (0.1448494165902934 b)/(0.21352891577655558 + \
(0.34484941659029344 - b)^2) + 
   0.013774982050389344/(0.21352891577655558 + (0.34484941659029344 - 
         c)^2) + (0.1448494165902934 c)/(0.21352891577655558 + \
(0.34484941659029344` - c)^2);

In[4]:= NSolve[{eq1, eq2}, {a, b, c}]

During evaluation of In[4]:= NSolve::infsolns: Infinite solution set has dimension at least 1. Returning intersection of solutions with (171802 a)/178835-(113492 b)/178835-(121484 c)/178835 == 1. >>

Out[4]= {{a -> 1.91912 - 0.59005 I, b -> 1.10211 - 0.316715 I, 
  c -> 0.212318 - 0.538566 I}, {a -> 1.91912 + 0.59005 I, 
  b -> 1.10211 + 0.316715 I, 
  c -> 0.212318 + 0.538566 I}, {a -> 1.10666 + 0.0365591 I, 
  b -> 0.0480565 - 0.785901 I, 
  c -> 0.0480565 + 0.785901 I}, {a -> 1.10666 - 0.0365591 I, 
  b -> 0.0480565 + 0.785901 I, 
  c -> 0.0480565 - 0.785901 I}, {a -> 1.05913 + 0.0223244 I, 
  b -> 0.0133044 - 0.479901 I, 
  c -> 0.0133044 + 0.479901 I}, {a -> 1.05913 - 0.0223244 I, 
  b -> 0.0133044 + 0.479901 I, 
  c -> 0.0133044 - 0.479901 I}, {a -> 1.96051 - 0.579729 I, 
  b -> 0.212318 - 0.538566 I, 
  c -> 1.10211 - 0.316715 I}, {a -> 1.96051 + 0.579729 I, 
  b -> 0.212318 + 0.538566 I, c -> 1.10211 + 0.316715 I}}

```

---

<div class="post-metadata">

**Author:** ![knazar](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@knazar](https://community.wolfram.com/u/knazar)\
**Post date:** [May 2, 2015, 2:08pm UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/3 "2015-05-02T14:08:17Z")

</div>

Thanks for your Answer,

Can you please explain, why you have taken " a" as this is not included in equations

In[4] := NSolve[{eq1, eq2}, {a, b, c}]

And can you please explain the following

(171802 a)/178835 - (113492 b)/  
178835 - (121484 c)/178835 == 1.

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [May 2, 2015, 2:26pm UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/4 "2015-05-02T14:26:36Z")

</div>

First question: saw b and c, assumed there was an a. It’s better to put Mathematica code into a code sample, as it’s easier to read.  
Second question: NSolve used that equation to give an answer to a problem with an infinite number of solutions.

---

<div class="post-metadata">

**Author:** ![knazar](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@knazar](https://community.wolfram.com/u/knazar)\
**Post date:** [May 2, 2015, 3:33pm UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/5 "2015-05-02T15:33:10Z")

</div>

if i use either  
NSolve[{eq1, eq2}, {b, c}]

or  
NSolve[{eq1, eq2}, {a1, b, c}]

Values of both variables b and c are same in both cases. You can see in the attached file.

Also sir, if you see my question, it was little different, I have no problem in solving the 2 equations with 2 variables, but by solving, the results are not favorable, but if i write the variables b and c in equations in the form of "b=x1+i y1 " and "c=x2+i y2 " and making 4 equations which is easy in my theory, with 4 variables, then Using  
NSolve[{eq1, eq2, eq3, eq4}, {x1, y1, x2, y2}, Reals].

I get my required results. But this way is not good for me as when i go for higher dimensions, i.e 10 equations and 10 variables , then i face problem that my system stucks and stop running  
oblem

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [May 2, 2015, 4:26pm UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/6 "2015-05-02T16:26:19Z")

</div>

The time required by NSolve increases exponentially with the complexity of the problem. For 10 equations and 10 variables, it would be better to use FindRoot.

---

<div class="post-metadata">

**Author:** ![knazar](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@knazar](https://community.wolfram.com/u/knazar)\
**Post date:** [May 2, 2015, 4:45pm UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/7 "2015-05-02T16:45:30Z")

</div>

Ok Sir,

Can you please guide me in the case of 2 equations and 4 equations case as discussed in my last mail. As

"I have no problem in solving the 2 equations with 2 variables, but by solving, the results are not favorable, but if i write the variables b and c in equations in the form of "b=x1+i y1 " and "c=x2+i y2 " and choosing 4 equations involving variables x1,y1, x2 and y2, then Using NSolve[{eq1, eq2, eq3, eq4}, {x1, y1, x2, y2}, Reals]. I get my favoured results.

How can i get same results.

For better understanding, please see the attached file

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [May 2, 2015, 6:15pm UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/8 "2015-05-02T18:15:18Z")

</div>

In[1]:= eq1 = -2.6496569219504336 +  
2.3827335619844803/(1.29731758306921 + (0.7463275363988051 -  
b)^2) - (0.7684079898461433 b)/(1.29731758306921 +   
(0.7463275363988051 - b)^2) +  
2.3827335619844803/(1.29731758306921 + (0.7463275363988051 -  
c)^2) - (0.7684079898461433 c)/(1.29731758306921 +   
(0.7463275363988051` - c)^2);

```
In[2]:= eq2 = 
  0.37580644282399783 + 
   0.013774982050389344/(0.21352891577655558 + (0.34484941659029344 - 
         b)^2) + (0.1448494165902934 b)/(0.21352891577655558 + \
(0.34484941659029344 - b)^2) + 
   0.013774982050389344/(0.21352891577655558 + (0.34484941659029344 - 
         c)^2) + (0.1448494165902934 c)/(0.21352891577655558 + \
(0.34484941659029344` - c)^2);

In[3]:= NSolve[{eq1 == 0, eq2 == 0}, {b, c}]

Out[3]= {{b -> 1.1021 + 0.316679 I, 
  c -> 0.212341 + 0.538527 I}, {b -> 1.10218 - 0.316787 I, 
  c -> 0.212354 - 0.538553 I}, {b -> 0.212358 + 0.538566 I, 
  c -> 1.10216 + 0.316634 I}, {b -> 0.212382 - 0.538559 I, 
  c -> 1.10227 - 0.316857 I}, {b -> 0.0481784 + 0.785998 I, 
  c -> 0.0482403 - 0.78599 I}, {b -> 0.0482052 - 0.785916 I, 
  c -> 0.0481275 + 0.785992 I}, {b -> 0.0134349 + 0.479927 I, 
  c -> 0.0133104 - 0.479802 I}, {b -> 0.013324 - 0.479794 I, 
  c -> 0.0134405 + 0.479929 I}}

```

---

<div class="post-metadata">

**Author:** ![cadrin](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@cadrin](https://community.wolfram.com/u/cadrin)\
**Post date:** [May 5, 2015, 10:52am UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/9 "2015-05-05T10:52:05Z")

</div>

![rep01.png](https://global.discourse-cdn.com/wolfram/original/3X/d/7/d7c5178c6734b75f9e697bf1ebbd01155153a815.png)

---

<div class="post-metadata">

**Author:** ![knazar](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@knazar](https://community.wolfram.com/u/knazar)\
**Post date:** [May 6, 2015, 6:41pm UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/10 "2015-05-06T18:41:55Z")

</div>

Hello Sir,

Thanks for your time, Can you please explain as defining first b and c then solving equations for the same b and c has not worked.

Thanks

---

<div class="post-metadata">

**Author:** ![cadrin](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@cadrin](https://community.wolfram.com/u/cadrin)\
**Post date:** [May 6, 2015, 9:48pm UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/11 "2015-05-06T21:48:53Z")

</div>

![rep04.png](https://global.discourse-cdn.com/wolfram/original/3X/d/4/d4597ac8b78ae74b61219c25b8e9426a975cf3f8.png)

---

<div class="post-metadata">

**Author:** ![knazar](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@knazar](https://community.wolfram.com/u/knazar)\
**Post date:** [May 7, 2015, 3:13am UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/12 "2015-05-07T03:13:30Z")

</div>

Once again thanks for your guidance, I have tried your suggestion in my file, but it is not working. I have attached the file, Please see and guide me if i am doing wrong.

Thanks

---

<div class="post-metadata">

**Author:** ![cadrin](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@cadrin](https://community.wolfram.com/u/cadrin)\
**Post date:** [May 7, 2015, 11:06pm UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/13 "2015-05-07T23:06:54Z")

</div>

!

 ![6401rep07.png](https://global.discourse-cdn.com/wolfram/original/2X/e/ecb2eebb4547208bc5ffc5635734e5298b12c0e8.png)

---

<div class="post-metadata">

**Author:** ![knazar](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@knazar](https://community.wolfram.com/u/knazar)\
**Post date:** [May 8, 2015, 5:00am UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/14 "2015-05-08T05:00:12Z")

</div>

In your last reply, In[8] and In[10] represent set of values of b and c?

---

<div class="post-metadata">

**Author:** ![cadrin](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@cadrin](https://community.wolfram.com/u/cadrin)\
**Post date:** [May 10, 2015, 11:18am UTC](https://community.wolfram.com/t/defining-a-complex-variable/5597/15 "2015-05-10T11:18:53Z")

</div>

![3755re01.png](https://global.discourse-cdn.com/wolfram/original/2X/b/b22919dae72bf0fa0c2d2e6611244cd171138b76.png)
