-1

I have an equation

(0.125-(1j*(mu1)*0.125))/(0.125 - cmath.sqrt((0.125**2)-(0.125**2)-((mu1**2)*(0.125**2))))

This is suppose to be 1 for any value of mu1 but it seems I am getting 1 only if mu1 is real... what am I missing?

For mu1 = 1, the above expression calculates 1 (see 3rd line)
(0.125-(1j*(mu1)*0.125))/(0.125 - cmath.sqrt((0.125**2)-(0.125**2)-((mu1**2)*(0.125**2))))
(1+0j)
For mu1 = 2, the above expression calculates 1 (see 3rd line)
(0.125-(1j*(mu1)*0.125))/(0.125 - cmath.sqrt((0.125**2)-(0.125**2)-((mu1**2)*(0.125**2))))
(1-0j)  ANSWER I AM LOOKING FOR
For mu1 = 2+2j, the above expression calculates
(0.125-(1j*(mu1)*0.125))/(0.125 - cmath.sqrt((0.125**2)-(0.125**2)-((mu1**2)*(0.125**2))))
(-1.4-0.8j) I WAS EXPECTING 1 because NUMERATOR and DENOMINATOR are same

For the last one, the bottom half evaluates to

1                     1
-- - sqrt(j^2 (2+2j)^2 ---^2 )
8                     8

1              1
-- - j (2+2j) ---
8              8

1 -2j -2j^2
-----------
8

3 - 2j
------
8
user3873617
  • 374
  • 1
  • 3
  • 15
  • The `(0.125**2)-(0.125**2)` part of your equation cancels out to zero - I suspect you've miscopied some part of it. – jasonharper Oct 13 '22 at 02:03
  • No its ok.. They are suppose to cancel out and the sqrt should give j*mu1*0.125 – user3873617 Oct 13 '22 at 02:05
  • In the original eq, both 0.125 is replaced by variables a and b.. I gave a easier expression to make my point – user3873617 Oct 13 '22 at 02:06
  • After cancelling out everything, the result will only be 1 when `1j*mu1*0.125 == cmath.sqrt(-(mu1**2 * 0.125**2))` – Barmar Oct 13 '22 at 02:19
  • Yes... that's what my question... I am getting 1 only if mu1 is real and not if mu1 is complex.... I thought they are essentially same expression...cmath.sqrt(-1) == 1j – user3873617 Oct 13 '22 at 02:26
  • They are not essentially the same; the left hand side can be any complex number, but the right hand side can only be the principal square root of a complex number, so it's just not logically possible for that equation to be an identity. – kaya3 Oct 13 '22 at 02:42
  • Can you please explain why its not because the same mu1 var exists in both LHS and RHS... At the most, there is atleast one soln where they are same – user3873617 Oct 13 '22 at 02:52
  • Equations *equate* two things; you have an *expression*. – chepner Oct 13 '22 at 11:47

3 Answers3

0

After cancelling out the common terms, the result will only be 1 when

1j*mu1*0.125 == cmath.sqrt(-(mu1**2 * 0.125**2))

I haven't analyzed it carefully, but it seems to be true only the real part of mu1 is positive or zero and the imaginary part is negative or zero. I.e. it's true in the lower-right quadrant of the complex plane.

So I think you may have been misinformed about the equation, or you copied it wrong.

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • LHS == RHS regardless of mu1 being real or complex... – user3873617 Oct 13 '22 at 02:32
  • @user3873617 Evidently not. – kaya3 Oct 13 '22 at 02:39
  • @kaya3 why is that??? – user3873617 Oct 13 '22 at 02:47
  • Why is it evident? Because you can see for yourself that the left hand side is not equal to the right hand side in some cases. – kaya3 Oct 13 '22 at 02:48
  • 2
    @user3873617 It seems like [math.se] might be a better place for you to ask about this formula. – Barmar Oct 13 '22 at 02:53
  • I dont see they are being different... The poster who posted the prev answer is correcting it now... If you have some calc, please post it – user3873617 Oct 13 '22 at 02:54
  • @kaya3 I think u are assuming that they are equation.. they are not each line is output from python shell.... I removed the ">>>" characters to make them readable... – user3873617 Oct 13 '22 at 02:57
  • @user3873617 They are not equal. You cannot square something, then take a square root, and always expect to get back the same number you started with; squaring is not an invertible operation. As I wrote above, the left hand side can be any complex number whereas the right hand side can only be a principal square root. – kaya3 Oct 13 '22 at 03:00
  • So you saying that for a complex number c, this is not true j c = sqrt(-c^2) – user3873617 Oct 13 '22 at 03:05
  • @Barmar I posted my question on math.stackexchange too. Thanks – user3873617 Oct 13 '22 at 03:31
  • @user3873617 Every number has two square roots. E.g. the square roots of 4 are 2 and -2. But `math.sqrt()` only returns one of them. – Barmar Oct 13 '22 at 14:57
0

The answer lies in using appropriate branch cuts of sqrt function.

user3873617
  • 374
  • 1
  • 3
  • 15
-1

In your case of 2+2j the top half of the fraction resolves to:

 1       j(2 + 2j)
---  -  -----------
 8           8

 1    -   (2j + (2j)^2)
---------------------
          8

 1    -   (2j + 2*-1)
---------------------
          8

 1    -   2j + 2
---------------------
          8

     3    -   2j 
---------------------
          8

Which only happens with the complex input due to j^2 = -1

The bottom half is:

(-0.125+0.25j)

# or
 
 -1 + 2j
--------
   8

# Because:

 1        sqrt(0 -      (2+2j)^2      )
---   -       -------------------
 8                 8^2


 1         sqrt(   -       8j
---  -                  -------     )
 8                         8^2

 1       2      2j
---  - (--- - -----)
 8       8      8

 1       2      2j
---  -  --- +  -----
 8       8      8

 -1 + 2j
--------
   8

It's worth noting this difference:

>>> cmath.sqrt(8j/64)
(0.25+0.25j)
>>> cmath.sqrt(-8j/64)
(0.25-0.25j)
mjsqu
  • 5,151
  • 1
  • 17
  • 21