Subject: gridlines styles.
i always get baffled at things like this.
from the help menu...
Grid line styles can involve graphics directives such
as RGBColor and Thickness
k. fine.
Plot[Sin[x], {x, 0, 2Pi}, GridLines -> Automatic]
Plot[Sin[x], {x, 0, 2Pi}, GridLines -> Automatic,
GridLinesStyle -> RGBColor[0, 1, 1]]
Apparently GridLinesStyle is not the options.
hm. how can Mathematica set the option for Grid Lines Style if
not GridLinesStyle?
any insights will be greatly appreciated.]
sean
__________________________________
===
Subject: Re: Another bizarre phenomenon
>I replaced a 3-letter symbol with another 3-letter symbol, looking at
>each search and replacement. All seemed ok. Then I tried to execute the
>file and it went nuts. I somehow found that if I removed JUST ONE SPACE
>between the Module list of local symbols in a function definition line,
>and a comment on the same line, all was OK again. Wow. This happened
>at least twice, identically. Any comments?
>Steve Gray
program would have such obvious bugs. The one about comments is far from
the
first one i've encountered. My respect for the program just went down a
bunch
and my caution just went down by the same amount. I will no longer assume
that bugs are my fault.
Steve Gray
===
Subject: Re: Matrix Problem
It would be N=Reverse@M.
But don't use N as a variable; it's an important built-in function.
To avoid conflicts, you should never capitalize your own symbols.
Bobby
> Suppose I have a m*n matrix like this type.
> M={{1, a1, b1, c1}, {2, a2, b2, c2}, {3, a3, b3, c3}, {4, a4, b4, c4}, {5,
a5,
> b5, c5}, {6, a6, b6, c6}, {7, a7, b7, c7}}
> I want to change my matrix in such a way,
> N={{7, a7, b7, c7}, {6, a6, b6, c6}, {5, a5, b5, c5}, {4, a4, b4, c4}, {3,
a3,
> b3, c3}, {2, a2, b2, c2}, {1, a1, b1, c1}}
> Could anybody tell me how to this.
> nilaakash
--
DrBob@bigfoot.com
www.eclecticdreams.net
===
Subject: Re: Matrix Problem
Try
Reverse[M]
Regs,
Ravi
> Suppose I have a m*n matrix like this type.
> M={{1, a1, b1, c1}, {2, a2, b2, c2}, {3, a3, b3, c3}, {4, a4, b4, c4}, {5,
a5,
> b5, c5}, {6, a6, b6, c6}, {7, a7, b7, c7}}
> I want to change my matrix in such a way,
> N={{7, a7, b7, c7}, {6, a6, b6, c6}, {5, a5, b5, c5}, {4, a4, b4, c4}, {3,
a3,
> b3, c3}, {2, a2, b2, c2}, {1, a1, b1, c1}}
> Could anybody tell me how to this.
> nilaakash
===
Subject: An Integration bug?
Is this another integration bug in Mathematica 5.0? Or am I doing something
wrong? Below I define two functions x[t] and h[t], then in eq1 I integrate
the integrand ( x[tau] h[t-tau] ) from -inf to +inf and get one set of
results and plots, then I integrate the same integrand as before but this
time in two steps, once from -inf to 0 and once from 0 to +inf, but the
results and plots from the integration performed in two steps are NOT the
same as the results and plots from integration in one step. Is this a bug
and if so what's the work around?
Try this in the input cell
In[19]:=
x[t_] = (3Exp[-.5t]UnitStep[t]) + DiracDelta[t + 3]
h[t_] = UnitStep[t] - UnitStep[t - 2]
eq1 = Integrate[x[[Tau]]h[t - [Tau]], {[Tau], -[Infinity],
[Infinity]}]
Plot[eq1, {t, -10, 10}, PlotRange -> All]
eq2 = Integrate[x[[Tau]]h[t - [Tau]], {[Tau], 0, [Infinity]}]
Plot[eq2, {t, -10, 10}, PlotRange -> All]
eq3 = Integrate[x[[Tau]]h[t - [Tau]], {[Tau], -[Infinity], 0}]
Plot[eq3, {t, -10, 0}, PlotRange -> All]
You will get the following output expressions (I couldn't paste the plots
here, but if you run the above input cells you should get the plots too,
then it will be more obvious what the problem is)
Out[21]=
!(1/2 ((1 + (6.` @(((-2) +
t))^2)/(((2.`)(
[InvisibleSpace])) - 1.` t) + (6.` @t^2)/t + @((3
+
t))^2/(3
+ t) - (1 + t + @((1 + t))^2)/(1 + t))))
Out[23]=
!((((-6.`) +
16.30969097075427` [ExponentialE]^((-0.5`) t)))
UnitStep[
(-2) + t] + ((((6.`)([InvisibleSpace])) -
6.` [ExponentialE]^((-0.5`) t))) UnitStep[t])
Out[25]=
!(1/2 (((-((1 +
t)/@((1 + t))^2)) + (3 + t)/@((3 +
t))^2)))
===
Subject: Hypergeometric functions and Sum error in 5.01?
Mathematica 5.01 produces the following:
In[1]:= s1=Sum[Binomial[n-i,m]2^i,{i,0,n-m}]
Out[1]= Gamma[1+n] Hypergeometric2F1[1,m-n,-n,2] / (Gamma[1+m]
Gamma[1-m+n])
In[2]:= Table[{s1,Sum[Binomial[n-i,m]2^i,{i,0,n-m}]}/.n¨3,{m,1,3}]
Out[2]= {{-5,11},{-11,5},{-15,1}}
Out[2] compares Mathematica's closed form with actual values. There appears
to be an error in the rules used by Sum when simplifying this expression.
Richard Ollerton
r.ollerton@uws.edu.au
===
Subject: Re: Re: cross-product in cylindrical problem
Actually you should be able to read it if you use Unicode as your
default encoding format for messages or if your mail program allows you
to choose the encoding that should be used for displaying a message.
Most modern mailers can do this and Unicode is used by all fairly
modern OSs known to me. (Since Apple's Mail uses Unicode by default I
keep forgetting that it can cause problems when copying and pasting
plain text from Mathematica.)
Anyway, here is the same thing in a less elegant but universally
readable form:
SetCoordinates[Cylindrical[[Rho], [Phi], z]];
Andrzej
> hello Andrzej,
> what
> the symobls are suppposed to be in:
SetCoordinates[Cylindrical[ìª, ì.,
> z]];
>> I forgot to include the line:
>> SetCoordinates[Cylindrical[ìª, ì., z]];
>> Without that JacobianMatrix[] should be replaced by
>> JacobianMatrix[Cylindrical[ìª, ì., z]].
>> Andrzej
>> I'm really puzzled by this behavior of Mathematica, I have two
>> vectors in
>> cylindrical coordinates and would like to take their cross-product
>> in
>> cylindrical, but it seems to give me incorrect answer, see below:
>> define parametric path {r,phi,z}
>> In[110]:=
>> f[[Rho]_, [Phi]_] = {[Rho], [Phi], 0}
>> Out[110]=
>> {[Rho], [Phi], 0}
>> take derivates of path w.r.t. r then w.r.t phi, get {1,0,0}, and
>> {0,1,0}
>> In[113]:=
>> v1 = D[f[[Rho], [Phi]], [Rho]]
>> v2 = D[f[[Rho], [Phi]], [Phi]]
>> Out[113]=
>> {1, 0, 0}
>> Out[114]=
>> {0, 1, 0}
>> then cross them in cylindrical coords, and should get {0,0,1}, but
>> instead
>> get wrong answer below
>> In[117]:=
>> n = CrossProduct[v1, v2, Cylindrical[[Rho], [Phi], z]] //
>> FullSimplify
>> Out[117]=
>> {0, 0, 0}
>> As you can see, when I cross {1,0,0} with {0,1,0} in cylindrical
>> coords, I
>> get {0,0,0}, when I should be getting {0,0,1}.
>> Can anyone help?
> The problem is with the meaning of two vectors in cylindrical
> coordinates. Even if your default coordinate system is cylindrical,
> Mathematica still represents tangent vectors using Cartesian
> coordinates. In other words, the meaning of a vector {a,b,c} in
> cylindrical coordinates is the vector given by:
> << Calculus`VectorAnalysis`
> CoordinatesToCartesian[{a,b,c},Cylindrical]
> Thus, the vectors {1,0,0} and {0,1,0} are turned to:
> CoordinatesToCartesian[{1, 0, 0}, Cylindrical]
> {1, 0, 0}
> and
> CoordinatesToCartesian[{0,1,0},Cylindrical]
> {0,0,0}
> So you get the zero vector (since {0,1,0} in cylindrical coordinates
> represents just the origin) and hence the result you get.
> I am not hundred percent sure what you meant. But I suppose thatt by
> {1,0,0} and {0,1,0} in cylindrical coordinates you meant the basic
> vector fields in the tangent bundle of R^3 (in other words vectors
> changing from point to point). Presumably (I am guessing) the vector
> (field) {1,0,0} is
> JacobianMatrix[] . {1, 0, 0}
> {Cos[ì.], Sin[ì.], 0}
> and the vector (field) {0,1,0} is
> JacobianMatrix[] . {0, 1, 0}
> {(-ìª)*Sin[ì.], ìª*Cos[ì.], 0}
> in Cartesian coordinates.
> In that case
> Simplify[Cross[JacobianMatrix[] . {1, 0, 0}, JacobianMatrix[] . {0,
> 1,
> 0}]]
> {0, 0, ìª}
> which is the vector field sometimes denoted by {0,0,1} in cylindrical
> coordinates.
> Andrzej Kozlowski
> Chiba, Japan
> http://www.akikoz.net/~andrzej/
> http://www.mimuw.edu.pl/~akoz/
===
Subject: Calabi-Yau Manifold visualization
I am seeking code to generate the 3D visualization of the 6D Calabi-Yau
Manifold that appears in string theory presentations such as Brian
Greene's book.
For your information, the code will be used to produce an illustration
in a book by David Nelson that deals with religion in some fashion.
Nelson has identified a person who has such code (who can be found
easily via Google), but (as I understand it) this person will not give
Nelson permission to use the code and/or image.
I take no position on the property rights issue; I am just trying to
help a friend of a friend of a friend.
--Mark.
===
Subject: bimodal ditribution form counting signs of Pi digits differences
This program is real slow on my machine.
Show a lean toward positive differences that is slight at 2000 digits.
Digits=2000
$MaxExtraPrecision = Digits
(* Sum of the sign of the differences between the first 2000 digits of Pi*)
f[m_]=Sum[Sign[Floor[Mod[10^(n+1)*Pi,10]]-Floor[Mod[10^n*Pi,10]]],{n,0,m}]
a=Table[{n,f[n]},{n,0,Digits-1}];
ListPlot[a,PlotJoined->True]
b=Table[a[[n]][[2]],{n,1,Dimensions[a][[1]]}];
(* distribution of the noise that results*)
c=Table[Count[b,m],{m,-12,12}]
ListPlot[c,PlotJoined->True]
Respectfully, Roger L. Bagula
tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel:
619-5610814 :
alternative email: rlbtftn@netscape.net
URL : http://home.earthlink.net/~tftn
===
Subject: Mathematica's (and others) ancient widget toolkit ... why?
(also sent to suggestions@wolfram.com)
this is a personal opinion of mine, regarding the use of Motif (or whatever
the Mathematica GUI was developed with) under Unix/Linux.
I have been using Mathematica for some months and I like its features but
the GUI looks like it hasn't evolved since 1980. (see attached screenshot
for comparison)
Since about 1998, more advanced toolkits are available that are much easier
to develop for (I know, I use them), like Qt and Gtk, and it is supposed to
be very easy to port Motif based apps to Qt (see
http://doc.trolltech.com/3.3/motif-walkthrough.html) (though I haven't used
*that* feature yet). Qt is also 1:1 source code compatible across Linux,
UNIX, Windows, and MacOSX which might be an added plus.
The gains would be considerate: Mathematica would automatically gain faster
graphics display, proper font display, font useage and font antialising,
better window manager/desktop/printing integration, Mathematica and its
tools would automatically respect the user's preferences of display colors
and font sizes and if you really want to spoil the Linux user base, provide
pre-packaged RPM packages to install, which properly integrate into the
system and can be managed by the system's RPM frontends (SuSE's YaST for
example), instead of clunky text based install scripts.
What I'd like to know is, am I the first to notice this? Why continue
selling a version of Mathematica that even though its *features* are great,
looks like it's been lying there and rusting since 1980, doesn't support
mouse wheel actions, pops up tooltips that don't disappear even if you
change virtual desktops, doesn't support proper cut&paste and drag&drop via
XDnD, takes seconds to redraw a window on a 1.8GHz-P4, uses seemingly
non-standard fonts that make headers in the documentation invisible on a
SuSE Linux 9.1 standard installation, and so on?
Seriously, your software works great, but it is absolute hell to use. It
would be much more productive (and fun!) if it would behave and look
properly, like the rest of my desktop. Please consider this for the future
of Mathematica.
--
Jens Benecke
http://www.hitchhikers.de - Europas kostenlose Mitfahrzentrale seit 1998
http://www.rb-hosting.de - Webhosting mit Extras - PHP ab Û9 -
SSH ab Û19
http://www.spamfreemail.de - 100% saubere Postf.8acher, garantiert!
===
Subject: Re: MovieParametericPlot-3D
Yes, you can animate 3d plots.
Here's an old notebook with not pictures for a Bours minimal surface:
(I'm not gauanteeing it is a good one, it is just what sherlock found me
for animate
that had no pictures)
(***********************************************************************
Mathematica-Compatible Notebook
This notebook can be used on any computer system with Mathematica 3.0,
MathReader 3.0, or any compatible application. The data for the notebook
starts with the line of stars above.
To get the notebook into a Mathematica-compatible application, do one of
the following:
* Save the data starting with the line of stars above into a file
with a name ending in .nb, then open the file inside the application;
* Copy the data starting with the line of stars above to the
clipboard, then use the Paste menu command inside the application.
Data for notebooks contains only printable 7-bit ASCII and can be
sent directly in email or through ftp in text mode. Newlines can be
CR, LF or CRLF (Unix, Macintosh or MS-DOS style).
NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing the
word CacheID, otherwise Mathematica-compatible applications may try to
use invalid cache data.
For more information on notebooks and Mathematica-compatible
applications, contact Wolfram Research:
web: http://www.wolfram.com
email: info@wolfram.com
phone: +1-217-398-0700 (U.S.)
Notebook reader applications are available free of charge from
Wolfram Research.
***********************************************************************)
(*CacheID: 232*)
(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[ 6639, 198]*)
(*NotebookOutlinePosition[ 7482, 225]*)
(* CellTagsIndexPosition[ 7438, 221]*)
(*WindowFrame->Normal*)
Notebook[{
Cell[BoxData[
(Clear[t, d, p, f, g, z, x])], Input],
Cell[CellGroupData[{
Cell[BoxData[
(f[t_] = ((Cos[2*t] - r^2*Cos[4*t]/2))/4)], Input],
Cell[BoxData[
(1/4 ((Cos[2 t] - 1/2 r^2 Cos[4 t])))],
Output]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[
(g[t_] = ((Sin[2*t] + r^2*Sin[4*t]/2))/4)], Input],
Cell[BoxData[
(1/4 ((Sin[2 t] + 1/2 r^2 Sin[4 t])))],
Output]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[
(x1 = r^2*f[t])], Input],
Cell[BoxData[
(1/4 r^2 ((Cos[2 t] - 1/2 r^2 Cos[4 t])))],
Output]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[
(y1 = r^2*g[t])], Input],
Cell[BoxData[
(1/4 r^2 ((Sin[2 t] + 1/2 r^2 Sin[4 t])))],
Output]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[
(z1 = r^3*Cos[3*t]/3)], Input],
Cell[BoxData[
(1/3 r^3 Cos[3 t])], Output]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{M, =,
RowBox[{(, GridBox[{
{(((1 + Cos[aa]))/2), ((-Sqrt[2])*Sin[aa]/2),
(((1 - Cos[aa]))/2)},
{(Sqrt[2]*Sin[aa]/2), (Cos[aa]),
((-Sqrt[2])*Sin[aa]/2)},
{(((1 - Cos[aa]))/2), (Sqrt[2]*Sin[aa]/2),
(((1 + Cos[aa]))/2)}
}], )}]}]], Input],
Cell[BoxData[
({{1/2 ((1 + Cos[(2 [Pi] w)/25])),
(-(Sin[(2 [Pi] w)/25]/@2)),
1/2 ((1 - Cos[(2 [Pi] w)/25]))}, {
Sin[(2 [Pi] w)/25]/@2, Cos[(2 [Pi]
w)/25],
(-(Sin[(2 [Pi] w)/25]/@2))}, {
1/2 ((1 - Cos[(2 [Pi] w)/25])),
Sin[(2 [Pi] w)/25]/@2,
1/2 ((1 + Cos[(2 [Pi] w)/25]))}})],
Output]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[
(xyz = M . {x1, y1, z1})], Input],
Cell[BoxData[
({(5
((Cos[2 t] + Cos[3 t] + 1/4 Cos[2 t] Cos[3 t] +
1/4 Cos[3 t] Cos[5 t]))
((1 + Cos[(2 [Pi] w)/25])))/(10 +
Cos[p0]) +
1/50 ((10 + Cos[p0])) ((10 + Cos[p0 + (2
[Pi])/3]))
((1 - Cos[(2 [Pi] w)/25]))
((1/4 Sin[3 t] + 1/4 Sin[5 t])) -
(5 @2
((Sin[2 t] + 1/4 Cos[3 t] Sin[2 t] - Sin[3 t] -
1/4 Cos[5 t] Sin[3 t]))
Sin[(2 [Pi] w)/25])/(10 + Cos[p0 + (2
[Pi])/3]),
(10 Cos[(2 [Pi] w)/25]
((Sin[2 t] + 1/4 Cos[3 t] Sin[2 t] - Sin[3 t] -
1/4 Cos[5 t] Sin[3 t])))/(10 +
Cos[p0 + (2 [Pi])/3]) +
(5 @2
((Cos[2 t] + Cos[3 t] + 1/4 Cos[2 t] Cos[3 t] +
1/4 Cos[3 t] Cos[5 t]))
Sin[(2 [Pi] w)/25])/(10 + Cos[p0]) -
(((10 + Cos[p0])) ((10 + Cos[p0 + (2
[Pi])/3]))
((1/4 Sin[3 t] + 1/4 Sin[5 t]))
Sin[(2 [Pi] w)/25])/(25 @2),
(5 ((Cos[2 t] + Cos[3 t] + 1/4 Cos[2 t] Cos[3 t]
+
1/4 Cos[3 t] Cos[5 t]))
((1 - Cos[(2 [Pi] w)/25])))/(10 +
Cos[p0]) +
1/50 ((10 + Cos[p0])) ((10 + Cos[p0 + (2
[Pi])/3]))
((1 + Cos[(2 [Pi] w)/25]))
((1/4 Sin[3 t] + 1/4 Sin[5 t])) +
(5 @2
((Sin[2 t] + 1/4 Cos[3 t] Sin[2 t] - Sin[3 t] -
1/4 Cos[5 t] Sin[3 t]))
Sin[(2 [Pi] w)/25])/(10 + Cos[p0 + (2
[Pi])/3])}
)], Output]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[
(nn = Floor[pl*70/13.44370389666515])], Input],
Cell[BoxData[
(180)], Output]
}, Open ]],
Cell[BoxData[
RowBox[{gr, =,
RowBox[{Animate, [,
RowBox[{
RowBox[{ParametricPlot3D, [,
RowBox[{
xyz, ,, ({t, (-Pi), Pi}), ,, ({p0,
(-Pi), Pi}),
,, , (PlotPoints -> {nn, 20}), ,,
(PlotRange -> All), ,,
StyleBox[
(LightSources ->
{{{0, 0, 1}, RGBColor[0, 1, 0]}, n
{{1,
0, 0.4},
RGBColor[1, 0, 0]}, n
{{0,
1, 0.4},
RGBColor[0, 0, 1]}}),
Input[CenterDot]],
StyleBox[,,
Input[CenterDot]],
StyleBox[(Axes -> False),
Input[CenterDot]],
StyleBox[,,
Input[CenterDot]],
StyleBox[(Boxed -> False),
Input[CenterDot]]}], ]}], ,, ({w, 0,
25})}],
]}]}]], Input]
},
FrontEndVersion->Macintosh 3.0,
ScreenRectangle->{{0, 1920}, {0, 1060}},
WindowSize->{882, 943},
WindowMargins->{{416, Automatic}, {Automatic, 33}},
MacintoshSystemPageSetup-><
00/0001804P000000_@2@?olonh35@9B7`<5:@?l0040004/0B`000003509H04/
02d5X5k/02H20@4101P00BL?00400@0000000000000000010000000000000000
0000000000000002000000@210D00000>
]
(***********************************************************************
Cached data follows. If you edit this Notebook file directly, not using
Mathematica, you must remove the line containing CacheID at the top of
the file. The cache data will then be recreated when you save this file
from within Mathematica.
***********************************************************************)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[1709, 49, 59, 1, 27, Input],
Cell[CellGroupData[{
Cell[1793, 54, 74, 1, 27, Input],
Cell[1870, 57, 79, 1, 40, Output]
}, Open ]],
Cell[CellGroupData[{
Cell[1986, 63, 74, 1, 27, Input],
Cell[2063, 66, 79, 1, 40, Output]
}, Open ]],
Cell[CellGroupData[{
Cell[2179, 72, 46, 1, 27, Input],
Cell[2228, 75, 85, 1, 40, Output]
}, Open ]],
Cell[CellGroupData[{
Cell[2350, 81, 46, 1, 27, Input],
Cell[2399, 84, 85, 1, 40, Output]
}, Open ]],
Cell[CellGroupData[{
Cell[2521, 90, 52, 1, 27, Input],
Cell[2576, 93, 55, 1, 40, Output]
}, Open ]],
Cell[CellGroupData[{
Cell[2668, 99, 386, 8, 56, Input],
Cell[3057, 109, 439, 8, 103, Output]
}, Open ]],
Cell[CellGroupData[{
Cell[3533, 122, 55, 1, 27, Input],
Cell[3591, 125, 1774, 33, 421, Output]
}, Open ]],
Cell[CellGroupData[{
Cell[5402, 163, 68, 1, 27, Input],
Cell[5473, 166, 37, 1, 26, Output]
}, Open ]],
Cell[5525, 170, 1110, 26, 75, Input]
}
]
*)
(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)
>THere is a MovieParametricPlot in 2-D, but is there a MovieParametricPlot
in
>3D also? Or someother way of making it from existing Mathematica
functions?
Respectfully, Roger L. Bagula
tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel:
619-5610814 :
alternative email: rlbtftn@netscape.net
URL : http://home.earthlink.net/~tftn
===
Subject: Re: MovieParametericPlot-3D
and if you write the Table[] by hand ?
lst = Table[
Block[{$DisplayFunction = Identity},
ParametricPlot3D[{Cos[w*t]*Sin[t], Sin[w*t]*Sin[t], Cos[t]},
{t, 0, Pi}, PlotPoints -> 10*w]
], {w, 10, 200, 25}];
Show[GraphicsArray[Partition[lst, 2]]]
Jens
news schrieb im Newsbeitrag
> THere is a MovieParametricPlot in 2-D, but is there a MovieParametricPlot
> in
> 3D also? Or someother way of making it from existing Mathematica
> functions?
===
Subject: Re: Re: Memory Problems
> If you need more than 3 GByte you need a 64 Bit operating system
> and a 64 bit Mathematica.
How big one expression can be in a 64-bit Mathematica ? I know the
theoretical answer. I would like to know the practical/implementation
one.
J.87nos
> Jens
> Nikolas Kiefer schrieb im Newsbeitrag
>> Is there a way to increase the memory allocation in Mathematica
>> Worksheets.
>> I've got large matrices that keep running out of memory during my
>> arithmatic
>> procedures.
===
Subject: Re: More on Delete Problems
I do not really see why you used packed arrays here.
If your message is intended to suggest that the crash problem is
somehow related to the PackedArrays, your conclusion is premature. To
show this I do:
a = {{1., 2., 3.}, {4., 5., 6.}};
b = {{1, 0, 1}, {0, -2, 3}, {0, 1, 0}};
c = a . b
{{1., -1., 7.}, {4., -4., 19.}}
<< Algebra`AlgebraicInequalities`
Delete[c, {1, 1}]
{{-1., 7.}, {4., -4., 19.}}
Without including the << Algebra`AlgebraicInequalities` line,
Mathematica crashes.
Including the < Packed Arrays strike again!
> Try this:
> In[1]:=
> a = {{1., 2., 3.}, {4., 5., 6.}};
> In[2]:=
> b = {{1, 0, 1}, {0, -2, 3}, {0, 1, 0}};
> In[3]:=
> In[4]:=
> Delete[c, {1, 1}]
> Out[4]=
> {{-1., 7.}, {4., -4., 19.}}
> No crash.
> Andrzej Kozlowski
> Andrzej Kozlowski
> Chiba, Japan
> http://www.akikoz.net/~andrzej/
> http://www.mimuw.edu.pl/~akoz/
> For the record:
> $Version
> a={{1.,2.,3.},{4.,5.,6.}}
> b = {{1,0,1},{0,-2,3}, {0,1,0}}
> c = a . b
> Delete[c,{1,1}]
> crashes Mathematica on my machine, exactly as Give Effinger said.
>> Here's simple code which bombs for me:
>> a={{1.,2.,3.},{4.,5.,6.}}
>> b = {{1,0,1},{0,-2,3}, {0,1,0}}
>> c = a . b
>> Delete[c,{1,1}]
>> Why?
>> G. Effinger
===
Subject: Re: Precisio in ListContourPlot?
Martin,
You can use the ColorFunctionScaling option (under Graphic and
Sound/Advanced Options in Help). You have to supply an appropriate color
function to go with it. Then different plots will have the same colors even
if they are made over different value ranges.
The DrawGraphics package at my web site has a DrawLineLabels routine that
can be used to label contour plots. It allows the format and precision of
the values to be specified. There is an example in the DrawGraphics Help.
David Park
djmp@earthlink.net
http://home.earthlink.net/~djmp/
the comparison of two 'ListContourPlot' shows different colors at the same
contourlines. So the comparison of equal contourlevels are difficult.
Though I defined a generell range for 'Contours' and a generell colorrange
for
'ContourStyle'. Now I get the same colors for the same contourlines - this
is
ok.
But the labels - made by 'LabelContourLines[ListContourPlot[...]]' (see
'Mathematica Graphics', Tom Wickham-Jones) are shown only with one digit
(e.g.
instead of 0.125, 0.25, 0.375, ... I get 0.1, 0.2, 0.3, ...).
Is there any reason to cut the contoursteps (defined with three digits) so
I
get contoursteps with only one digit?!
Is there any possibility to define the 'Precision' in
'ListContourPlot[...]'
or
'LabelContourLines[...]'?
If so please send me a mail (maxao@aol.com).
Martin
===
Subject: Re: Re: Fitting question
>> I have two lists. One of them contains the running total of some
>> quantity per cycles, the other contains the totals per cycles. Here
>> they are:
>> In[35]:= runtotpergen = {1, 23, 136, 568, 1735, 4382, 9099,
>> 16384, 25993, 36694, 47752, 58044, 66761,
>> 73534, 78429, 81753, 83750, 84873, 85482,
>> 85779, 85937, 86025, 86069, 86081, 86087}
>> In[36]:= totpergen = {1, 22, 113, 432, 1167, 2647, 4717, 7285,
>> 9609, 10701, 11058, 10292, 8717, 6773, 4895,
>> 3324,
>> 1997, 1123, 609, 297, 158, 88, 44, 12, 6}
>> I am trying to find out the analytical form of a function which fits
>> best totpergen. [...]
>> totpergen is not symmetrical, [...]
>> I feel that Mathematica has the capability to find the best fitting
>> function without too much manual trials. Any hint how to do that ?
> This fits a shifted gamma density to the first three moments of
> totpergen.
> It handles the asymmetry naturally and fits well.
> In[1]:= n = Last[runtotpergen = {1, 23, 136, 568, 1735, 4382, 9099,
> 16384, 25993, 36694, 47752, 58044, 66761, 73534, 78429, 81753,
> 83750, 84873, 85482, 85779, 85937, 86025, 86069, 86081, 86087}]
> Out[1]= 86087
> In[2]:= m = Length[totpergen = {1, 22, 113, 432, 1167, 2647, 4717,
> 7285,
> 9609, 10701, 11058, 10292, 8717, 6773, 4895, 3324, 1997, 1123,
> 609, 297, 158, 88, 44, 12, 6}]
> Out[2]= 25
> In[3]:= < #@GammaDistribution[a,b]&/@{Mean,Variance,Skewness} //InputForm
> Out[4]//InputForm= {a*b, a*b^2, 2/Sqrt[a]}
> In[5]:= f[a_,b_,c_,x_] := PDF[GammaDistribution[a,b],x-c] /; x >= c
> In[6]:= N@{mean = totpergen.Range[m]/n,
> var = totpergen.(Range[m]-mean)^2/n,
> skew = totpergen.(Range[m]-mean)^3/n * var^(-3/2)}
> {a = 4./skew^2, b = Sqrt[var/a], c = mean - a*b}
> Out[6]= {11.2316, 9.49626, 0.305409}
> Out[7]= {42.8842, 0.470574, -8.94861}
> In[8]:= Plot[n*f[a,b,c,x],{x,1,m}, Epilog->{PointSize[.015],
> Point/@Transpose@{Range@m,totpergen}}];
Wow !! That is amazing !
One must wonder how long exposure to Mathematica allow one to have that
kind of insight demonstrated here. It is time for me to read on some
serious Statistics` :)
My humble trials used to end like this:
FindFit::cvmit: Failed to converge to the requested accuracy or
precision
within 10000000 iterations
Old Hungarian proverb: More with brain than muscle. I do not give
up on hope :)
J.87nos
------------------------------------------------
``Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.'' -- George W. Bush
===
Subject: Re: Re: How to reprensent the result in vector form?
Here's a more general rule:
crossrule4 = Flatten[Outer[
{Sign[#3 #5]a3_ b2_ - Sign[#2 #6]a2_ b3_,
Sign[#1 #6]a1_ b3_ - Sign[#3 #4]a3_ b1_,
Sign[#2 #4]a2_ b1_ - Sign[#1 #5]a1_ b2_} ->
myCross[{#4 b1, #5 b2, #6 b3}, {#1 a1, #2 a2, #3 a3}] &,
Sequence @@ Array[{-1, 0, 1} &, {6}]], 5];
Cross[{0,u2,-u3},{v1,-v2,-v3}]/.crossrule2
Cross[{0,u2,-u3},{v1,-v2,-v3}]/.crossrule4
{-u3 v2-u2 v3,-u3 v1,-u2 v1}
myCross[{0,-u2,u3},{-v1,v2,v3}]
But uniqueness still escapes us:
Cross[{0,0,-u3},{0,-v2,-v3}]/.crossrule4
myCross[{0,-u3 v2,0},{0,-a2,1}]
Bobby
> I fully agree with you that my suggestion was not a general solution. I
had
> in mind the sort of piecemeal replacement(s) you sometimes have to do at
the
> end of a derivation to coax the result into the form you want. I usually
> concoct these on the fly and store them as rules.
> A quick (and very dirty!) fix to the problem of matching to ALL possible
> sign combinations is
> crossrule2=
> Flatten[Table[{Sign[ai3 bi2]a3_ b2_ -Sign[ai2 bi3]a2_ b3_,
> Sign[ai1 bi3]a1_ b3_ -Sign[ai3 bi1]a3_ b1_,
> Sign[ai2 bi1]a2_ b1_ -Sign[ai1 bi2]a1_ b2_}- myCross[{bi1 b1,bi2 b2,bi3 b3},{ai1 a1,ai2 a2,ai3 a3}],{ai1,-1,1,
>
2},{ai2,-1,1,2},{ai3,-1,1,2},{bi1,-1,1,2},{bi2,-1,1,2},{bi3,-1,1,2}],
> 5];
> Now your 3 counterexamples behave thus:
> Cross[{-u1,u2,u3},{v1,v2,v3}]/.crossrule2
> myCross[{u1,-u2,-u3},{-v1,-v2,-v3}]
> Cross[{u1,-u2,u3},{v1,v2,v3}]/.crossrule2
> myCross[{-u1,u2,-u3},{-v1,-v2,-v3}]
> Cross[{u1,u2,-u3},{v1,v2,v3}]/.crossrule2
> myCross[{-u1,-u2,u3},{-v1,-v2,-v3}]
> I agree with your final two remarks about the non-uniqueness of the
> representation. However, I think the original question was to do with
> spotting a particular type of pattern in the algebra, and then rewriting
it
> in a more compact and familiar notation. Because this sort of
> pseudo-inversion is non-unique I tend to make up the replacement rules on
an
> ad hoc basis as I said earlier.
> Steve Luttrell
>> This won't always work, however.
>> crossrule = {a3_ b2_ - a2_ b3_, a1_ b3_ - a3_ b1_,
>> a2_ b1_ - a1_ b2_} -> myCross[{b1, b2, b3}, {a1, a2, a3}];
>> Cross[{u1, u2, u3}, {v1, v2, v3}] /. crossrule
>> myCross[{u1,u2,u3},{v1,v2,v3}]
>> Fine so far, but these should return cross products too:
>> Cross[{-u1,u2,u3},{v1,v2,v3}]/.crossrule
>> {-u3 v2+u2 v3,u3 v1+u1 v3,-u2 v1-u1 v2}
>> Cross[{u1,-u2,u3},{v1,v2,v3}]/.crossrule
>> {-u3 v2-u2 v3,u3 v1-u1 v3,u2 v1+u1 v2}
>> Cross[{u1,u2,-u3},{v1,v2,v3}]/.crossrule
>> {u3 v2+u2 v3,-u3 v1-u1 v3,-u2 v1+u1 v2}
>> Besides this problem there are other issues, such as:
>> (1) EVERY vector is the cross product of two vectors,
>> and
>> (2) The vectors are never unique.
>> Good luck!!
>> Bobby
> You can use a replacement rule to convert your expression into the
> compact
> form that you want:
> Define the replacement rule.
> crossrule = {a3_ b2_ -a2_ b3_,a1_ b3_ -a3_ b1_,a2_ b1_ -a1_ b2_} - myCross[{b1,b2,b3},{a1,a2,a3}];
> Apply the rule to your expression.
> result = {-u3 v2 + u2 v3, u3 v1 - u1 v3, -u2 v1 + u1 v2}/.crossrule
> which gives the output
> myCross[{u1,u2,u3},{v1,v2,v3}]
> You could make the notation more compact by doing this
> result /. {{u1,u2,u3} -> u,{v1,v2,v3} -> v}
> which gives the output
> myCross[u,v]
> Another (related but more sophisticated) method is to use the
> Utilities`Notation` package to implement the reformatting of your
output
> automatically. This includes a way of defining infix operators so that
> you
> can get an output that looks like u x v rather than myCross[u,v]
> Steve Luttrell
>> I used mathmetica5 to solve a vector equation. Mathmetica expands the
>> result into sub-variable form. But I want to get the vector form. How
>> to do that?
>> ex:
>> Solution:
>> {-u3 v2 + u2 v3, u3 v1 - u1 v3, -u2 v1 + u1 v2}
>> I want mathematica give me {u cross v}
>> ShenLei
>> --
>> DrBob@bigfoot.com
>> www.eclecticdreams.net
--
DrBob@bigfoot.com
www.eclecticdreams.net
===
Subject: Re: Re: How to reprensent the result in vector form?
>> However, I think the original question was to do with spotting a
>> particular type of pattern in the algebra, and then rewriting it
>> in a more compact and familiar notation.
If such rules work only for a very limited set of situations, it's arguably
easier to type the new answer (because we've recognized what it should be)
rather than write a rule that retrieves it in the specific case (which
amounts to concocting rules on the fly).
Your new rule seems general enough to be genuinely useful, however.
Bobby
> I fully agree with you that my suggestion was not a general solution. I
had
> in mind the sort of piecemeal replacement(s) you sometimes have to do at
the
> end of a derivation to coax the result into the form you want. I usually
> concoct these on the fly and store them as rules.
> A quick (and very dirty!) fix to the problem of matching to ALL possible
> sign combinations is
> crossrule2=
> Flatten[Table[{Sign[ai3 bi2]a3_ b2_ -Sign[ai2 bi3]a2_ b3_,
> Sign[ai1 bi3]a1_ b3_ -Sign[ai3 bi1]a3_ b1_,
> Sign[ai2 bi1]a2_ b1_ -Sign[ai1 bi2]a1_ b2_}- myCross[{bi1 b1,bi2 b2,bi3 b3},{ai1 a1,ai2 a2,ai3 a3}],{ai1,-1,1,
>
2},{ai2,-1,1,2},{ai3,-1,1,2},{bi1,-1,1,2},{bi2,-1,1,2},{bi3,-1,1,2}],
> 5];
> Now your 3 counterexamples behave thus:
> Cross[{-u1,u2,u3},{v1,v2,v3}]/.crossrule2
> myCross[{u1,-u2,-u3},{-v1,-v2,-v3}]
> Cross[{u1,-u2,u3},{v1,v2,v3}]/.crossrule2
> myCross[{-u1,u2,-u3},{-v1,-v2,-v3}]
> Cross[{u1,u2,-u3},{v1,v2,v3}]/.crossrule2
> myCross[{-u1,-u2,u3},{-v1,-v2,-v3}]
> I agree with your final two remarks about the non-uniqueness of the
> representation. However, I think the original question was to do with
> spotting a particular type of pattern in the algebra, and then rewriting
it
> in a more compact and familiar notation. Because this sort of
> pseudo-inversion is non-unique I tend to make up the replacement rules on
an
> ad hoc basis as I said earlier.
> Steve Luttrell
>> This won't always work, however.
>> crossrule = {a3_ b2_ - a2_ b3_, a1_ b3_ - a3_ b1_,
>> a2_ b1_ - a1_ b2_} -> myCross[{b1, b2, b3}, {a1, a2, a3}];
>> Cross[{u1, u2, u3}, {v1, v2, v3}] /. crossrule
>> myCross[{u1,u2,u3},{v1,v2,v3}]
>> Fine so far, but these should return cross products too:
>> Cross[{-u1,u2,u3},{v1,v2,v3}]/.crossrule
>> {-u3 v2+u2 v3,u3 v1+u1 v3,-u2 v1-u1 v2}
>> Cross[{u1,-u2,u3},{v1,v2,v3}]/.crossrule
>> {-u3 v2-u2 v3,u3 v1-u1 v3,u2 v1+u1 v2}
>> Cross[{u1,u2,-u3},{v1,v2,v3}]/.crossrule
>> {u3 v2+u2 v3,-u3 v1-u1 v3,-u2 v1+u1 v2}
>> Besides this problem there are other issues, such as:
>> (1) EVERY vector is the cross product of two vectors,
>> and
>> (2) The vectors are never unique.
>> Good luck!!
>> Bobby
> You can use a replacement rule to convert your expression into the
> compact
> form that you want:
> Define the replacement rule.
> crossrule = {a3_ b2_ -a2_ b3_,a1_ b3_ -a3_ b1_,a2_ b1_ -a1_ b2_} - myCross[{b1,b2,b3},{a1,a2,a3}];
> Apply the rule to your expression.
> result = {-u3 v2 + u2 v3, u3 v1 - u1 v3, -u2 v1 + u1 v2}/.crossrule
> which gives the output
> myCross[{u1,u2,u3},{v1,v2,v3}]
> You could make the notation more compact by doing this
> result /. {{u1,u2,u3} -> u,{v1,v2,v3} -> v}
> which gives the output
> myCross[u,v]
> Another (related but more sophisticated) method is to use the
> Utilities`Notation` package to implement the reformatting of your
output
> automatically. This includes a way of defining infix operators so that
> you
> can get an output that looks like u x v rather than myCross[u,v]
> Steve Luttrell
>> I used mathmetica5 to solve a vector equation. Mathmetica expands the
>> result into sub-variable form. But I want to get the vector form. How
>> to do that?
>> ex:
>> Solution:
>> {-u3 v2 + u2 v3, u3 v1 - u1 v3, -u2 v1 + u1 v2}
>> I want mathematica give me {u cross v}
>> ShenLei
>> --
>> DrBob@bigfoot.com
>> www.eclecticdreams.net
--
DrBob@bigfoot.com
www.eclecticdreams.net
===
Subject: Converting Mathematica to MS Word
I have written a technical paper in Mathematica and the publisher has
requested
it be sent in MS Word! (yes, I am rolling my eyes as well). Is this
sort of thing even remotely possible?
-Mark
===
Subject: Re: Re: 1) Global Real Space and 2) Histogram Y-axis
unwary. As it happens, I would not use RealOnly myself because complex
number are my friends!
Steve Luttrell
> Hello Steve,
> I suggest not to use RealOnly.
> With the package loaded, there are horrible mistakes with 5.0.
> (Let us call it bugs)
> For example :
> In[3]:=
> << Miscellaneous`RealOnly`
> In[10]:=
> Integrate[1/(x^2 + x + 1), x]
> Out[10]=
> x/(1 + x + x^2)
> Which is wrong, of course !
> So it is better to use
> ComplexExpand and
> Simplify[expr,Element[x,Reals]]
> and so on!
> F.Jaccard
> -----Message d'origine-----
> De : Steve Luttrell [mailto:steve_usenet@_removemefirst_luttrell.org.uk]
> Ë : mathgroup@smc.vnet.net
> Objet : Re: 1) Global Real Space and 2) Histogram Y-axis
> Use the Miscellaneous`RealOnly` package.
> Steve Luttrell
>> I'd like to thank Janos D. Pinter and DrBob for their advice on
>> NMinimize,
>> which I found very helpful.
>> Mathematica is so carefully designed that its accuracy sometimes may be
>> annoying. Namely, it never forgets about complex numbers and sometimes I
>> wish it did. My question is this: is it possible to tell a notebook that
>> it
>> has to deal only with real numbers? It would be nice to have some global
>> setting so that one doesn't have to specify the same assumptions over
and
>> over again.
>> My second question is this: How do I adjust the range of the y-axis of a
>> histogram? PlotRange->{min,max} doesn't seem to work.
>> Skirmantas
===
Subject: Re: Re : Re: 1) Global Real Space and 2) Histogram Y-axis
Florian,
For your example even that is not enough!
You have to use
expr=Integrate[1/(x^2 + x + 1), x];
Simplify[ComplexExpand[expr, TargetFunctions -> {Re, Im}], Element[x,
Reals]]
to get the answer you would like to see:
(2*ArcTan[(1 + 2*x)/Sqrt[3]])/Sqrt[3]
Peter
> Hello Steve,
> I suggest not to use RealOnly.
> With the package loaded, there are horrible mistakes with 5.0.
> (Let us call it bugs)
> For example :
> In[3]:=
> << Miscellaneous`RealOnly`
> In[10]:=
> Integrate[1/(x^2 + x + 1), x]
> Out[10]=
> x/(1 + x + x^2)
> Which is wrong, of course !
> So it is better to use
> ComplexExpand and
> Simplify[expr,Element[x,Reals]]
> and so on!
> F.Jaccard
> -----Message d'origine-----
> DeÊ: Steve Luttrell
[mailto:steve_usenet@_removemefirst_luttrell.org.uk]
> ËÊ: mathgroup@smc.vnet.net
> ObjetÊ: Re: 1) Global Real Space and 2) Histogram Y-axis
> Use the Miscellaneous`RealOnly` package.
> Steve Luttrell
> I'd like to thank Janos D. Pinter and DrBob for their advice on
NMinimize,
> which I found very helpful.
> Mathematica is so carefully designed that its accuracy sometimes may be
> annoying. Namely, it never forgets about complex numbers and sometimes
I
> wish it did. My question is this: is it possible to tell a notebook that
> it
> has to deal only with real numbers? It would be nice to have some
global
> setting so that one doesn't have to specify the same assumptions over
and
> over again.
> My second question is this: How do I adjust the range of the y-axis of
a
> histogram? PlotRange->{min,max} doesn't seem to work.
> Skirmantas
===
Subject: Re: Matrix Problem
> Suppose I have a m*n matrix like this type.
> M={{1, a1, b1, c1}, {2, a2, b2, c2}, {3, a3, b3, c3}, {4, a4, b4, c4}, {5,
a5,
> b5, c5}, {6, a6, b6, c6}, {7, a7, b7, c7}}
> I want to change my matrix in such a way,
> N={{7, a7, b7, c7}, {6, a6, b6, c6}, {5, a5, b5, c5}, {4, a4, b4, c4}, {3,
a3,
> b3, c3}, {2, a2, b2, c2}, {1, a1, b1, c1}}
In[1]:=
m={{1,a1,b1,c1},{2,a2,b2,c2},{3,a3,b3,c3},{4,a4,b4,c4},{5,
a5,b5,c5},{6,a6,b6,c6},{7,a7,b7,c7}};
n={{7,a7,b7,c7},{6,a6,b6,c6},{5,a5,b5,c5},{4,a4,b4,c4},{3,a3,b3,
c3},{2,a2,b2,c2},{1,a1,b1,c1}};
In[3]:=
Reverse[m]
Out[3]=
{{7,a7,b7,c7},{6,a6,b6,c6},{5,a5,b5,c5},{4,a4,b4,c4},{
3,a3,b3,c3},{2,a2,b2,c2},{1,a1,b1,c1}}
In[4]:=
Reverse[m][Equal]n
Out[4]=
True
===
Subject: Re: Matrix Problem
Reference the first level of the list
and load the elements backward:
N=Table[M[[7-n]],{n,0,6}]
It is actually a permutation of the rows of the matrix.
Columns would be harder, ha, ha...
>Suppose I have a m*n matrix like this type.
>M={{1, a1, b1, c1}, {2, a2, b2, c2}, {3, a3, b3, c3}, {4, a4, b4, c4}, {5,
a5,
> b5, c5}, {6, a6, b6, c6}, {7, a7, b7, c7}}
>I want to change my matrix in such a way,
>N={{7, a7, b7, c7}, {6, a6, b6, c6}, {5, a5, b5, c5}, {4, a4, b4, c4}, {3,
a3,
> b3, c3}, {2, a2, b2, c2}, {1, a1, b1, c1}}
>Could anybody tell me how to this.
>nilaakash
--
Respectfully, Roger L. Bagula
tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel:
619-5610814 :
alternative email: rlbtftn@netscape.net
URL : http://home.earthlink.net/~tftn
===
Subject: Re: Matrix Problem
n=Reverse[m]
n=Sort[m, #1[[1]]>#2[[1]]&]
Bob Hanlon
===
> Subject: Matrix Problem
> Suppose I have a m*n matrix like this type.
> M={{1, a1, b1, c1}, {2, a2, b2, c2}, {3, a3, b3, c3}, {4, a4, b4, c4}, {5,
a5,
> b5, c5}, {6, a6, b6, c6}, {7, a7, b7, c7}}
> I want to change my matrix in such a way,
> N={{7, a7, b7, c7}, {6, a6, b6, c6}, {5, a5, b5, c5}, {4, a4, b4, c4}, {3,
a3,
> b3, c3}, {2, a2, b2, c2}, {1, a1, b1, c1}}
> Could anybody tell me how to this.
> nilaakash
===
Subject: Re: Diff. Equations with Changeable Parameters
> I have solved diff. equations in this kind of a way:
> NDSolve[{x'[t]=y[t],y[0]=0}, {y'[t]=x+Sin[t]+c*y[t]},{x,y},{t,0,2Pi}]
> and parameter c was 1, but how to write this algorithm if c is:
> c=0, if y<=-1
> c=1, if -1 c=2, if y>=1
> How to include this variable parameter c in my NDSolve method?
You used single equals = rather than the double equals == that
Mathematica expects when using NDSolve.
The answer to your question is to use UnitStep.
varCsoln = NDSolve[{x'[t] == y[t], y[
0] == 0, y'[t] == x[t] + Sin[t] + (UnitStep[y[t] + 1] +
UnitStep[y[t] - 1])*y[t], x[0] == 0}, {x[t], y[t]}, {t, 0, 2Pi}]
--
Curt Fischer
===
Subject: Re: Diff. Equations with Changeable Parameters
You need an initial condition for x as well.
Then a right hand side function definition is handy:
f[x_, y_] := x + Sin[t] + 1*y; -1 < y && y < 1;
f[x_, y_] := x + Sin[t] + 0*y; y <= -1;
f[x_, y_] := x + Sin[t] + 2*y; 1 <= y;
NDSolve[{x'[t] == y[t], y'[t] == f[x[t], y[t]],
y[0] == 0, x[0] == 0}, {x[t], y[t]}, {t, 0, 2Pi}]
The result will be:
{{x[t] -> InterpolatingFunction[{{0., 6.28319}}, <>][t],
y[t] -> InterpolatingFunction[{{0., 6.28319}}, <>][t]}}
Peter
> I have solved diff. equations in this kind of a way:
> NDSolve[{x'[t]=y[t],y[0]=0}, {y'[t]=x+Sin[t]+c*y[t]},{x,y},{t,0,2Pi}]
> and parameter c was 1, but how to write this algorithm if c is:
> c=0, if y<=-1
> c=1, if -1 c=2, if y>=1
> How to include this variable parameter c in my NDSolve method?
===
Subject: Re: Diff. Equations with Changeable Parameters
a) you do not solve
> NDSolve[{x'[t]=y[t],y[0]=0}, {y'[t]=x+Sin[t]+c*y[t]},{x,y},{t,0,2Pi}]
because it is full of errors, for equations you have to use Equal[] == and
not Set[] =,
there is no initial condition for x[0] and in the last differential equation
a x[t] is missed.
b) in your question c is simply a function of y and you should define a
function c[y] with
c[y_?NumericQ] /; y < -1 := 0.0
c[y_?NumericQ] /; -1 <= y <= 1 := 1.
c[y_?NumericQ] := 2.0
and type the correct version of the NDSolve[] command
NDSolve[{x'[t] == y[t], y[0] == 0, x[0] == 0,
y'[t] == x[t] + Sin[t] + c[y[t]]*y[t]}, {x, y}, {t, 0, 2Pi}]
Jens
Krunom Ilicevic schrieb im Newsbeitrag
>I have solved diff. equations in this kind of a way:
> and parameter c was 1, but how to write this algorithm if c is:
> c=0, if y<=-1
> c=1, if -1 c=2, if y>=1
> How to include this variable parameter c in my NDSolve method?
===
Subject: Re: Diff. Equations with Changeable Parameters
> I have solved diff. equations in this kind of a way:
> NDSolve[{x'[t]=y[t],y[0]=0}, {y'[t]=x+Sin[t]+c*y[t]},{x,y},{t,0,2Pi}]
No, you haven't; not in Mathematica. This works, however:
NDSolve[{x'[t] == y[t], y[0] == 0, x[0] == 1, y'[t] == x[t] + Sin[t] +
c*y[t]} /. c -> 1, {x, y}, {t, 0, 2Pi}]
or
DSolve[{x'[t] == y[t], y[0] == 0, x[0] == 0, y'[t] == x[t] + Sin[
t] + c*y[t]} /. c -> 1, {x, y}, t]
(Both x and y need boundary conditions.)
or, for your step function example:
c[t_] = UnitStep[t - 1] + UnitStep[t + 1];
Plot[c@t, {t, -2, 2}, PlotRange -> All];
NDSolve[{x'[t] == y[t], y[0] == 0, x[0] == 1,
y'[t] == x[t] + Sin[t] + c[t]*y[t]}, {x, y}, {t, 0, 2Pi}]
Bobby
> I have solved diff. equations in this kind of a way:
> NDSolve[{x'[t]=y[t],y[0]=0}, {y'[t]=x+Sin[t]+c*y[t]},{x,y},{t,0,2Pi}]
> and parameter c was 1, but how to write this algorithm if c is:
> c=0, if y<=-1
> c=1, if -1 c=2, if y>=1
> How to include this variable parameter c in my NDSolve method?
--
DrBob@bigfoot.com
www.eclecticdreams.net
===
Subject: malliavin calculus
hi,
someone knows packages in Mathematica that implement the Malliavin Calculus
for finance applications. foremost i am interested in malliavin calculus for
greeks computation .
paolo
____________________________________________________________
Libero ADSL: navighi gratis a 1.2 Mega, senza canone e costi di attivazione.
Abbonati subito su http://www.libero.it
===
Subject: Re: Inverse of PowerExpand
> Klaus,> One method...
> Log[a] + 2*Log[b] - Log[c];
> % //. (a_.)*Log[b_] + (c_.)*Log[d_] -> Log[b^a*d^c]
> Log[(a*b^2)/c]
OK. But you assume that you know how to add logarithms..
> Concerning your previous posting, an expression like...
> !(Log[(a b^2)/c])
> can be copied and pasted into a Mathematica notebook even though it is
not
> easy to read in a posting. An Input/Output cell can be converted to
> InputForm before copying into a posting or the Copy As Input Form palette
> can be downloaded from..
Of course you are right. I'm quite new at version 5, so I have to get
used to the different types of formatting.
Klaus G.
===
Subject: Re: full QR decomposition
> i have the following problem. For a given a NxM (e.g. 3000x600) matrix A
i
> get a matrix Q (MxN) and R (MxM) after the QRDecomposition. But i would
> like to get the full decomposition with a matrix QF (NxN) and RF (NxM)
where
> RF contains only zero lines below the line with index M. I'm especially
> interrested in the last N-M lines in QF which create the zero lines in
RF.
> At the moment i use QRDecomposition and append then N-M random lines to
the
> matrix Q. With this new matrix i go into the routine GramSchmidt and
extract
> the last N-M lines from the result. But this is very slow and i'm not sure
if
> it will always work? Are there any suggestions or hints?
In[1]:= a = Table[Random[],{30},{6}];
q = First@QRDecomposition@a;
qf = Join[q,First@QRDecomposition@Transpose@NullSpace@q];
Max@Abs[qf.Transpose@qf-IdentityMatrix@30] // InputForm
Out[4]//InputForm= 8.881784197001252*^-16
===
Subject: Re: full QR decomposition
> i have the following problem. For a given a NxM (e.g. 3000x600) matrix
> A i
> get a matrix Q (MxN) and R (MxM) after the QRDecomposition. But i would
> like to get the full decomposition with a matrix QF (NxN) and RF (NxM)
> where RF
> contains only zero lines below the line with index M. I'm especially
> interrested in the last N-M lines in QF which create the zero lines in
> RF.
> At the moment i use QRDecomposition and append then N-M random lines to
> the matrix Q. With this new matrix i go into the routine GramSchmidt
> and extract the last N-M
> lines from the result. But this is very slow and i'm not sure if it
> will
> always work?
This will not always work because there is a very small probability
that the space spanned by the entries you've added overlaps the space
spanned by Q.
> Are there any suggestions or hints?
What you are after is the basis of the null space of your original
matrix. If you use NullSpace then the resulting vectors span the same
space as the missing rows of Q.
Ssezi
===
Subject: Re: full QR decomposition
> i have the following problem. For a given a NxM (e.g. 3000x600) matrix A
i
> get a matrix Q (MxN) and R (MxM) after the QRDecomposition. But i would
> like to get the full decomposition with a matrix QF (NxN) and RF (NxM)
where RF
> contains only zero lines below the line with index M. I'm especially
> interrested in the last N-M lines in QF which create the zero lines in
RF.
> At the moment i use QRDecomposition and append then N-M random lines to
> the matrix Q. With this new matrix i go into the routine GramSchmidt and
extract the last N-M
> lines from the result. But this is very slow and i'm not sure if it will
> always work? Are there any suggestions or hints?
> jan schmedes
I'll discuss this with respect to real valued matrices so as to avoid
requiring Conjugate in various places. The important defining relation
between a given real matrix mat and the decomposition into q and r is
decomposition it is not hard to see that extra rows in q are simply any
orthonormal set for the null space of q. To make the null space
orthogonal we simply use another invocation of QRDecomposition and
extract the Q part.
This may be obtained as in the example below.
SeedRandom[1111];
randomMatrix[n_,m_] := Table[Random[], {n}, {m}]
rows = 7;
cols = 3;
mat = randomMatrix[rows, cols];
{q,r} = QRDecomposition[mat];
First we check the QR decomposition.
In[64]:= Transpose[q] . r == mat
Out[64]= True
In[65]:= Chop[q . Transpose[q]] == IdentityMatrix[Length[q]]
Out[65]= True
Now we form the full decomposition.
qextra = NullSpace[q];
{q2,r2} = QRDecomposition[Transpose[qextra]];
qf = Join[q,q2];
rf = Join[r, Table[0, {rows-Length[r]}, {cols}]];
Now check the full decomposition:
In[66]:= Transpose[qf] . rf == mat
Out[66]= True
In[67]:= Chop[qf . Transpose[qf]] == IdentityMatrix[Length[qf]]
Out[67]= True
In[68]:= Dimensions[qf] == {rows,rows}
Out[68]= True
Daniel Lichtblau
Wolfram Research
===
Subject: Graphics question
I have 3 Plots over the same x-axis range: p1, p2, p3
Each plot is of a well-behaved monotonically decreasing function.
The result of Show[p1,p2,p3] is three curves which do not intersect,
with the exception except that the lower two curves intersect at x=0.
I would like to fill in the region between the
two lower curves with a Gray background.
How can I accomplish this?
alan
===
Subject: Re: Bug in Graphics Text under Linux
Bill,
I believe that OS10 uses X11 (XFreeBSD or somesuch).
Kevin
>>This problem has been presented before, but I have not used
>>Mathematica under Linux in a while. Under 5.0 (and earlier
>>versions) I find that graphic text that runs other than horizontal
>>is not properly rendered. For example, if I plot something like
>>this
>>Text[StyleForm[Scattered Wave, FontSize -> 12], {5.5, 3.2}, {0,
>>0}, {1, 0.55}]
>>I get Scattered Wave running off at about 30deg, but each letter
>>is horizontal. This problem produces an even more absurd result for
>>y-axis labels for which the label runs vertically but the letters
>>are horizontal.
>>The last time I tuned in on this, Wolfram support said it was a
>>problem with X11. Perhaps, but it is still a BUG in the Linux
>>product that makes Mathematica on Linux unusable in the classroom.
>>Does anyone know of a workaround?
> The problem you describe above is not just a problem with X11 and Linux.
It also occurs with Mathematica running on Mac OS 10.3.
> I have seen various workarounds, none entirely satisfatory. One approach
is to use Hershey fonts. There is a package on Wolfram's web site which
allows usage of Herhey fonts in Mathematica. This approach is nice in that
everything is handled within Mathematica. But placing and sizing the text the
way you want is somewhat time consuming. Also, the choice of fonts is more
limited. But reasonable appearing plots can be generated with this approach.
> The other workaround I've used for reports is to generated the plots
without problematical text, convert the Mathematica notebook to a PDF file
and use a third party application to edit the resulting PDF file manually
adding the text in the way I want. The end result usually looks better than
what I get with Hershey fonts, but I really prefer something that can be
handled within Mathematica.
> Another possible workaround might be to use Publicon. Does anyone know if
this issue exists within Publicon?
> --
>
===
Subject: Re: Bug in Graphics Text under Linux
Jens,
That is not really a satisfactory way to deal with this bug for the near
term. In passing I note that another system under Linux does not have this
problem. My real point is that although X11 has this deficiency, in the
end it is Mathematica that behaves poorly, i.e. it is a bug in
Mathematica or at least a mistake that the developers made in their
choice of X11 or whatever. I did not pay money to be told that Mathematica
is
fine, it is X11's fault. Rather, I bought Mathematica to do a job and it
doesn't.
Kevin
> your X11 can not rotate trxt by an arbitary degree, because X11 does a
> rastered
> bitmap reperesetation of the letters in the font and it can not rotate the
> bitmap.
> You can export the PostScript version of the graphics, let GhostScript
> render a
> bitmap version and import this bitmap.
> and you can (and this seems to be the best solution) join the X11
developer
> group
> and enhance X11 to render outline fonts.
> Jens
> Kevin schrieb im Newsbeitrag
>>This problem has been presented before, but I have not used Mathematica
>>under
>>Linux in a while. Under 5.0 (and earlier versions) I find that graphic
>>text that runs other than horizontal is not properly rendered. For
>>example, if I plot something like this
>>Text[StyleForm[Scattered Wave, FontSize -> 12], {5.5, 3.2}, {0, 0},
>>{1, 0.55}]
>>I get Scattered Wave running off at about 30deg, but each letter is
>>horizontal. This problem produces an even more absurd result for y-axis
>>labels for which the label runs vertically but the letters are
horizontal.
>>The last time I tuned in on this, Wolfram support said it was a problem
>>with X11. Perhaps, but it is still a BUG in the Linux product that makes
>>Mathematica on Linux unusable in the classroom.
>>Does anyone know of a workaround?
>>Kevin
===
Subject: Re: Regression with missing values
Actually, I didn't want to delete those entries. To be a little bit
more explicit about my data, I have circa 5 independent variables
which place the 6th dependent variable (the analysis result) into a
category. Unfortunately, sometimes there exist data for which 1 of
the 5 independent variables cannot be determined, and thus the data
really can't be placed into a category. It's at this point that I was
hoping it would be possible to still make use of the 6th data variable
(which depends on the first 5 vars) by somehow estimating the
category to which it should belong to.
I know that certain statistical packages deal with such circumstances
without simply deleting the data, but can Mathematica?
Nik
>Can Mathematica handle regression where the dependent variables
>sometimes have missing values? If so, how are these missing values
>to be represented in the data?
> How do you want the missing values treated? Simply ignored? If so, code
the missing values in any manner you find suitable to easily distinguish them
from valid values and use DeleteCases to delete them from the data matrix
given to the regression routine you want to use.
> For example, I have a data file with optical power measurements made in
dBm. Valid measurements are negative numbers. So, I used 9999 to replace the
missing values. Then I use DeleteCases[data,{_,9999}] to strip these values
from the data matrix.