Skip to main content
1 of 3
PKD
  • 31
  • 5

Sqrt returns complex values

I am trying to find sine from a cosine relation using the following commands:

CosEta[x_,y_]: = 1/2 Cosh[Log[3]/2] (-Sqrt[y^2 + (x - Sech[Log[3]/2])^2] + Sqrt[y^2 + (x + Sech[Log[3]/2])^2]);    

sinsquare[x_,y_]: = 1 - (CosEta[x,y])^2;    

SinEta[x_,y_]: = Sqrt[sinsquare[x,y]];    

At some point, i.e. x->1.1, y->-0.000000001 , CosEta[x,y] becomes -4.4408910^-16 , and as a consequence, SinEta returns complex number as 0. + 2.1073410^-8 I . What can be done to get rid of this complex number return?

I have to implement this commands in my full code which includes multiple 1st and 2nd derivatives of SinEta and CosEta for which I can not use Re[] in defining the SinEta since Re' and Re'' shows up in the final outcome.

PKD
  • 31
  • 5