Dux
Dux

Reputation: 101

WxMaxima solving Equation leads to complex numbers?

I'm trying to solve the equation "eq" for "mu". How do I tell maxima that I only want the positive result, is this the best way var : abs(mu), res;? But, my main problem is, that the results contains %i, where does that come from? Shouldn't it be solvable in R, without the need for complex numbers, like I demonstrated in my "by hand"-calculation?

Arithmetic solution:

(%i16)  eq: RN^2 = R^2+N^2;
(eq)    (121*G^2*h2^2*t1^2)/(100*h1^2*t2^2)=(G^2*v^2)/(4*mu^2)+G^2/4
(%i20)  res: solve(eq,mu); var : abs(mu), res; expand(var); res, numer;
(res)   [mu=-(5*%i*h1*t2*v)/sqrt(25*h1^2*t2^2-121*h2^2*t1^2),mu=(5*%i*h1*t2*v)/sqrt(25*h1^2*t2^2-121*h2^2*t1^2)]
(var)   5*abs(h1)*abs(t2)*abs(1/sqrt(25*h1^2*t2^2-121*h2^2*t1^2))*abs(v)
(%o19)  5*abs(h1)*abs(t2)*abs(1/sqrt(25*h1^2*t2^2-121*h2^2*t1^2))*abs(v)
(%o20)  [mu=-(5*%i*h1*t2*v)/(25*h1^2*t2^2-121*h2^2*t1^2)^0.5,mu=(5*%i*h1*t2*v)/(25*h1^2*t2^2-121*h2^2*t1^2)^0.5]

Numeric solution:

(%i26)  t1: 64`mm;
    t2: 33`mm;
    h1: 47`mm;
    h2: 28`mm;
    v: 2;
(t1)    64 ` mm
(t2)    33 ` mm
(h1)    47 ` mm
(h2)    28 ` mm
(v) 2
(%i42)  res: solve(eq,mu); var : abs(mu), res; var, numer; res, numer;
(res)   [mu=-(5*%i*h1*t2*v)/sqrt(25*h1^2*t2^2-121*h2^2*t1^2),mu=(5*%i*h1*t2*v)/sqrt(25*h1^2*t2^2-121*h2^2*t1^2)]
(var)   1410/sqrt(2714239)
(%o41)  0.8558449047226222
(%o42)  [mu=-(0.8558449047226222*%i)/(-1)^0.5,mu=(0.8558449047226222*%i)/(-1)^0.5]

Solving by hand(negative result omitted): https://www.bilder-upload.eu/bild-07c372-1620053087.png.html

Upvotes: 1

Views: 350

Answers (2)

Robert Dodier
Robert Dodier

Reputation: 17576

At least part of the story is that Maxima simplifies sqrt(-b^2/(c - a)) to %i*abs(b)/sqrt(c - a) instead of abs(b)/sqrt(a - c). On the other hand, sqrt(b^2/(a - c)) simplifies to abs(b)/sqrt(a - c).

I was thinking that maybe a way to get a result which is free of %i would be to rearrange sqrt(-b^2/(c - a)) to sqrt(b^2/(a - c)) and then letting the built-in simplifier work on that. (tellsimp accomplishes that -- a tellsimp rule is applied before the built-in simplifier, while a tellsimpafter rule is applied afterwards.)

I tried some attempts at defining a suitable tellsimp rule, but I wasn't able to find something that works for the example given. I can post my attempts if there is interest.

Upvotes: 1

Stavros Macrakis
Stavros Macrakis

Reputation: 372

If I'm not mistaken, the result is only real if 121*h2^2*t1^2 > 25*h1^2*t2^2.

So:

  ​eq: (121*G^2*h2^2*t1^2)/(100*h1^2*t2^2)=(G^2*v^2)/(4*mu^2)+G^2/4;
  ​assume ( 121*h2^2*t1^2 > 25*h1^2*t2^2 );
  ​solve( eq, mu);
         ​=> [mu = -(5*h1*t2*v)/sqrt(121*h2^2*t1^2-25*h1^2*t2^2),
             mu =  (5*h1*t2*v)/sqrt(121*h2^2*t1^2-25*h1^2*t2^2) ]

How do you find that magic inequality? Well, you run solve without it and note that there is a square root which might have a negative argument....

Upvotes: 3

Related Questions