Message Boards Message Boards

0
|
7731 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

limit equation's solutions

Posted 9 years ago

I have a question please, I have to solve an equation that gives more than 400 solutions (reel and complexe numbers) but i'm just interested by reel and positive solution How can i have just the reel positive numbers from all the solutions of this equation?

POSTED BY: djouaher zo
4 Replies
Posted 9 years ago

hi, thank you, it works.

POSTED BY: djouaher zo

Hi,

I still don't see the problem. Here's a smaller example.

A = RandomReal[{-1, 1}, {5, 5}]; B = RandomReal[{-1, 1}, {5, 5}];
sols = Solve[Det[A - w^2*B] == 0, w]

This gives:

{{w -> -0.890446 - 0.570123 I}, {w -> -0.890446 + 0.570123 I}, {w -> -0.604951}, {w -> 0. - 1.01964 I}, 
{w ->  0. + 1.01964 I}, {w -> 0. - 1.82466 I}, {w -> 0. + 1.82466 I}, {w -> 0.604951}, 
{w -> 0.890446 - 0.570123 I}, {w -> 0.890446 + 0.570123 I}}

If you now apply the command I posted earlier:

Select[Chop[w /. sols], (Head[#] == Real && Re[#] > 0) &]

It gives

{0.604951}

which is indeed the only positive real solution that Mathematica found. So what makes you say that this does not work?

Cheers,

Marco

POSTED BY: Marco Thiel
Posted 9 years ago

Thanks for your answer, but this tip does not work with my equation Look, i have to solve this equation Solve[Det[kg- w^2*Mg] == 0, w] Knowing that both "kg" and "Mg" are [18x18] matrix Can rewrite your example with my equation. greetings

POSTED BY: djouaher zo

Dear Djouaher Zo,

I hope this helps a bit. I show the principle using a 4th order polynomial:

sols = NSolve[Sum[(RandomReal[] - 0.5) x^i, {i, 0, 4}] == 0, x]; 

In this case I get:

sols
(*{{x -> -0.946069}, {x -> -0.171399 - 0.607033 I}, {x -> -0.171399 + 0.607033 I}, {x -> 0.748391}}*)

Now I can choose the real and positive solutions:

Select[Cases[Chop[x /. sols], _Real], # > 0 &]
{0.748391}

You can do this in one command, e.g. just Select:

Select[Chop[x /. sols], (Head[#] == Real && Re[#] > 0) &]

Cheers,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract