Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

equation question

3 views
Skip to first unread message

dimm...@yahoo.com

unread,
Sep 27, 2006, 6:35:13 AM9/27/06
to
Hello.

Consider the following simple examples of FindRoot application.

FindRoot[Sin[x] == 2, {x, I}]
{x -> 1.5707963267948966 + 1.3169578969248168*I}

FindRoot[Sin[x^2] == 2, {x, I + 1}]
{x -> 1.3454777060580754 + 0.4894016047219337*I}

FindRoot[Sin[x^2] == 2, {x, 3*I + 2}]
{x -> 0.3004695589886017 + 2.1914997002654357*I}

Is it possible for FindRoot (or in general in another way) to search
for solutions
in the complex plane in an particular domain e.g. searching in the
domain that
is made by the lines Re[x]=a1, Re[x]=a2 and Im[x]=b1, Im[b]=b2 ?

I really appreciate any assistance.

Regards
Dimitris

dh

unread,
Sep 28, 2006, 6:18:14 AM9/28/06
to

Hi Dimitris,
you can try "FindInstance". E.g:"
FindInstance[{Sin[x]\[Equal]2,Re[x]>1.5},x]//N
gives:{{x -> 1.5708 + 1.31696 \[ImaginaryI]}}

Daniel

Chris Chiasson

unread,
Sep 28, 2006, 6:21:27 AM9/28/06
to
If you want to use numerical proceedures, penalty functions could help
you out with constraints. If you don't want to write your own penalty
functions, you could repose your FindRoot problem as an NMinimize on
the absolute value of the difference between your lhs and rhs.

On 9/27/06, dimm...@yahoo.com <dimm...@yahoo.com> wrote:
> Hello.
>
> Consider the following simple examples of FindRoot application.
>
> FindRoot[Sin[x] == 2, {x, I}]
> {x -> 1.5707963267948966 + 1.3169578969248168*I}
>
> FindRoot[Sin[x^2] == 2, {x, I + 1}]
> {x -> 1.3454777060580754 + 0.4894016047219337*I}
>
> FindRoot[Sin[x^2] == 2, {x, 3*I + 2}]
> {x -> 0.3004695589886017 + 2.1914997002654357*I}
>
> Is it possible for FindRoot (or in general in another way) to search
> for solutions
> in the complex plane in an particular domain e.g. searching in the
> domain that
> is made by the lines Re[x]=a1, Re[x]=a2 and Im[x]=b1, Im[b]=b2 ?
>
> I really appreciate any assistance.
>
> Regards
> Dimitris
>
>


--
http://chris.chiasson.name/

bghi...@ucdavis.edu

unread,
Sep 28, 2006, 7:14:41 AM9/28/06
to
Demitris,

One way is to use ContourPLot. First, let us determine the required
equations defined in the complex plane

First we express the equations in terms of x=a + I*ß. Here is the
result for Sin[x]-2

f1 = ComplexExpand[Sin[x] - 2 /. x -> a + I*ß]


-2 + Cosh[ß]*Sin[a] + I*Cos[a]*Sinh[ß]

Here is the result for Sin[x^2]-2

f2 = ComplexExpand[Sin[x^2] /. x -> a + I*ß] - 2


-2 + Cosh[2*a*ß]*Sin[a^2 - ß^2] +
I*Cos[a^2 - ß^2]*Sinh[2*a*ß]

Now we use ContourPlot to display the real part and the imaginary part
of the level set equal to 0 as follows

Block[{$DisplayFunction = Identity}, Plt1 = ContourPlot [Re[f1], {a,
-2,
10}, {ß, -2,
2}, Contours -> {0}, ContourShading -> False, ContourStyle -> Blue,

PlotPoints -> 100]; Plt2 =
ContourPlot [Im[f1], {a, -2, 10}, {ß, -2, 2}, Contours -> {0},

ContourShading -> False, ContourStyle -> Red, PlotPoints ->
100];]
Show[Plt1, Plt2]

Block[{$DisplayFunction = Identity}, Plt1 = ContourPlot [Re[f2], {a,
-2,
10}, {ß, -2,
2}, Contours -> {0}, ContourShading -> False, ContourStyle -> Blue,

PlotPoints -> 100]; Plt2 =
ContourPlot [Im[f2], {a, -2, 10}, {ß, -2, 2}, Contours -> {0},

ContourShading -> False, ContourStyle -> Red, PlotPoints ->
100];]
Show[Plt1, Plt2]

The above plots show the complex roots (the intersection of the two
level set curves) in the range

-2<a<10 , -2<ß<2

If you want then to extract approximate values of these roots from the
graphic object which you can feed to FindRootyou can use the method
suggested by Stan Wagon in his book Mathematica in Action (see p 289).

In short you can automate the location of all complex roots in the
desired range.

Hope this helps,

Cheers,

Brian

Daniel Lichtblau

unread,
Sep 28, 2006, 7:21:50 AM9/28/06
to
dimm...@yahoo.com wrote:
> Hello.
>
> Consider the following simple examples of FindRoot application.
>
> FindRoot[Sin[x] == 2, {x, I}]
> {x -> 1.5707963267948966 + 1.3169578969248168*I}
>
> FindRoot[Sin[x^2] == 2, {x, I + 1}]
> {x -> 1.3454777060580754 + 0.4894016047219337*I}
>
> FindRoot[Sin[x^2] == 2, {x, 3*I + 2}]
> {x -> 0.3004695589886017 + 2.1914997002654357*I}
>
> Is it possible for FindRoot (or in general in another way) to search
> for solutions
> in the complex plane in an particular domain e.g. searching in the
> domain that
> is made by the lines Re[x]=a1, Re[x]=a2 and Im[x]=b1, Im[b]=b2 ?
>
> I really appreciate any assistance.
>
> Regards
> Dimitris

You can set it up as a minimization of a square (for multiple equations,
a sum of squares) and use NMinimize, which handles such constraints.

Example:

In[1]:= NMinimize[{Abs[(Sin[(a+I*b)^2]-2)^2],
{5<=a<=9, 0<=b<=2}}, {a,b}]
-17
Out[1]= {3.89097 10 , {a -> 5.16912, b -> 0.127387}}


Daniel Lichtblau
Wolfram Research


Andrzej Kozlowski

unread,
Sep 29, 2006, 6:52:44 AM9/29/06
to

A slightly different approach is:


NMinimize[{1, {5 <= a <= 9, 0 <= b <= 2,
Abs[Sin[(a + I*b)^2] - 2] == 0}}, {a, b}]

Out[1]=
{1., {a -> 5.1691164655883295, b -> 0.12738713670869523}}

In fact, in this approach, it makes no difference, if one uses
NMinimize or NMaximize:

In[2]:=
NMaximize[{1, {5 <= a <= 9, 0 <= b <= 2,
Abs[Sin[(a + I*b)^2] - 2] == 0}}, {a, b}]

Out[2]=
{1., {a -> 5.1691164655883295, b -> 0.12738713670869523}}


On the other hand, one advantage of having Abs[Sin[(a + I*b)^2] - 2]
as the objective function is that we automatically get an idea of the
size of the residual.


Andrzej Kozlowski

Andrzej Kozlowski

unread,
Sep 30, 2006, 5:20:13 AM9/30/06
to

ab_...@prontomail.com

unread,
Oct 2, 2006, 12:52:32 AM10/2/06
to

You can specify a rectangular search region in the FindRoot iterator
(the bottom left and top right corners):

In[1]:= FindRoot[Sin[x^2] - 2, {x, 2 + 3*I, 0, 3 + 4*I}]

Out[1]= {x -> 0.30046956 + 2.1914997*I}

Maxim Rytin
m...@inbox.ru
***********************************

0 new messages