MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problem with Min Max between two functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112043] Re: Problem with Min Max between two functions
  • From: maria giovanna dainotti <mariagiovannadainotti at yahoo.it>
  • Date: Thu, 26 Aug 2010 06:49:09 -0400 (EDT)

Dear J. Batista,
I used the following equations
R1==1.029
R2==3.892
R3==8
e1==250
e2==11.8
e3==80.5
i==p/12
spherenear[x_,y_]:==((R3^2-x^2-y^2)^(1/2))
spherefar[x_,y_]:==-((R3^2-x^2-y^2)^(1/2))
jetnear[x_,y_]:==Min[Re[spherenear[x,y]],Re[(R1^2-x^2)^(1/2)+y*Tan[i]]]
jetfar[x_,y_]:==Max[Re[spherefar[x,y]],Re[-(R1^2-x^2)^(1/2)]+y*Tan[i]]
jetbrightness[x_,y_]:==Boole[-R1=EF=82=A3x=EF=82=A3R1]*(jetnear[x,y] - jetfar[x,y])*e1
emptynear[x_,y_]:==Min[Re[spherenear[x,y]],Re[(R2^2-x^2)^(1/2)+y*Tan[i]]]
emptyfar[x_,y_]:==Max[Re[spherefar[x,y]],Re[-(R2^2-x^2)^(1/2)]+y*Tan[i]]
emptybrightness[x_,y_]:==Boole[-R1<x<R1]*(emptynear[x,y] -jetnear[x,y] +
jetfar[x,y]- emptyfar[x,y])*e2 +(Boole[-R2
<x<-R1]+Boole[R2>x>R1])*(emptynear[x,y] -jetnear[x,y] + jetfar[x,y]-
emptyfar[x,y])*e2
spherebrightness[x_,y_]:==Boole[-R2<x<R2]*(spherenear[x,y] -emptynear[x,y] +
emptyfar[x,y]- spherefar[x,y])*e3 +(Boole[x<-R2]+Boole[R2<x])*(spherenear[x,y] -
spherefar[x,y])*e3
=E3=80=80
f[x_,y_]:==((jetnear[x,y]-jetfar[x,y])*e1+e3*(spherenear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefar[x,y])+e2*(emptynear[x,y]-jetnear[x,y]+jetfar[x,y]-emptyfar[x,y]))*Boole[-R1<x<R1]+((emptynear[x,y]-emptyfar[x,y])*e2+e3*(spherenear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefar[x,y]))*(Boole[-R2<x<-R1]+Boole[R2>x>R1])+(spherenear[x,y]-spherefar[x,y])*e3*(Boole[x<-R2]+Boole[x>R2])

=E3=80=80
1.029
3.892
8
250
11.8
80.5p=C2 
originalPlot==ContourPlot[f[x,y],{x,-8,8},{y,-8,8},Contours=EF=82=AE50,ColorFunction=EF=82=AE(Hue[#]&)]/12

originalColorData====ImageData[originalPlot];
targetPixels====Position[originalColorData,originalColorData[[180,180]]];newColorData====ReplacePart[originalColorData,targetPixels

->
Image[newColorData]
But I got the following error message:
Part::partd: Part specification
\[NoBreak]originalColorData=EF=81=90180,180\[RightDoubleBracket]\[NoBreak] is longer
than depth of object. =EF=82=87
=C2 
Image::imgarray: The specified argument \[NoBreak]originalColorData\[NoBreak]
should be an array of rank 2 or 3 with machine-size numbers. =EF=82=87
I will be very grateful if you could help me.
Thanks a lot
Best regards
Maria
=C2 {1.,1.,1.}];

________________________________
Da: J. Batista <jbatista800 at gmail.com>
A: mathgroup at smc.vnet.net
Inviato: Lun 2 agosto 2010, 13:02:00
Oggetto: [mg111445] Re: Problem with Min Max between two functions

Maria/All, I just learned from a colleague that all equations on my message
have double equal signs.=C2  Please note that is probably due to a transm=
ission
error.=C2  All equations should only have a single equal sign.=C2  I'm
retransmitting my original message.
Regards,
J. Batista
On Sun, Aug 1, 2010 at 3:10 AM, J. Batista <jbatista800 at gmail.com> wrote:

> Dean Maria, here is a possible solution to your question.=C2  The white
> contour areas can be removed by approaching the output of ContourPlot as =
an
> image, treating the task as one of image processing (as suggested previou=
sly
> by Daniel Lichtblau).=C2  First, equate the original ContourPlot output=
 with a
> variable name, for example originalPlot ==== Out[1]=C2  (where Out[1] i=
s the
> ContourPlot output cell).=C2  Alternatively, you can simply select the
> ContourPlot, copy and then paste into the first line of the code sequence
> below in place of the variable originalPlot.=C2  I will now display the=
 four
> lines of the code sequence and then explain them afterwards.
>
> originalColorData ==== ImageData[originalPlot];
>
> targetPixels ==== Position[originalColorData, originalColorData[[180, 180=
]]];
>
> newColorData ==== ReplacePart[originalColorData, targetPixels -> {1., 1.,
> 1.}];
>
> Image[newColorData]
>
>
> The first code line accomplishes the task of collecting and reading the
> ContourPlot into computer memory as image data, in this case a vector of =
RGB
> color values.=C2  Note that I place a semicolon at the end of this and =
other
> lines of code in order to suppress the visual output of the code sequence=
's
> result.=C2  This is because the vector is lengthy and will clog the not=
ebook
> unnecessarily.
> The second code line establishes the pattern by which the portions of the
> plot that you wish to alter are identified as a subset of the entire
> original data set.=C2  The pattern is established by entering the pixel
> coordinate of a representative target pixel that you wish to alter, in th=
is
> case [[180, 180]] being one of the pixels in the white contour areas.=C2=
  You
> can determine an appropriate pixel coordinate by right-clicking in the
> original ContourPlot output, selecting Get Indices, and then guiding your
> cursor to a desired location within the plot.
> The third code line replaces the pixel locations flagged by the previous
> pattern search with new pixel data, in this case new RGB color values tha=
t
> you select.=C2  I have used the example of {1., 1., 1.} to illustrate c=
hanging
> from the semi-white color of the original plot to a true white that match=
es
> the plot background.=C2  Be sure to use decimal points as above when ex=
pressing
> color values for your pixels, as something like {1, 1, 1} will not
> be understood correctly for this purpose.=C2  If you want to change the
> semi-white color of your original plot to black, use {0., 0., 0.}.
> The fourth and final line re-establishes the newly altered set of pixel
> data as an image object, and displays the altered image.
>
> Hope this helps.
> Best Regards,
> J. Batista
>
>=C2  On Mon, Jul 26, 2010 at 6:37 AM, maria giovanna dainotti <
> mariagiovannadainotti at yahoo.it> wrote:
>
>> Dear Mathgroup,
>> I have the following function
>> R1====1.029
>> R2====3.892
>> R3====8
>> e1====250
>> e2====11.8
>> e3====80.5
>> i====pi/12
>> spherenear[x_,y_]:====((R3^2-x^2-y^2)^(1/2))
>> spherefar[x_,y_]:====-((R3^2-x^2-y^2)^(1/2))
>> emptynear[x_,y_]:====Min[Re[spherenear[x,y]],Re[(R2^2-x^2)^(1/2)+y*Tan[i=
]]==
]
>> emptyfar[x_,y_]:====Max[Re[spherefar[x,y]],Re[-(R2^2-x^2)^(1/2)]+y*Tan[i=
]]
>> jetnear[x_,y_]:====Min[Re[spherenear[x,y]],Re[(R1^2-x^2)^(1/2)+y*Tan[i]]=
]
>> jetfar[x_,y_]:====Max[Re[spherefar[x,y]],Re[-(R1^2-x^2)^(1/2)]+y*Tan[i]]
>>
>> f[x_,y_]:====((jetnear[x,y]-jetfar[x,y])*e1+e3*(spherenear[x,y]-emptynea=
r[==
x,y]+emptyfar[x,y]-spherefar[x,y])+e2*(emptynear[x,y]-jetnear[x,y]+jetfar[x=
==
,y]-emptyfar[x,y]))*Boole[-R1====EF====82====A3x====EF====82====A3R1]+((emp=
tynear[x,y]-==
emptyfar[x,y])*e2+e3*(spherenear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefa=
==
r[x,y]))*(Boole[-R2<x<-R1]+Boole[R2>x>R1])+(spherenear[x,y]-spherefar[x,y])=
==
*e3*(Boole[x<-R2]+Boole[x>R2])
>>
>>
>> ContourPlot[f[x,y],{x,-8,8},{y,-8,8},Contours====EF====82====AE{0,100,20=
0,300,==
400,500,600,700,800,900}]
>>
>> From the picture you can see there is a white contours that results a bi=
==
t
>> odd, I
>> think th at it comes out from the introduction of the Min and Max.
>> I would like to remove this white contour. Could you help me?
>> Thanks a lot for your attention
>> Cheers
>> Maria
>>
>>
>


     

--0-882231370-1282758216=:97664
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Sun-Content-Length: 10136

<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></he=
ad><body><div style="font-family:arial, helvetica, sans-serif;font-size:1=
4pt"><DIV>Dear J. Batista,</DIV>=0A<DIV>I used the following equations</DIV=
>=0A<DIV>=0A<P>R1=1.029</P>=0A<P>R2=3.892</P>=0A<P>R3=8</P>=0A<P>e1=
=250</P>=0A<P>e2=11.8</P>=0A<P>e3=80.5</P>=0A<P>i=<FONT face=Math=
ematica1Mono>p</FONT>/12</P>=0A<P>spherenear[x_,y_]:=((R3^2-x^2-y^2)^(1/2=
))</P>=0A<P>spherefar[x_,y_]:=-((R3^2-x^2-y^2)^(1/2))</P>=0A<P>jetnear[x_=
,y_]:=Min[Re[spherenear[x,y]],Re[(R1^2-x^2)^(1/2)+y*Tan[i]]]</P>=0A<P>jet=
far[x_,y_]:=Max[Re[spherefar[x,y]],Re[-(R1^2-x^2)^(1/2)]+y*Tan[i]]</P>=0A=
<P>jetbrightness[x_,y_]:=Boole[-R1<FONT face=Mathematica1Mono>=EF=82=A3=
</FONT>x<FONT face=Mathematica1Mono>=EF=82=A3</FONT>R1]*(jetnear[x,y] - j=
etfar[x,y])*e1</P>=0A<P>emptynear[x_,y_]:=Min[Re[spherenear[x,y]],Re[(R2^=
2-x^2)^(1/2)+y*Tan[i]]]</P>=0A<P>emptyfar[x_,y_]:=Max[Re[spherefar[x,y]],=
Re[-(R2^2-x^2)^(1/2)]+y*Tan[i]]</P>=0A<P>emptybrightness[x_,y_]:=Boole[-R=
1<FONT face=Mathematica1Mono>&lt;</FONT>x<FONT face=Mathematica1Mono>&l=
t;</FONT>R1]*(emptynear[x,y] -jetnear[x,y] + jetfar[x,y]- emptyfar[x,y])*e2=
 +(Boole[-R2 &lt;x&lt;-R1]+Boole[R2&gt;x&gt;R1])*(emptynear[x,y] -jetnear[x=
,y] + jetfar[x,y]- emptyfar[x,y])*e2</P>=0A<P>spherebrightness[x_,y_]:=Bo=
ole[-R2<FONT face=Mathematica1Mono>&lt;</FONT>x<FONT face=Mathematica1M=
ono>&lt;</FONT>R2]*(spherenear[x,y] -emptynear[x,y] + emptyfar[x,y]- sphere=
far[x,y])*e3 +(Boole[x&lt;-R2]+Boole[R2&lt;x])*(spherenear[x,y] - spherefar=
[x,y])*e3</P>=0A<P>=E3=80=80</P>=0A<P>f[x_,y_]:=((jetnear[x,y]-jetfar[x,y=
])*e1+e3*(spherenear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefar[x,y])+e2*(=
emptynear[x,y]-jetnear[x,y]+jetfar[x,y]-emptyfar[x,y]))*Boole[-R1<FONT face=
=Mathematica1Mono>&lt;</FONT>x<FONT face=Mathematica1Mono>&lt;</FONT>R1=
]+((emptynear[x,y]-emptyfar[x,y])*e2+e3*(spherenear[x,y]-emptynear[x,y]+emp=
tyfar[x,y]-spherefar[x,y]))*(Boole[-R2&lt;x&lt;-R1]+Boole[R2&gt;x&gt;R1])+(=
spherenear[x,y]-spherefar[x,y])*e3*(Boole[x&lt;-R2]+Boole[x&gt;R2])</P>=0A<=
P>=E3=80=80</P>=0A<P>1.029</P>=0A<P>3.892</P>=0A<P>8</P>=0A<P>250</P>=0A<P>=
11.8</P>=0A<P>80.5</P><FONT face=Mathematica1Mono>=0A<P>p</FONT><FONT fac=
e="Times New Roman">/12</FONT></P>&nbsp;<BR><B><FONT face=Courier>=0A<P=
>originalPlot=ContourPlot[f[x,y],{x,-8,8},{y,-8,8},Contours</FONT><FONT f=
ace=Mathematica1Mono>=EF=82=AE</FONT><FONT face=Courier>50,ColorFunctio=
n</FONT><FONT face=Mathematica1Mono>=EF=82=AE</FONT><FONT face=Courier>=
(Hue[#]&amp;)]</P></B></FONT></DIV>=0A<DIV style="FONT-FAMILY: arial, hel=
vetica, sans-serif; FONT-SIZE: 14pt"><B><FONT face=Courier>=0A<P align==
left>originalColorData==ImageData[originalPlot];</P>=0A<P align=left>=
targetPixels==Position[originalColorData,originalColorData[[180,180]]];=
newColorData==ReplacePart[originalColorData,targetPixels</P>=0A<P align=
=left>-&gt;</FONT><FONT face=Courier>{1.,1.,1.}];</P>=0A<P>Image[newCol=
orData]</P>=0A<P>But I got the following error message: </P>=0A<P>Part::par=
td: Part specification \[NoBreak]originalColorData<FONT face=Mathematica2=
>=EF=81=90</FONT>180,180\[RightDoubleBracket]\[NoBreak] is longer than dept=
h of object. <A href="http://reference.wolfram.com/mathematica/ref/Part.h=
tml"><FONT face=Mathematica1>=EF=82=87</FONT></A></P>=0A<P>&nbsp;</P>=0A<=
P>Image::imgarray: The specified argument \[NoBreak]originalColorData\[NoBr=
eak] should be an array of rank 2 or 3 with machine-size numbers. <A href=
="http://reference.wolfram.com/mathematica/ref/Image.html";><FONT face=M=
athematica1>=EF=82=87</FONT></A></P>=0A<P>I will be very grateful if you co=
uld help me.</P>=0A<P>Thanks a lot</P>=0A<P>Best regards</P>=0A<P>Maria</P>=
=0A<P>&nbsp;</P></B></FONT>=0A<DIV style="FONT-FAMILY: arial, helvetica, =
sans-serif; FONT-SIZE: 13px"><FONT size=2 face=Tahoma>=0A<HR SIZE=1>=
=0A<B><SPAN style="FONT-WEIGHT: bold">Da:</SPAN></B> J. Batista &lt;jbati=
sta800 at gmail.com&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">A:</SPAN></B> =
mathgroup at smc.vnet.net<BR><B><SPAN style="FONT-WEIGHT: bold">Inviato:</SP=
AN></B> Lun 2 agosto 2010, 13:02:00<BR><B><SPAN style="FONT-WEIGHT: bold"=
>Oggetto:</SPAN></B> [mg111445] Re: Problem with Min Max between two functi=
ons<BR></FONT><BR>Maria/All, I just learned from a colleague that all equat=
ions on my message<BR>have double equal signs.&nbsp; Please note that is pr=
obably due to a transmission<BR>error.&nbsp; All equations should only have=
 a single equal sign.&nbsp; I'm<BR>retransmitting my original message.<BR>R=
egards,<BR>J. Batista<BR>On Sun, Aug 1, 2010 at 3:10 AM, J. Batista &lt;<A =
href="mailto:jbatista800 at gmail.com" ymailto="mailto:jbatista800 at gmail.c=
om">jbatista800 at gmail.com</A>&gt; wrote:<BR><BR>&gt; Dean Maria, here is a =
possible solution to your question.&nbsp; The white<BR>&gt; contour areas c=
an be
 removed by approaching the output of ContourPlot as an<BR>&gt; image, trea=
ting the task as one of image processing (as suggested previously<BR>&gt; b=
y Daniel Lichtblau).&nbsp; First, equate the original ContourPlot output wi=
th a<BR>&gt; variable name, for example originalPlot == Out[1]&nbsp; (w=
here Out[1] is the<BR>&gt; ContourPlot output cell).&nbsp; Alternatively, y=
ou can simply select the<BR>&gt; ContourPlot, copy and then paste into the =
first line of the code sequence<BR>&gt; below in place of the variable orig=
inalPlot.&nbsp; I will now display the four<BR>&gt; lines of the code seque=
nce and then explain them afterwards.<BR>&gt;<BR>&gt; originalColorData ==
= ImageData[originalPlot];<BR>&gt;<BR>&gt; targetPixels == Position[o=
riginalColorData, originalColorData[[180, 180]]];<BR>&gt;<BR>&gt; newColorD=
ata == ReplacePart[originalColorData, targetPixels -&gt; {1., 1.,<BR>&g=
t; 1.}];<BR>&gt;<BR>&gt; Image[newColorData]<BR>&gt;<BR>&gt;<BR>&gt; The fi=
rst code
 line accomplishes the task of collecting and reading the<BR>&gt; ContourPl=
ot into computer memory as image data, in this case a vector of RGB<BR>&gt;=
 color values.&nbsp; Note that I place a semicolon at the end of this and o=
ther<BR>&gt; lines of code in order to suppress the visual output of the co=
de sequence's<BR>&gt; result.&nbsp; This is because the vector is lengthy a=
nd will clog the notebook<BR>&gt; unnecessarily.<BR>&gt; The second code li=
ne establishes the pattern by which the portions of the<BR>&gt; plot that y=
ou wish to alter are identified as a subset of the entire<BR>&gt; original =
data set.&nbsp; The pattern is established by entering the pixel<BR>&gt; co=
ordinate of a representative target pixel that you wish to alter, in this<B=
R>&gt; case [[180, 180]] being one of the pixels in the white contour areas=
.&nbsp; You<BR>&gt; can determine an appropriate pixel coordinate by right-=
clicking in the<BR>&gt; original ContourPlot output, selecting Get
 Indices, and then guiding your<BR>&gt; cursor to a desired location within=
 the plot.<BR>&gt; The third code line replaces the pixel locations flagged=
 by the previous<BR>&gt; pattern search with new pixel data, in this case n=
ew RGB color values that<BR>&gt; you select.&nbsp; I have used the example =
of {1., 1., 1.} to illustrate changing<BR>&gt; from the semi-white color of=
 the original plot to a true white that matches<BR>&gt; the plot background=
.&nbsp; Be sure to use decimal points as above when expressing<BR>&gt; colo=
r values for your pixels, as something like {1, 1, 1} will not<BR>&gt; be u=
nderstood correctly for this purpose.&nbsp; If you want to change the<BR>&g=
t; semi-white color of your original plot to black, use {0., 0., 0.}.<BR>&g=
t; The fourth and final line re-establishes the newly altered set of pixel<=
BR>&gt; data as an image object, and displays the altered image.<BR>&gt;<BR=
>&gt; Hope this helps.<BR>&gt; Best Regards,<BR>&gt; J.
 Batista<BR>&gt;<BR>&gt;&nbsp; On Mon, Jul 26, 2010 at 6:37 AM, maria giova=
nna dainotti &lt;<BR>&gt; <A href="mailto:mariagiovannadainotti at yahoo.it"=
 ymailto="mailto:mariagiovannadainotti at yahoo.it">mariagiovannadainotti@ya=
hoo.it</A>&gt; wrote:<BR>&gt;<BR>&gt;&gt; Dear Mathgroup,<BR>&gt;&gt; I hav=
e the following function<BR>&gt;&gt; R1==1.029<BR>&gt;&gt; R2==3.89=
2<BR>&gt;&gt; R3==8<BR>&gt;&gt; e1==250<BR>&gt;&gt; e2==11.8<BR=
>&gt;&gt; e3==80.5<BR>&gt;&gt; i==pi/12<BR>&gt;&gt; spherenear[x_,y=
_]:==((R3^2-x^2-y^2)^(1/2))<BR>&gt;&gt; spherefar[x_,y_]:==-((R3^2-=
x^2-y^2)^(1/2))<BR>&gt;&gt; emptynear[x_,y_]:==Min[Re[spherenear[x,y]],=
Re[(R2^2-x^2)^(1/2)+y*Tan[i]]=<BR>]<BR>&gt;&gt; emptyfar[x_,y_]:==Max=
[Re[spherefar[x,y]],Re[-(R2^2-x^2)^(1/2)]+y*Tan[i]]<BR>&gt;&gt; jetnear[x_,=
y_]:==Min[Re[spherenear[x,y]],Re[(R1^2-x^2)^(1/2)+y*Tan[i]]]<BR>&gt;&gt=
; jetfar[x_,y_]:==Max[Re[spherefar[x,y]],Re[-(R1^2-x^2)^(1/2)]+y*Tan[i]=
]<BR>&gt;&gt;<BR>&gt;&gt;
 f[x_,y_]:==((jetnear[x,y]-jetfar[x,y])*e1+e3*(spherenear[x,y]-emptynea=
r[=<BR>x,y]+emptyfar[x,y]-spherefar[x,y])+e2*(emptynear[x,y]-jetnear[x,y]=
+jetfar[x=<BR>,y]-emptyfar[x,y]))*Boole[-R1==EF==82==A3x==
=EF==82==A3R1]+((emptynear[x,y]-=<BR>emptyfar[x,y])*e2+e3*(sphe=
renear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefa=<BR>r[x,y]))*(Boole[-R2=
&lt;x&lt;-R1]+Boole[R2&gt;x&gt;R1])+(spherenear[x,y]-spherefar[x,y])=<BR>=
*e3*(Boole[x&lt;-R2]+Boole[x&gt;R2])<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt; Co=
ntourPlot[f[x,y],{x,-8,8},{y,-8,8},Contours==EF==82==AE{0,100,2=
00,300,=<BR>400,500,600,700,800,900}]<BR>&gt;&gt;<BR>&gt;&gt; From the pi=
cture you can see there is a white contours that results a bi=<BR>t<BR>&g=
t;&gt; odd, I<BR>&gt;&gt; think th at it comes out from the introduction of=
 the Min and Max.<BR>&gt;&gt; I would like to remove this white contour. Co=
uld you help me?<BR>&gt;&gt; Thanks a lot for your attention<BR>&gt;&gt; Ch=
eers<BR>&gt;&gt;
 Maria<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;<BR><BR><BR></DIV></DIV></div><br>=0A=
=0A=0A=0A      </body></html>
--0-882231370-1282758216=:97664--


  • Prev by Date: Re: Dynamic Text in Manipulate.
  • Next by Date: Re: FindMaximum doesn't converge
  • Previous by thread: Re: Problem with Min Max between two functions
  • Next by thread: Re: Problem with Min Max between two functions