mm-530
====
Subject: Keeping the Legendre polynomials in expressions without finding the
explicit polinomials
Infortunately I had simplified my task very much, so that I could not
apply any answer directly to my case.
Can somebody help me with the following. I need present some functions
(prolate spheroidal functions) in the basis of the Legendre
polynomials. I.e. I have functions like
FF1 = 0.6 LegendreP[5, #1] + 0.7 LegendreP[6, #1] &
FF2 = 0.3 LegendreP[5, #1] + 0.2 LegendreP[6, #1] &
I want to manipulate these functions and remain in the basis of prolate
functions. For example I want to create a linear combination of
functions, or something like this.
FF = .2FF1[#1] + .3FF2[#1] &
It works well from the point of view of finding the numerical result,
but it do not give the presentaion of the function in the basis of the
Legendre polynomials.
I would like to have create a function which would give the result like
FFX = 0.9 LegendreP[5, #1] + 0.9 LegendreP[6, #1] &,
so that I could see the presentaion of the function by typing FFX and
obtaining 0.9 LegendreP[5, #1] + 0.9 LegendreP[6, #1] &. In practice
these functions contain much more terms and having the form like 0.9
LegendreP[5, #1] + 0.9 LegendreP[6, #1] & is very important. At the
same time I would not like to have the explicit presentation as
plolinomials, like -0.28125+1.6875 w + 5.90625 w^2 + .. because of
loss of accuracy for future results.
Vlad
====
Subject: Re: Keeping the Legendre polynomials in expressions without finding
the explicit polinomials
insert a new symbol say LPolynom[n,x] and if you
need the
explicit form say LPolynom -> LengendreP
poly = LPolynom[5, x] + LPolynom[6, x]/4
poly /. LPolynom -> LegendreP
Jens
Vladislav schrieb im
of usefull things, but
> Infortunately I had simplified my task very
> much, so that I could not
> apply any answer directly to my case.
Can somebody help me with the following. I need
> present some functions
> (prolate spheroidal functions) in the basis of
> the Legendre
> polynomials. I.e. I have functions like
FF1 = 0.6 LegendreP[5, #1] + 0.7 LegendreP[6,
> #1] &
> FF2 = 0.3 LegendreP[5, #1] + 0.2 LegendreP[6,
> #1] &
I want to manipulate these functions and remain
> in the basis of prolate
> functions. For example I want to create a
> linear combination of
> functions, or something like this.
FF = .2FF1[#1] + .3FF2[#1] &
It works well from the point of view of finding
> the numerical result,
> but it do not give the presentaion of the
> function in the basis of the
> Legendre polynomials.
I would like to have create a function which
> would give the result like
FFX = 0.9 LegendreP[5, #1] + 0.9 LegendreP[6,
> #1] &,
> so that I could see the presentaion of the
> function by typing FFX and
> obtaining 0.9 LegendreP[5, #1] + 0.9
> LegendreP[6, #1] &. In practice
> these functions contain much more terms and
> having the form like 0.9
> LegendreP[5, #1] + 0.9 LegendreP[6, #1] & is
> very important. At the
> same time I would not like to have the explicit
> presentation as
> plolinomials, like -0.28125+1.6875 w + 5.90625
> w^2 + .. because of
> loss of accuracy for future results.
> Vlad
>
====
Subject: Re: (suggestion to Wolfram)
I second this idea. It may actually already be implemented though
(similar to the way -Graphics- represents the head Graphics wrapped
around directives/primitives). Anyone know?
> Export[---] (without a following semicolon) prints the filename of the
> exported file to an output cell in the notebook.
Sure would be nice if options could be added to have this output cell
> contain a bunch of additional information such as
--Full path for the output file
> --File size
> --Name of object exported, as well as file name
> --Format used
plus all kinds of potentially useful format-specific and object-specific
> data such as graphic dimensions for an EPS file; pixel dimensions for
> JPEG and the like; fonts used and/or embedded; number of characters
> and/or lines for a text file; and so on. (Presumably much of this
> information can be decoded from within the output file itself, but we
> amateurs may not find that so easy to do.)
Any simple command that will extract all this information from the
> kernal or front end immediately following execution of an Export[---]
> command?
Also, to have an output cell with the filename be printed even when the
> Export[---]; command is executed within a longer sequence of expressions
> separated by semicolons, the following seems to work:
Print[Export[---]];
Anything illegal or immoral about doing this?
--
Chris Chiasson
http://chrischiasson.com/
1 (810) 265-3161
====
Subject: Re: (suggestion to Wolfram)
> Export[---] (without a following semicolon) prints the
> filename of the exported file to an output cell in the notebook.
> Sure would be nice if options could be added to have this
> output cell contain a bunch of additional information such as
--Full path for the output file
> --File size
> --Name of object exported, as well as file name
> --Format used
plus all kinds of potentially useful format-specific and
> object-specific data such as graphic dimensions for an EPS
> file; pixel dimensions for JPEG and the like; fonts used
> and/or embedded; number of characters and/or lines for a text
> file; and so on. (Presumably much of this information can be
> decoded from within the output file itself, but we amateurs
> may not find that so easy to do.)
Any simple command that will extract all this information
> from the kernal or front end immediately following execution
> of an Export[---] command?
There is FileInformation[].
I'd suggest that this be used instead of Export[]. The reason for this is
that Mathematica has the convention that a trailing semicolon supresses
output. Perhaps adding an argument (eg VerboseOutput->True) to Export
might
be a better way to go.
Just my (Australian) two cents worth ...
Dave.
====
Subject: Re: sorting complex number?
there is no ordering relation in the complex plane.
You can order the real parts or what ever.
Jens
Sean2 schrieb im Newsbeitrag
>
====
Subject: Re: Using InterpolatingFunction in Argument of NIntegrate
Hi Iggy,
what you describe should work. I guess you have a syntactical error.
E.g. you have to write g[f[x]]] instead of: g(f(x)
If this does not help, you have to be more specific.
sincerely, Daniel
I am solving numberically an ODE and outputing the results into a function
> f(x). This f(x) is some InterpolatingFunction.
I would like to then use f(x) in a call to NIntegrate in a way such as:
NIntegrate[g(f(x),{x,0,1}]
However I get an integrand not numerical error. I can easily Plot g(f(x))
> and if I replace f(x) with some function like x^2 everything works too.
How can I get around this?
> Iggy
>
====
Subject: Re: Using InterpolatingFunction in Argument of NIntegrate
f[t_?NumericQ] =
x[t] /. NDSolve[
{x''[t] + x[t] == 0, x[0] == 0, x'[0]
== 1},
x[t], {t, 0, 2Pi}][[1]]
Plot[f[t], {t, 0, 2Pi}]
NIntegrate[f[t], {t, 0, Pi}]
??
Jens
Iggy schrieb im Newsbeitrag
I am solving numberically an ODE and outputing
> the results into a function
> f(x). This f(x) is some InterpolatingFunction.
I would like to then use f(x) in a call to
> NIntegrate in a way such as:
NIntegrate[g(f(x),{x,0,1}]
However I get an integrand not numerical error.
> I can easily Plot g(f(x))
> and if I replace f(x) with some function like
> x^2 everything works too.
How can I get around this?
> Iggy
>
====
Subject: Re: goto and label (cont)
Guy,
Here is an example using Label. Note that if you put in line returns, a ()
pair is necessary to make a compound statement.
(Label[begin];
f[1] = Random[Integer, {1, 10}]; If[f[1] > 5, Goto[begin]];
f[2] = Random[Integer, {1, f[1] + 5}];
If[f[2] <= 5, Goto[begin]];
{f[1], f[2]})
The following is the same thing done with a While statement.
While[(f[1] = Random[Integer, {1, 10}]; f[1] > 5) ||
(f[2] = Random[Integer, {1, f[1] + 5}];
f[2] <= 5), Continue[]]
{f[1], f[2]}
David Park
djmp@earthlink.net
http://home.earthlink.net/~djmp/
Hi again,
since everyone tells me not to use goto and label (although for the use
i'll
describe below it is very comfterable and the simplest way to do it. If
anyone can suggests an alternative/mathematica way of doing it, please do.
the pseudocode with goto
label[l]
do something1
if condition1==true goto[l]
do something2
if condition2==true goto[l]
do some other stuff
as you see i do something1 then check some cond. if something didn't go
well
i start doing everything from the start. same for something2. I want to go
all the way to the top. using a while or something alike would need some
variable to hold it and maintaine which is messy. or if a do while loop
exists (?) it will need to do everything and then restart. I want some
mechanism that will restart itself if conditions are not met. goto seems
the
only simple option to do it.
again, suggestions are always welcomed
Guy
====
Subject: Re: Solve with assumptions
Hi Muktar,
try e.g. Reduce. Here is a small example.
Reduce[{x^3 + 1 == 0}, x] gives
x == -1 || x == (-1)^(1/3) || x == -(-1)^(2/3)
on real and two complex solutions.
However:
Reduce[{Element[x, Reals], x^3 + 1 == 0}, x]
gives
x == -1
or another example: Reduce[{x < 0, x^2 - 1 == 0}, x]
sincerely, Daniel
> I need to solve equation f[x1,x2] for x1 and x2, where I know that x1>0
> and x2>0 and are both real. Solve[f[x1,x2]==0,{x1,x2}] takes a lot of
> time to solve and when it does solve it gives me tons of unreal
> solutions or repetitive solutions (I have enabled Miscellanous RealOnly
> and instead of complex solutions it just gives me Unreal). I would
> like to know how I (1) can restrict the solution set where Mathematica
> is trying to find a solution, and (2) show only unique solutions and
> totally not showing Unreal ones. FindRoot is great but it is very
> Bekkali
>
====
Subject: Re: Centering of graphics
I am just writing a technical text with a lot of imported and
> Mathematica
> generated pictures/graphics. I wonder how to center them
> automatically. Or
> is there no solution for this simple problem? The contribution in
> the
> MathGroup Archive 1999 centering a figure from P.J. Hinton did
> not work:
> the picture keeps more at the left side than in the center of the
> page. I
> use Mathematica 5.1.
Any suggestions?
> Markus
>
Hi Markus,
My Glue palette has a button for aligning the centers of selected
graphics. This will let you center your top-most graphic manually and
then align the centers of all others with it. Here's the link to it
at MathSource:
http://library.wolfram.com/infocenter/MathSource/4396/
----------------
Selwyn Hollis
http://www.appliedsymbols.com
====
Subject: Re: Finding Position in an ordered list
0. Now I disclose that I am looking for a word in a dictionary.
> 2. The idea of interpolation in the case of numbers is fantastic.
> 3. However, I tried BinarySearch[{a,b,c},b] without being evaluated.
Thus, I need further help.
Janos,
Apparently the Combinatorica package BinarySearch function only accepts
numeric keys. We can modify this function to work with any key as follows:
binarysearch[d_, k_, ordf_:Less] :=
Module[{lo = 1, mid, hi = Length[d], c},
While[lo <= hi,
If[ordf[k, c], hi = mid - 1, lo = mid + 1]];
Return[lo - 1/2]
]
Then, for your example, we would use the ordering function OrderedQ[{##}]&:
binarysearch[{a, b, c}, b, OrderedQ[{##}] &]
2
Carl Woll
====
Subject: Re: Finding Position in an ordered list
> 0. Now I disclose that I am looking for a word in a dictionary.
> 2. The idea of interpolation in the case of numbers is fantastic.
> 3. However, I tried BinarySearch[{a,b,c},b] without being evaluated.
Thus, I need further help.
> Janos
BinarySearch in the Combinatorica package is written so that it
accepts only numeric input. It is very easy to change this:
BinarySearch[list_, elem_] := Module[{
n0 = 1, n1 = Length[list], m}, While[n0 Ó n1, m =
Floor[(n0 +
n1)/2];
If[list[[m]] == elem,
Return[m]]; If[OrderedQ[{list[[m]], elem}], n0 = m + 1, n1 = m -
1] ];
0 ]
BinarySearch[{a,b,c,},b]
2
BinarySearch[{a,b,c,},e]
0
0 means not found.
Andrzej Kozlowski
Chiba, Japan
====
Subject: Re: Point Sampling in Digital Image Processing?
describe. However, this is easily accomplished - here is an example.
(* this reads the image *)
{r, g, b} = ToChannels[ImageRead[ some file ...] ]
(* construct an InterpolatingFunction object, default value for n is 3 *)
interRed = ListInterpolation[ RawImageData[r], InterpolationOrder -> n ]
(* sample *)
interRed[ Random[Real,{1,256}], Random[Real,{1,256}] ]
That is all, good luck,
Mariusz
Hi -- I was wondering if the Digital Image Processing package has a
built-in function for point sampling an image at arbitrary coordinates
(e.g., non-integer coords), doing some sort of interpolation between
pixels. I haven't found anything appropriate in the help.
-Greg Humphreys
====
Subject: Remove definitions from I
Hallo,
I want to use the symbol I as symbol for electrical current without any
definitions. Instead I want to use Esc jj Esc for the imaginary unit like
it is done in elecrtical engineering.
How can I free the I from any definitions. It is locked!
Oliver Friedrich
====
Subject: Re: Remove definitions from I
don't do that, I has the attribute locked.
Use [ScriptCapitalI] for the current.
Jens
Oliver Friedrich
schrieb im Newsbeitrag
> Hallo,
I want to use the symbol I as symbol for
> electrical current without any
> definitions. Instead I want to use Esc jj Esc
> for the imaginary unit like
> it is done in elecrtical engineering.
How can I free the I from any definitions. It is
> locked!
> Oliver Friedrich
>
====
Subject: Solving a recursive system of 3x3 linear systems...
Hi everybody,
I'm looking at a recursive system where at each l-th step the three
variables a[i,l] (1 <= i <= 3) have to be solved from a system of three
linear equations involving the previously solved a[i,l+1], ....,
a[i,k] (1 <= i <= 3) (so the iterator l runs back, starting from some
value k). My goal is to find a closed form direct formula for the
a[i,l], that is a formula that expresses each a[i,l] in terms of the
starting values a[i,k]'s and the the other known constants involved.
More precisely, the code for finding the first few steps of this
recursive system looks like this:
(detail without meaning: in the above code the system starts from k+1
instead of k). All the B[.,.]'s, beta[.,.]'s and d[.]'s are in principle
known constants, as are the starting values a[i,k] for each 1 <= i <= 3.
Now, if I try to let Mathemetica just run through the system using the
code above, it chokes already at the third step and the expressions of
the second step are already pretty terrible (a lot of lines...). Is
there any chance of using Mathematica some way to find (which is
probably even a lot more difficult than just running through the
system...) those direct formulas for the a[i,l]'s (so, only dependent on
the a[i,k]'s, B[.,.]'s, beta[.,.]'s and d[.]'s)??
Kees
====
Subject: Re: Simplify expression
>I need to solve system of equations f1[x1,x2]=0,f2[x1,x2]==0,
>however, some elements of these equation have the form
>Sqrt[(x1^2-x2^2)^2]. It takes really long time to solve. If,
>however, I manually simplify those elements, for example,
>Sqrt[(x1^2-x2^2)^2]=x1^2-x2^2 then solve is fast. Therefore, the
>question is how I can force mathematica simplify expressions of
>this sort (another elements are fractions that depend on x1 and x2
>in Mathematica's mind but in reality they cancel out and fraction
>becomes a number). I do not want to use FindRoot since I want to
I think PowerExpand is what you are looking for, i.e.
PowerExpand[Sqrt[(x1^2-x2^2)^2]] yields
x1^2 - x2^2
Solve doesn't use PowerExpand as one of the transforms to try since it will
not yield valid results for all possible conditions.
--
To reply via email subtract one hundred and four
====
Subject: Re: Mathematica TeX save in standard LaTeX style
Frank,
I think you misunderstand my point. I'm not saying put TraditionalForm
in the TeX file. I'm saying use TraditionalForm in the notebook.
Or in other words, put into Mathematica what you want to see in the
final document (ps, pdf, or whatever you're creating from the TeX
file).
So sin(x) in a Mathematica notebook translates to $sin(x)$ in the
TeX file. This is rendered as sin(x) in the final document.
And Sin[x] -> $text{Sin}[x]$.
And sin x -> $sin x$.
This is sometimes referred to as WYSIWYG (what you see is what you
get). Though there are many ways in which Mathematica and TeX greatly
differ. So I wouldn't go that far. But the general idea holds. When
deciding what to put in the notebook, don't think about what TeX you
want to produce. Think about the final document you want to produce.
-Dale
> TeX Export is designed to create a TeX document that looks like your
>> Mathematica notebook (or as close as possible given the many
>> differences between TeX and notebooks).
By default, Mathematica uses StandardForm (e.g. Sin[x]). What you want
>> is called TraditionalForm (e.g. sin(x)).
I don't know what Rex wants, but I wouldn't want the Traditional form,
> either. I'd want $sin x$ (with the $$ around the whole math
> expression, or course). But then how should Mathematica know that I'm
> also happy with $sin ax$, while I don't want $sin phi_0+omega t$,
> but rather $sin (phi_0+omega t)$?
--
> Frank K.9fster
> Inst. f. Biochemie der Univ. Z.9frich
> Debian Developer
>
====
Subject: Re: Mathematica TeX save in standard LaTeX style
> TeX Export is designed to create a TeX document that looks like your
> Mathematica notebook (or as close as possible given the many
> differences between TeX and notebooks).
By default, Mathematica uses StandardForm (e.g. Sin[x]). What you want
> is called TraditionalForm (e.g. sin(x)).
I don't know what Rex wants, but I wouldn't want the Traditional form,
either. I'd want $sin x$ (with the $$ around the whole math
expression, or course). But then how should Mathematica know that I'm
also happy with $sin ax$, while I don't want $sin phi_0+omega t$,
but rather $sin (phi_0+omega t)$?
--
Frank K.9fster
Inst. f. Biochemie der Univ. Z.9frich
Debian Developer
====
Subject: Sorting on multiple columns within a matrix
I can't come up with a solution to the following simple task:
- I have a matrix, let's M={ {Z,2,a},{A,2,k},
{Z,1,z},
{A,1,a},{Z,3,k}, {A,3,z} }
- I want to be able to sort the matrix row-wise, based on multiple
columns, for example sort first on column 2 (ascending) and then
secondly on column1 (ascending)
desired result:
A 1 a
Z 1 z
A 2 k
Z 2 a
A 3 z
Z 3 k
I suspect the solution involves using a pure function of some form as
the second argument in the Sort function, but I can't figure out what
this function should be.
Lee
====
Subject: Re: Sorting on multiple columns within a matrix
Hello Lee,
You need Ordered like in this example:
OrderedQ[{#1[[2]], #2[[2]]}]] &]
sincerely, Daniel
I can't come up with a solution to the following simple task:
- I have a matrix, let's M={ {Z,2,a},{A,2,k},
{Z,1,z},
> {A,1,a},{Z,3,k}, {A,3,z} }
> - I want to be able to sort the matrix row-wise, based on multiple
> columns, for example sort first on column 2 (ascending) and then
> secondly on column1 (ascending)
desired result:
> A 1 a
> Z 1 z
> A 2 k
> Z 2 a
> A 3 z
> Z 3 k
I suspect the solution involves using a pure function of some form as
> the second argument in the Sort function, but I can't figure out what
> this function should be.
Lee
>
====
Subject: Re: Sorting on multiple columns within a matrix
Sort[M, If[#1[[2]] =!= #2[[2]], #1[[2]] < #2[[2]],
#1[[1]] < #2[[1]]] &]
??
Jens
Lee Newman schrieb im
I can't come up with a solution to the following
> simple task:
- I have a matrix, let's M={
> {Z,2,a},{A,2,k}, {Z,1,z},
> {A,1,a},{Z,3,k}, {A,3,z} }
> - I want to be able to sort the matrix
> row-wise, based on multiple
> columns, for example sort first on column 2
> (ascending) and then
> secondly on column1 (ascending)
desired result:
> A 1 a
> Z 1 z
> A 2 k
> Z 2 a
> A 3 z
> Z 3 k
I suspect the solution involves using a pure
> function of some form as
> the second argument in the Sort function, but I
> can't figure out what
> this function should be.
Lee
>
====
Subject: a question about subscript
I want to take the advantage of the subscript in Mathematica 5.1.
I defined a function like the following:
v[t_]=t+t1
====
Subject: Re: a question about subscript
Subscript[] is a function like any other, this
mean that
that in a pattern
v[t_]:=t+Subscript[t,1]
the argument of v[] will replace all t in
t+Subscript[t,1]
If you need a variable that behave like a symbol,
use Symbolize[]
from the Notation package.
Jens
Zhou Jiang schrieb im
> I want to take the advantage of the subscript in
> Mathematica 5.1.
> I defined a function like the following:
v[t_]=t+t1
Since this is a plane text, I cannot type in the
> subscript t1 (i.e., t sub 1) for you. This is so
> simple which represents a time translocation of
> t1. I want Mathematica to compute v[0] and it is
> supposed to give t1 (ie. t sub 1). I typed in
> v[0] but Mathematica gives me 01 (i.e., 0 sub
> 1). Obviously it is not the correct answer. Can
> anyone give me some insight of this delima?
>
====
Subject: Re: goto and label (cont)
How about something like:
i= 0;
Do[
i= i+1;
Print[something 1 = , i];
If[i <=3, Continue[] ];
i= i+10;
Print[something 2 = , i];
If[i < 30, Continue[] ],
{7}
]
Print[something else];
something 1 = 1
something 1 = 2
something 1 = 3
something 1 = 4
something 2 = 14
something 1 = 15
something 2 = 25
something 1 = 26
something 2 = 36
something 1 = 37
something 2 = 47
something else
Stefan Linnik
~~~~~~~~
> Hi again,
since everyone tells me not to use goto and label (although for the use
> i'll
> describe below it is very comfterable and the simplest way to do it. If
> anyone can suggests an alternative/mathematica way of doing it, please
do.
the pseudocode with goto
label[l]
> do something1
> if condition1==true goto[l]
> do something2
> if condition2==true goto[l]
> do some other stuff
as you see i do something1 then check some cond. if something didn't go
> well
> i start doing everything from the start. same for something2. I want to
go
> all the way to the top. using a while or something alike would need some
> variable to hold it and maintaine which is messy. or if a do while loop
> exists (?) it will need to do everything and then restart. I want some
> mechanism that will restart itself if conditions are not met. goto seems
> the
> only simple option to do it.
again, suggestions are always welcomed
> Guy
====
Subject: Re: goto and label (cont)
> Hi again,
since everyone tells me not to use goto and label (although for the use
i'll
> describe below it is very comfterable and the simplest way to do it. If
> anyone can suggests an alternative/mathematica way of doing it, please
do.
the pseudocode with goto
label[l]
> do something1
> if condition1==true goto[l]
> do something2
> if condition2==true goto[l]
> do some other stuff
as you see i do something1 then check some cond. if something didn't go
well
> i start doing everything from the start. same for something2. I want to
go
> all the way to the top. using a while or something alike would need some
> variable to hold it and maintaine which is messy. or if a do while loop
> exists (?) it will need to do everything and then restart. I want some
> mechanism that will restart itself if conditions are not met. goto seems
the
> only simple option to do it.
again, suggestions are always welcomed
> Guy
The logical OR evaluates its arguments in order, skipping subsequent
arguments as soon as a True result is found. Use it in a bodyless
While:
While[(something1; condition1) || (something2; condition2)];
otherstuff
====
Subject: Re: goto and label (cont)
>Hi again,
since everyone tells me not to use goto and label (although for the
>use i'll describe below it is very comfterable and the simplest way
>to do it. If anyone can suggests an alternative/mathematica way of
>doing it, please do.
>the pseudocode with goto
>label[l]
>do something1
>if condition1==true goto[l]
>do something2
>if condition2==true goto[l]
>do some other stuff
>as you see i do something1 then check some cond. if something
>didn't go well i start doing everything from the start. same for
>something2. I want to go all the way to the top. using a while or
>something alike would need some variable to hold it and maintaine
>which is messy. or if a do while loop exists (?) it will need to do
>everything and then restart. I want some mechanism that will
>restart itself if conditions are not met. goto seems the only
>simple option to do it.
While loops will do what you want. The flow you describe above could be
coded as
While[condition1 == True || condition2 == True,
While[condition1 == True, do something1];
do something2]
do some other stuff
The same functionality as a do while loop can be implemented in Mathematica
as a While loop as follows:
While[True,
do something;
If[test, Break[]]]
With this, the while loop continues until test evaluated true and causes a
Break[] to be executed. At that time the loop is exited. And since the do
something comes before the If, you are certain to do something at least
once.
Do note, this simply shows you how to achieve the flow control you want
without a goto. It is still an example of proceedural programing. It is
almost always the case, Mathematica works more efficiently and faster if
functional programming is used rather than proceedural programming. And it is
usually true there is a functional approach for any proceedural approach.
I've no way to suggest a functional approach without a better definition of
the problem you are trying to solve.
--
To reply via email subtract one hundred and four
====
Subject: Re: Reloading packages: Removed[symbol]
Hi
I keep some functions in a package in a file (called 'Std.m').
After altering a function(s) all I do is to re Evaluate
< been modified in another mathematica session and I want to take
> advantage of the new functionality.)
I thought I was being clever by first removing all the package symbols
> with Remove[] and then removing the package name from $Packages. This
> allows me to reload the package, but I'm left with a dilemma.
> Definitions that are in memory that referenced the symbols that have
> been removed have been replaced with 'Removed[symbol]' and I can't
> seem to match them to turn them back.
Is there a way of reloading a module? How do I fix this problem?
The string of operations to reload MyPackage was:
Remove[MyPackage`*]
Unprotect[$Packages];
> $Packages = Select[$Packages, =AC StringMatchQ[#, MyPackage`*] &];
Needs[MyPackage`]
My problem now is effectively:
In: a = MyPackage`Foo[]
> In: Remove[MyPackage`*]
> In: a // FullForm
> Out: Removed[Foo][]
How do I convert a back?
In: a /. Removed[x_] :> Symbol[x]
Doesn't do anything :(.
Joe
> --
> Josef Karthauser (joe@tao.org.uk) http://www.josef-k.net/
> FreeBSD (cvs meister, admin and hacker) http://www.uk.FreeBSD.org/
====
Subject: Re: WolframNotebookIndexer
At least it worked... I installed the Indexer a few days ago on my G4
(OS 10.4.1) and after the
next restart Spotlight would not search at all.
I have had no reply to a query to prerelease.wolfram.com as to how to
uninstall,
but when I (as adminstrator) removed Wolfram Notebook.mdimporter from
its location in
/Library/Spotlight and restarted, Spotlight returned to normal.
David Elliott
> This is a Mac OS question.
I downloaded and installed the Wolfram Notebook Indexer for 10.4
> Spotlight. The description states that it will search the notebooks
> that are part of the online help system. However, when I search for,
> for example, EulerGamma, I get many hits from Trott's Mathematica
> Guidebook notebooks and from the WebMathematica documentation but
> nothing from the online help. Am I missing a step or is the
> description wrong?
Garry Helzer
> gah@math.umd.edu
====
Subject: string to a special list
hi
please how could i transform the string:
ab(c|d|e)fg(h|i)zx
into the list:
{a,b,c|d|e,f,g,h|i,z,x}
rose
====
Subject: Re: string to a special list
ToExpression /@ (Characters[
ab(c|d|e)fg(h|i)zx] //. {a__, (, b__, ),
c___} :> {a, {b},
c} //. {a___, b_, |, c_, d___} :> {a,
StringJoin[b, |, c], d})
???
Jens
hi
> please how could i transform the string:
> ab(c|d|e)fg(h|i)zx
> into the list:
> {a,b,c|d|e,f,g,h|i,z,x}
> rose
====
Subject: Mathematica equivalent complexplot
This is a newbie question, I suppose. I've read as much as I can but cannot
find a straight forward way to implement the complexplot in
Mathematica 5.
An example call could be complexplot(sin(x+i),x=-Pi..Pi) where sin(x+i)
is a typical function f(x) that maps real to complex and -Pi..Pi is the
domain of f, a..b. Of course, there are various plot options which can
follow and would be included before the closing paren but I think I can
handle that.
So any help would be appreciated.
Ron Francis
====
Subject: Re: Mathematica equivalent complexplot
what many
< schrieb im Newsbeitrag
This is a newbie question, I suppose. I've read
> as much as I can but cannot
> find a straight forward way to implement the
> complexplot in
> Mathematica 5.
An example call could be
> complexplot(sin(x+i),x=-Pi..Pi) where sin(x+i)
> is a typical function f(x) that maps real to
> complex and -Pi..Pi is the
> domain of f, a..b. Of course, there are various
> plot options which can
> follow and would be included before the closing
> paren but I think I can
> handle that.
So any help would be appreciated.
> Ron Francis
====
Subject: Re: BinaryIO
I have just updated to Mathematica 5.1.1.0 and trying the new
BinaryIO-Commands to
> increase the IO speed. But ... here is something strange:
> n = 1000000;
> BinaryWrite[binTS.dat, TSout, {Real64, Real64}]; // Timing
> TSin = BinaryReadList[binTS.dat, {Real64, Real64}]; // Timing
> TSout == TSin
> Evaluating these lines with a fresh kernel: everything is ok. Evaluate
them a
> second time and TSout==TSin produce a _False_. Restarting the kernel:
> everything is ok.
> Every time I (try to) overwrite the file _binTS.dat_ I got a False. It
seems to
> me that the routine is not able to overwrite files.
Hmmm, any suggestions?
marko
>
The problem with using BinaryWrite (or indeed Write) with a file name as
its first argument is that there is no clear concept of closing the
files. Create a stream
strout=OpenWrite[binTS.dat,BinaryFormat->True]
Then you can use that as the argument to BinaryWrite. After that, use
Close to close the stream and re-open the file with
OpenRead[binTS.dat,BinaryFormat->True] to read it back. Finally, close
it again. This is a little bit more work, but Mathematica knows exactly
what you want it to do with the files.
David Bailey
http://www.dbaileyconsultancy.co.uk
====
Subject: Re: BinaryIO
Hi Marko,
First,
is an integer and you need the format: Integer64 instead of Real64
Second, BinaryReadList used without specifying the numbers of elements
does not always work properly and returns a superfloues last element.
Further, if the file is not close before calling BinaryReadList
without numbers of elements, it returns subsequently more elements.
BinaryReadList is not properly implemented! Mayby Wolfram takes a not.
Best is always to specify the number of elements in BinaryReadList.
sincerely, Daniel
I have just updated to Mathematica 5.1.1.0 and trying the new
BinaryIO-Commands to
> increase the IO speed. But ... here is something strange:
> n = 1000000;
> BinaryWrite[binTS.dat, TSout, {Real64, Real64}]; // Timing
> TSin = BinaryReadList[binTS.dat, {Real64, Real64}]; // Timing
> TSout == TSin
> Evaluating these lines with a fresh kernel: everything is ok. Evaluate
them a
> second time and TSout==TSin produce a _False_. Restarting the kernel:
> everything is ok.
> Every time I (try to) overwrite the file _binTS.dat_ I got a False. It
seems to
> me that the routine is not able to overwrite files.
Hmmm, any suggestions?
marko
>
====
Subject: Re: BinaryIO
BinaryWrite is like Write. It does not close it's streams when it's
finished. So the second BinaryWrite appends to the file. To overwrite,
you should first close the stream.
n = 1000000;
stream = OpenWrite[binTS.dat, BinaryFormat -> True];
BinaryWrite[stream, TSout, {Real64, Real64}]; // Timing
Close[stream];
TSin = BinaryReadList[binTS.dat, {Real64, Real64}]; // Timing
TSout == TSin
-Dale
I have just updated to Mathematica 5.1.1.0 and trying the new
> BinaryIO-Commands to
> increase the IO speed. But ... here is something strange:
> n = 1000000;
> BinaryWrite[binTS.dat, TSout, {Real64, Real64}]; // Timing
> TSin = BinaryReadList[binTS.dat, {Real64, Real64}]; // Timing
> TSout == TSin
> Evaluating these lines with a fresh kernel: everything is ok. Evaluate
> them a
> second time and TSout==TSin produce a _False_. Restarting the kernel:
> everything is ok.
> Every time I (try to) overwrite the file _binTS.dat_ I got a False. It
> seems to
> me that the routine is not able to overwrite files.
Hmmm, any suggestions?
marko
>
====
Subject: Re: Numbering equations
> I am interested in numbering equations in the following way :
chapter 1
> (1.1)
> (1.2)
> ...
chapter 2
> (2.1)
> (2.2)
> ...
> etc.
Is there a simple way to do that ?
Yes. This may sound complicated but it is actually quite straightforward
and logical. Three things are required:
[1] You need a Chapter heading style. I would suggest taking an existing
Style (such as Section) in an existing StyleSheet (say Article Classic,
which has a NumberedEquation style), copying and pasting it into the
StyleSheet and then modifying its name to Chapter. It is easiest to use
Format | Show Expression
and edit the raw cell to modify its name to Chapter. You need to
modify the names in each of the style environments as well.
[2] You can modify the properties of the Chapter style using either
Format | Show Expression
or via the Option Inspector. In particular, you need to set
CellGroupingRules -> {SectionGrouping, 20} -- the number defines the
hierarchical ordering.
CounterIncrements -> Chapter -- you want the Chapter counter to
increment each time you start a new Chapter.
CounterAssignments->{{Section, 0}, {Subsection, 0},
{Subsubsection, 0}, {NumberedEquation, 0}} -- you want the
section, subsection, subsubsection, and equation counters to reset
whenever you start a new Chapter.
[3] Now edit the NumberedEquation style, which is in the Styles for
Automatic Numbering section so that it includes counters for both the
Chapter and NumberedEquation. Unformatting the NumberedEquation
style, the appropriate part of the NumberedEquation style should become
TextData[
{
(,
CounterBox[ Chapter],
.
CounterBox[ NumberedEquation]
)
}]
Now everything should work as required.
Paul
--
Paul Abbott Phone: +61 8 6488 2734
School of Physics, M013 Fax: +61 8 6488 1014
The University of Western Australia (CRICOS Provider No 00126G)
AUSTRALIA http://physics.uwa.edu.au/~paul
http://InternationalMathematicaSymposium.org/IMS2005/
====
Subject: Preventing LegendreP from self-extracting in manipulations
I have already tried to post the message, but it went lost. I repeat it
as a new therad.
Can somebody help me with the following. I need present some functions
(prolate spheroidal functions) in the basis of the Legendre
polynomials. I.e.
I have functions like
FF1 = 0.6 LegendreP[5, #1] + 0.7 LegendreP[6, #1] &
FF2 = 0.3 LegendreP[5, #1] + 0.2 LegendreP[6, #1] &
I want to manipulate these functions and remain in the basis of prolate
functions.
For example I want to create a linear combination of functions, or
something like this.
FF = .2FF1[#1] + .3FF2[#1] &
It works well from the point of view of finding the numerical result,
but it do not give
the presentaion of the function in the basis of the Legendre
polynomials
I would like to have create a function which would give the result like
FFX = 0.9 LegendreP[5, #1] + 0.9 LegendreP[6, #1] &, so that I could
see the presentaion
of the function by typing FFX and obtaining 0.9 LegendreP[5, #1] + 0.9
LegendreP[6, #1] &.
In practice these functions contain much more terms and having the form
like
0.9 LegendreP[5, #1] + 0.9 LegendreP[6, #1] & is very important. In
the same way
I would not like to have the explicit presentation as plolinomials,
like -0.28125+
1.6875 w + 5.90625 w^2 + .. because of loss of accuracy for future
results.
Vladislav
====
Subject: Re: Simplify expression
Hi Muktar,
what you want to do involves assumptions that you must specify. E.g.:
Assuming[x1^2 > x2^2, Sqrt[(x1^2 - x2^2)^2] // Simplify]
will do what you want.
sincerely, Daniel
> I need to solve system of equations f1[x1,x2]=0,f2[x1,x2]==0, however,
> some elements of these equation have the form Sqrt[(x1^2-x2^2)^2]. It
> takes really long time to solve. If, however, I manually simplify
> those elements, for example, Sqrt[(x1^2-x2^2)^2]=x1^2-x2^2 then solve
> is fast. Therefore, the question is how I can force mathematica
> simplify expressions of this sort (another elements are fractions that
> depend on x1 and x2 in Mathematica's mind but in reality they cancel
> out and fraction becomes a number). I do not want to use FindRoot since
>
====
Subject: Re: Simplify expression
you can't because Sqrt[[(x1^2-x2^2)^2] is
Abs[x1^2-x2^2]
Jens
Mukhtar Bekkali schrieb im
>I need to solve system of equations
>f1[x1,x2]=0,f2[x1,x2]==0, however,
> some elements of these equation have the form
> Sqrt[(x1^2-x2^2)^2]. It
> takes really long time to solve. If, however, I
> manually simplify
> those elements, for example,
> Sqrt[(x1^2-x2^2)^2]=x1^2-x2^2 then solve
> is fast. Therefore, the question is how I can
> force mathematica
> simplify expressions of this sort (another
> elements are fractions that
> depend on x1 and x2 in Mathematica's mind but in
> reality they cancel
> out and fraction becomes a number). I do not
> want to use FindRoot since
> Bekkali
>
====
Subject: Re: goto and label (cont)
Ok,
Hi Gui,
The reason for us as humans to write computer code is to take control over
the action of computers. The reason to avoid the Goto command is to avoid
spaghetti code that is difficult to debug and to reinterpret later. The
Goto
enables you to create a wormhole from any point at any level to any other
point at any other level in the program, and this means that there is no
clear flow direction in the program. Is this way the program easily
gets
very complicated topology. When you try to read such a program, and find a
label, you must check the complete code for Goto commands, and understand
the state of the variables at the jump, to be able to see the effects of
the
commands following the label. I have had difficulties in rewriting my own
old Basic programs as Mathematica code just because these goto commands. I
also imagine that compilers can have difficulties to create optimal code
when Goto commands are used. Thus, as a general rule, avoid Goto. As
with
all such general rules, there might of course be exceptions.
We can rewrite your pseudo code in the following way, to obtain one outer
and one inner loop, with only one Goto for each label.
label[L2]
label[L1]
do something1
if condition1==true goto[L1]
do something2
if condition2==true goto[L2]
do some other stuff
Here is some equivalent pseudo code, using While instead. With While, there
is automatically only one start and end point per jump. I redefine
condition1 and condition2 as variables, which can take the values True or
False:
condition1 = True; condition2 = True;
While[condition2,
While[condition1, do something1; recalculate condition1];
do something2; condition1 = True; recalculate condition2]
Here is a concrete example:
x = 0; y = 0; condition1 = True; condition2 = True;
While[condition2,
While[condition1, x = x + 1; condition1 = x <= 10];
y = y + 1; condition1 = True; condition2 = (x <= 15 || y <= 10)];
{x, y}
(Returns {21,11})
Ingolf Dahl
Sweden
-----Original Message-----
====
Subject: goto and label (cont)
Hi again,
since everyone tells me not to use goto and label (although for the use
i'll
describe below it is very comfterable and the simplest way to do it. If
anyone can suggests an alternative/mathematica way of doing it, please do.
the pseudocode with goto
label[l]
do something1
if condition1==true goto[l]
do something2
if condition2==true goto[l]
do some other stuff
as you see i do something1 then check some cond. if something didn't go
well
i start doing everything from the start. same for something2. I want to go
all the way to the top. using a while or something alike would need some
variable to hold it and maintaine which is messy. or if a do while loop
exists (?) it will need to do everything and then restart. I want some
mechanism that will restart itself if conditions are not met. goto seems
the
only simple option to do it.
again, suggestions are always welcomed
Guy
====
Subject: Getting simple answers from Reduce, ComplexExpand and FullSimplify
Below the expression ex has roots, rts, where n in an integer and the
constant a is in the interval 0 < a <1. We may check this using
FullSimplify
as follows.
ex=2 Cos[z]+I a Sin[z];
rts=z ->Pi(2n-1)/2 + I Log[(2+a)/(2-a)]/2;
FullSimplify[0 == ex/.rts,Element[n,Integers]]
My problem is to try and deduce the roots using computer algebra rather
than
by hand. (I also have other expressions I would like to work on.) My
attempt
at using Reduce is partially successful but leads to unfamiliar, and
difficult to interpret, ArcTanh functions
Reduce[{ex == 0,0