mm-979
===
Subject: ExportString[NumberForm@5,MathML,Semantics->False]
The option in the command in the subject is being ignored. I wasn't
going to report this because I have kinda been forced to distance
myself from MathML in Mathematica, but I figured it was the right
thing to do.
Here is the output from the command:
P.S. The listing of options in the documentation for importing and
exporting MathML is incomplete. Check
Options@XML`MathML`ExpressionToMathML
P.P.S. As mentioned in other bug reports, the tag is wrong. This
is caused by a problem with MakeBoxes and NumberForm generating too
many string quotations. Kinda like DisplayForm:
(*has the extra string quotation problem (should be equivalent to 3rd
example, but isn't)*)
FullForm@ToBoxes@DisplayForm@5
(*same problem here*)
FullForm@ToBoxes@NumberForm@5
(*doesn't have the extra string quotation problem*)
FullForm@ToBoxes@DisplayForm@RowBox@List@5
Version 6.0.1 on Windows XP SP2
--
http://chris.chiasson.name/
===
Subject: Re: Re: Similar matrices->similar eigenvectors?
If there were a standard way to make Eigensystem stable in that sense, I
suspect WRI would be using it already. What those guys don't know about
algebra is rarely worth knowing.
Bobby
> I've tried both approaches, and they seem to remove some of the
> jittering, but now I realize that the problem is more fundamental --
> spectral decomposition of a matrix with degenerate eigenvalues is ill-
> posed. As a result, Eigenvectors, and SingularValueDecomposition are
> unstable for inputs in the vicinity of those points.
Is there a standard approach for regularizing the problem so that
> eigenvector finding becomes stable?
Yaroslav
>> I don't think it's possible to eliminate all discontinuities, but this
>> may
>> improve things:
>> Clear[normalize, eigensystem]
>> normalize[v : {(0.) ..., x_?Negative, ___}] := -v/Norm[v]
>> normalize[v_?VectorQ] := v/Norm[v]
>> normalize[m_?MatrixQ] := normalize /@ m
>> eigensystem[m_?MatrixQ] := Module[{e, vecs, vals, o},
>> {vals, vecs} = Eigensystem[m];
>> vecs = normalize@vecs;
>> o = Reverse@Ordering@vals;
>> {vals[[o]], vecs[[o]]}
>> ]
>> eigensystem[m_?MatrixQ, k_Integer?Positive] :=
>> eigensystem[m][[All, ;; k]]
>> distances2points[d_] := (n = Length[d];
>> h = IdentityMatrix[n] - Table[1, {n, n}]/n;
>> b = -h.(d*d/2).h;
>> {vals, vecs} = eigensystem[b, 2];
>> Point[Re[#]] & /@ Transpose[vecs*Sqrt[vals]])
>> Clear[d1, d2, d3, d4, d5, d6]; limits = {{{d1, 0, 1->2}, 0,
>> 1}, {{d2, 0, 1->3}, 0, 1}, {{d3, 0, 1->4}, 0,
>> 1}, {{d4, 0, 2->3}, 0, 1}, {{d5, 0, 2->4}, 0,
>> 1}, {{d6, 0, 3->4}, 0, 1}};
>> Manipulate[
>> Graphics[distances2points[{{0, d1, d2, d3}, {d1, 0, d4, d5}, {d2, d4,
>> 0, d6}, {d3, d5, d6, 0}}], PlotRange -> {{-1, 1}, {-1, 1}}],
>> Evaluate[Sequence @@ limits], LocalizeVariables -> False]
>> Replace eigensystem with Eigensystem in distances2points, to get the
>> original behavior.
>> Bobby
>> In the default implementation of Eigenvectors, the orientations
seem
>> arbitrary. Changing the matrix slightly could end up flipping the
>> eigenvectors 180 degrees. A simple fix of telling eigenvectors to
>> always be on one side of some arbitrary plane doesn't work because it
>> will flip eigenvectors that are near-parallel to the plane with small
>> changes in the matrix.
>> I'm trying to make a demo of multi-dimensional scaling, and the result
>> is that as I drag the slider, the points flip back and forth
>> erratically.
>> Basically I'd like to get a function g[mat] which returns eigenvectors
>> of mat, and is continuous, what is the simplest way of achieving this?
>> -----------
>> distances2points[d_] := (n = Length[d];
>> (*nxn matrix of ones*)j = Table[1, {n, n}];
>> (*centering matrix*)h = IdentityMatrix[n] - j/n;
>> a = -d*d/2;
>> b = h.a.h;
>> (*Eigenvectors are returned with arbitrary orientation,
>> orient them to point in the same halfplane*)
>> orient[v_, orientvec_] := ((*1,1,1,1 halfplane is often ambiguous,
>> use random halfplane*)(*SeedRandom[0];
>> orientvec=RandomReal[{0,1},Length[v]];*)
>> If[Round[v, .1].orientvec > 0, -v, v]);
>> vecs = Eigenvectors[b][[1 ;; 2]];
>> (*vecs=orient[#,b[[1]]]&/@vecs;*)
>> vals = Eigenvalues[b][[1 ;; 2]];
>> Point[Re[#]] & /@ Transpose[vecs*Sqrt[vals]])
>> Clear[d1, d2, d3, d4, d5, d6]; limits = {{{d1, 0, 1->2}, 0,
>> 1}, {{d2, 0, 1->3}, 0, 1}, {{d3, 0, 1->4}, 0,
>> 1}, {{d4, 0, 2->3}, 0, 1}, {{d5, 0, 2->4}, 0,
>> 1}, {{d6, 0, 3->4}, 0, 1}};
>> Manipulate[
>> Graphics[distances2points[{{0, d1, d2, d3}, {d1, 0, d4, d5}, {d2, d4,
>> 0, d6}, {d3, d5, d6, 0}}], PlotRange -> {{-1, 1}, {-1, 1}}],
>> Evaluate[Sequence @@ limits], LocalizeVariables -> False]
>> --
>> DrMajor...@bigfoot.com
--
DrMajorBob@bigfoot.com
===
Subject: Re: the temperamental loop or something wrong with my expression
Post that without In[...]:= and the outputs, and you'd triple the chance
that anybody will respond. To do anything with your code, we have to
manually, laboriously figure out what's a printed output (guessing in some
cases), delete all of it, find all the Ins and Outs, delete those...
Who'd do that?
Well... I might, but I don't have a lot to do some days!
The first line tells me the likely problem, however... and that's
Simplify. You're using complicated expressions, making them even MORE
complicated... and then trying to Simplify. Frequently.
That can easily take more time than you'll ever have.
When possible you should Simplify once and for all and use Set, not
SetDelayed, for example:
approxFab[f_,t_,p_]=1/384 f^2 (-35-28 Cos[2 t]-Cos[4 t]+8 (Cos[4
p]+Sqrt[3] Sin[4 p]) Sin[t]^4)+1/147456f^4 (5702-86 Cos[4 t]-7 Cos[6 t]-16
Sin[t]^4 (-41 Cos[2 p]+95 Cos[4 p]+Sqrt[3] (41 Sin[2 p]+95 Sin[4 p])+2
Cos[6 p] Sin[t]^2)+Cos[2 t] (4631+16 (-Cos[2 p]+7 Cos[4 p]+Sqrt[3] (Sin[2
p]+7 Sin[4 p])) Sin[t]^4))-1/6144[ImaginaryI] f^3 (32 (7+Cos[2 t]) Sin[3
p] Sin[t]^3+16 Sqrt[3] Cos[5 p] Sin[t]^5+16 Sin[5 p] Sin[t]^5-Sqrt[3]
Cos[p] (42 Sin[t]+27 Sin[3 t]+Sin[5 t])+Sin[p] (42 Sin[t]+27 Sin[3
t]+Sin[5 t]))//Simplify
(1/147456)f^2 (384 (-35-28 Cos[2 t]-Cos[4 t]+8 (Cos[4 p]+Sqrt[3] Sin[4 p])
Sin[t]^4)+f^2 (5702-86 Cos[4 t]-7 Cos[6 t]-16 Sin[t]^4 (-41 Cos[2 p]+95
Cos[4 p]+Sqrt[3] (41 Sin[2 p]+95 Sin[4 p])+2 Cos[6 p] Sin[t]^2)+Cos[2 t]
(4631+16 (-Cos[2 p]+7 Cos[4 p]+Sqrt[3] (Sin[2 p]+7 Sin[4 p]))
Sin[t]^4))-24 [ImaginaryI] f (16 Sin[t]^3 (2 (7+Cos[2 t]) Sin[3
p]+(Sqrt[3] Cos[5 p]+Sin[5 p]) Sin[t]^2)-Sqrt[3] Cos[p] (42 Sin[t]+27
Sin[3 t]+Sin[5 t])+Sin[p] (42 Sin[t]+27 Sin[3 t]+Sin[5 t])))
In that case Simplify didn't accomplish much (reducing LeafCount from 248
to 243), but it's worth trying, and Set (=) will still yield (usually) a
function that executes faster than with SetDelayed (:=). This can't be
done with a function like delconj that uses Part, but even so, delconj
could be simplified to
delconj[eq_] := Conjugate@Total@eq /. Conjugate[x_] -> x
I'm not sure what /. Conjugate[x_] -> x accomplishes for you (too many
details for me), but eliminate it if you can. Even if you can't, the above
will be much faster than the original.
Similarly, expandaa becomes:
expandaa[eq_] := CoefficientList[eq, f].f^Range@Length@eq
(Dot product is fast.)
It's doubtful that Expand[Simplify[....]] makes the Integrate in
a[Alpha][Alpha][f_, l_, m_] evaluate faster or better. If the
integration can be done for symbolic f, l, and m, do it just ONCE (not
every time the function is called), like this:
a[Alpha][Alpha][f_, l_, m_] =
Integrate[
Sin[[Theta]]*
conjSphericalHarmonicY[l,
m, [Theta], [Phi]] approxF[Alpha][Alpha][
f, [Theta], [Phi]], {[Theta], 0, Pi}, {[Phi], 0,
2 Pi}]
That doesn't work as things are, but try to redefine
conjSphericalHarmonicY and approxF[Alpha][Alpha] so that it DOES.
I hope some of that helps!
Bobby
> Hi
> I have defined a function whose value I want to know for a range of two
> of its arguments. So to save time, I use a Do loop. However, after a
> few loops, it just doesn't produce any more result, even though at the
> top it still says: 'Running ...'. I know that when I do this by manually
> changing the arguments without using a Do loop, they all evaluate. So I
> thought it's to do with Do, and after reading somewhere in this forum
> that For and While are faster, I tried them as well, but they still
> become stuck after a few loops. The best I can do using a loop is to
> split the range of the variables into smaller ones; for some reason,
> this sometimes work, but sometimes it still doesn't work. The quickest
> I can do is actually just do them individually without using a loop. I
> find this a bit puzzling and would really appreciate if anyone can help
> me with this.
The Notebook is here:
> ***********************************************
> In[1]:=
> delconj[eq_] :=
> Apply[Plus,(Conjugate[
> Simplify[
> Table[Expand[eq][[i]],{i,1,
> Length[Expand[eq]]}]]]) /. {Conjugate[x_][Rule]x}];
In[2]:=
> conjSphericalHarmonicY[l_,m_,[Theta]_,[Phi]_]:=
> delconj[1+SphericalHarmonicY[l,m,[Theta],[Phi]]]-1;
In[3]:=
> conjY[eq_]:= Conjugate[eq] /. Conjugate[x_][Rule]x;
In[4]:=
> expandaa[eq_]:=(aaa=eq;bbb=CoefficientList[aaa,f];
> Apply[Plus,Table[bbb[[i]]f^(i-1),{i,1,Length[bbb]}]]);
In[5]:=
> !((approxF[Alpha][Alpha][f_, [Theta]_, [Phi]_] :=
> 1/12 ((Cos[[Theta]]^2 ((3 + Cos[4 [Phi]])) +
> 4 ((1 +
> Cos[[Theta]]^4)) Cos[[Phi]]^2
Sin[[Phi]]^2)) f
> ^2 + (1/147456) (((((-11278) - 9307 Cos[2 [Theta]]
+
> 94 Cos[4 [Theta]] + 11 Cos[6 [Theta]] +
> 128 (((-5) + Cos[2 [Theta]])) Cos[
> 2 [Phi]] Sin[[Theta]]^4 -
> 64 (((-37) + 5 Cos[2 [Theta]])) Cos[
> 4 [Phi]] Sin[[Theta]]^4 -
> 32 Cos[6 [Phi]] Sin[[Theta]]^6))
f^4));))
In[7]:=
> !((approxF[Alpha][Beta][f_, [Theta]_, [Phi]_] :=
> 1/384 (((-35) - 28 Cos[2 [Theta]] - Cos[4
[Theta]] +
> 8 Sin[[Theta]]^4 ((Cos[
> 4 [Phi]] + @3 Sin[
> 4 [Phi]])))) f^2 +
(-((1/6144) ((
> [ImaginaryI] ((16 @3 Cos[
> 5 [Phi]] Sin[[Theta]]^5 -
> @3 Cos[[Phi]]
> ((42 Sin[[Theta]] + 27 Sin[3 [Theta]] +
> Sin[5 [Theta]])) + ((42 Sin[[Theta]]
+
> 27 Sin[3 [Theta]] +
> Sin[5 [Theta]])) Sin[[Phi]] +
> 32 ((7
> + Cos[2 [Theta]])) Sin[[Theta]]^3 Sin[
> 3 [Phi]] +
> 16 Sin[[Theta]]^5 Sin[
> 5 [Phi]])) f^3)))) +
(1/147456)
> ((((5702
> - 86 Cos[4 [Theta]] - 7 Cos[6 [Theta]] -
> 16 Sin[[Theta]]^4 (((-41) Cos[2
[Phi]] +
> 95 Cos[4 [Phi]] +
> 2 Cos[
> 6 [Phi]] Sin[[Theta]]^2
> + @3 ((41 Sin[
> 2 [Phi]] + 95 Sin[4
[Phi]])))) +
> Cos[2 [Theta]] ((4631 +
> 16 Sin[[Theta]]^4 (((-Cos[2
[Phi]]) +
> 7 Cos[
> 4 [Phi]] + @3 ((Sin[2
[Phi]] +
> 7 Sin[
> 4 [Phi]]))))))))
f^4));))
In[8]:=
> a[Alpha][Alpha][f_,l_,m_]:=
> Integrate[
> Expand[Simplify[
> Sin[[Theta]]*
> conjSphericalHarmonicY[l,
> m,[Theta],[Phi]]approxF[Alpha][Alpha][
> f,[Theta],[Phi]]]],{[Theta],0,Pi},{[Phi],0,2Pi}];
In[10]:=
> a[Alpha][Beta][f_,l_,m_]:=
> Integrate[
> Expand[Simplify[
> Sin[[Theta]]*
>
conjSphericalHarmonicY[l,m,[Theta],[Phi]]approxF[Alpha][Beta][
> f,[Theta],[Phi]]]],{[Theta],0,Pi},{[Phi],0,2Pi}];
In[12]:=
> !((a[Beta][Beta][f_, l_, m_] :=
> Exp[(-I)*m*(((2 Pi)/3))] a[Alpha][Alpha][f, l,
m];))
In[13]:=
> !((a[Gamma][Gamma][f_, l_, m_] :=
> Exp[(-I)*m*(((4 Pi)/3))] a[Alpha][Alpha][f, l,
m];))
In[15]:=
> !((a[Beta][Gamma][f_, l_, m_] :=
> Exp[(-I)*m*(((2 Pi)/3))] a[Alpha][Beta][f, l,
m];))
In[17]:=
> !((a[Gamma][Alpha][f_, l_, m_] :=
> Exp[(-I)*m*(((4 Pi)/3))] a[Alpha][Beta][f, l,
m];))
In[19]:=
> a[Alpha][Gamma][f_,l_,m_]:= (-1)^m*conjY[a[Alpha][Beta][f,l,m]];
In[21]:=
> !((a[Beta][Alpha][f_, l_, m_] := (((-1)))^m*
> Exp[(-I)*m*(((2 Pi)/3))]
conjY[a[Alpha][Beta][f, l,
> m]];))
In[23]:=
> !((a[Gamma][Beta][f_, l_, m_] := (((-1)))^m*
> Exp[(-I)*m*(((4 Pi)/3))]
conjY[a[Alpha][Beta][f, l,
> m]];))
In[24]:=
> !((aET[f_, l_,
> m_] := (1/(3 @ 2)) ((a[Alpha][Alpha][f, l, m]
-
> 2 a[Beta][Beta][f, l, m] + a[Gamma][Gamma][f, l, m]
+
> a[Alpha][Beta][f, l, m] - 2 a[Beta][Alpha][f, l, m]
+
> a[Gamma][Beta][f, l, m] -
> 2 a[Beta][Gamma][f, l, m] + ((a[Alpha][Gamma][f, l,
m]
> +
> a[Gamma][Alpha][f, l, m]))));))
In[34]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,6,2]]]]]
Out[34]=
> !({53.921514`8.183307071248283 Second, (((3 [ImaginaryI] -
> @3))
> f^4 @([Pi]/910))/4752})
Do[Print[aET(f,,l,m,)=,
> expandaa[FullSimplify[ComplexExpand[aET[f,l,m]]]]],{l,0,6},{m,0,l} ]
aET(f,[InvisibleSpace]0[InvisibleSpace]0[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]1[InvisibleSpace]0[InvisibleSpace])=[InvisibleS
pace]
> 0
!(*
> InterpretationBox[(aET(f,[InvisibleSpace]1[InvisibleSpace]1
> [InvisibleSpace])=[InvisibleSpace](1/168
(((-[ImaginaryI]) +
> @3)) f^3 @[Pi])),
> SequenceForm[ aET(f,, 1, 1, )=,
> Times[
> Rational[ 1, 168],
> Plus[
> Complex[ 0, -1],
> Power[ 3,
> Rational[ 1, 2]]],
> Power[ f, 3],
> Power[ Pi,
> Rational[ 1, 2]]]],
> Editable->False])
aET(f,[InvisibleSpace]2[InvisibleSpace]0[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]2[InvisibleSpace]1[InvisibleSpace])=[InvisibleS
pace]
> 0
!(*
> InterpretationBox[(aET(f,[InvisibleSpace]2[InvisibleSpace]2
> [InvisibleSpace])=[InvisibleSpace](1/864 (((-3)
[ImaginaryI]
> +
> @3)) f^4 @([Pi]/5))),
> SequenceForm[ aET(f,, 2, 2, )=,
> Times[
> Rational[ 1, 864],
> Plus[
> Complex[ 0, -3],
> Power[ 3,
> Rational[ 1, 2]]],
> Power[ f, 4],
> Power[
> Times[
> Rational[ 1, 5], Pi],
> Rational[ 1, 2]]]],
> Editable->False])
aET(f,[InvisibleSpace]3[InvisibleSpace]0[InvisibleSpace])=[InvisibleS
pace]
> 0
!(*
> InterpretationBox[(aET(f,[InvisibleSpace]3[InvisibleSpace]1
> [InvisibleSpace])=[InvisibleSpace](1/72
(((-[ImaginaryI])
> + @3))
> f^3 @([Pi]/14))),
> SequenceForm[ aET(f,, 3, 1, )=,
> Times[
> Rational[ 1, 72],
> Plus[
> Complex[ 0, -1],
> Power[ 3,
> Rational[ 1, 2]]],
> Power[ f, 3],
> Power[
> Times[
> Rational[ 1, 14], Pi],
> Rational[ 1, 2]]]],
> Editable->False])
aET(f,[InvisibleSpace]3[InvisibleSpace]2[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]3[InvisibleSpace]3[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]4[InvisibleSpace]0[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]4[InvisibleSpace]1[InvisibleSpace])=[InvisibleS
pace]
> 0
!(*
> InterpretationBox[(aET(f,[InvisibleSpace]4[InvisibleSpace]2
> [InvisibleSpace])=[InvisibleSpace]([ImaginaryI]
(([ImaginaryI]
> +
> @3)) f^4 @([Pi]/5))/3168),
> SequenceForm[ aET(f,, 4, 2, )=,
> Times[
> Complex[ 0,
> Rational[ 1, 3168]],
> Plus[
> Complex[ 0, 1],
> Power[ 3,
> Rational[ 1, 2]]],
> Power[ f, 4],
> Power[
> Times[
> Rational[ 1, 5], Pi],
> Rational[ 1, 2]]]],
> Editable->False])
aET(f,[InvisibleSpace]4[InvisibleSpace]3[InvisibleSpace])=[InvisibleS
pace]
> 0
!(*
> InterpretationBox[(aET(f,[InvisibleSpace]4[InvisibleSpace]4
> [InvisibleSpace])=[InvisibleSpace](-((17 [ImaginaryI]
(((-
> [ImaginaryI]) + @3)) f^4
@([Pi]/35))/3168))),
> SequenceForm[ aET(f,, 4, 4, )=,
> Times[
> Complex[ 0,
> Rational[ -17, 3168]],
> Plus[
> Complex[ 0, -1],
> Power[ 3,
> Rational[ 1, 2]]],
> Power[ f, 4],
> Power[
> Times[
> Rational[ 1, 35], Pi],
> Rational[ 1, 2]]]],
> Editable->False])
aET(f,[InvisibleSpace]5[InvisibleSpace]0[InvisibleSpace])=[InvisibleS
pace]
> 0
!(*
> InterpretationBox[(aET(f,[InvisibleSpace]5[InvisibleSpace]1
> [InvisibleSpace])=[InvisibleSpace]((((-[ImaginaryI])
> + @3)) f^3
> @([Pi]/55))/1008),
> SequenceForm[ aET(f,, 5, 1, )=,
> Times[
> Rational[ 1, 1008],
> Plus[
> Complex[ 0, -1],
> Power[ 3,
> Rational[ 1, 2]]],
> Power[ f, 3],
> Power[
> Times[
> Rational[ 1, 55], Pi],
> Rational[ 1, 2]]]],
> Editable->False])
aET(f,[InvisibleSpace]5[InvisibleSpace]2[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]5[InvisibleSpace]3[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]5[InvisibleSpace]4[InvisibleSpace])=[InvisibleS
pace]
> 0
!(*
> InterpretationBox[(aET(f,[InvisibleSpace]5[InvisibleSpace]5
> [InvisibleSpace])=[InvisibleSpace](1/72 ((3
> + [ImaginaryI] @3))
> f^3 @([Pi]/154))),
> SequenceForm[ aET(f,, 5, 5, )=,
> Times[
> Rational[ 1, 72],
> Plus[ 3,
> Times[
> Complex[ 0, 1],
> Power[ 3,
> Rational[ 1, 2]]]],
> Power[ f, 3],
> Power[
> Times[
> Rational[ 1, 154], Pi],
> Rational[ 1, 2]]]],
> Editable->False])
aET(f,[InvisibleSpace]6[InvisibleSpace]0[InvisibleSpace])=[InvisibleS
pace]
> 0
Do[Print[aET(f,,l,m,)=,
> expandaa[FullSimplify[ComplexExpand[aET[f,l,m]]]]],{l,6,8},{m,0,l}]
aET(f,[InvisibleSpace]6[InvisibleSpace]0[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]6[InvisibleSpace]1[InvisibleSpace])=[InvisibleS
pace]
> 0
!(*
> InterpretationBox[(aET(f,[InvisibleSpace]6[InvisibleSpace]2
> [InvisibleSpace])=[InvisibleSpace](((3 [ImaginaryI] -
> @3)) f^4
> @([Pi]/910))/4752),
> SequenceForm[ aET(f,, 6, 2, )=,
> Times[
> Rational[ 1, 4752],
> Plus[
> Complex[ 0, 3],
> Times[ -1,
> Power[ 3,
> Rational[ 1, 2]]]],
> Power[ f, 4],
> Power[
> Times[
> Rational[ 1, 910], Pi],
> Rational[ 1, 2]]]],
> Editable->False])
aET(f,[InvisibleSpace]6[InvisibleSpace]3[InvisibleSpace])=[InvisibleS
pace]
> 0
!(*
> InterpretationBox[(aET(f,[InvisibleSpace]6[InvisibleSpace]4
> [InvisibleSpace])=[InvisibleSpace](-(([ImaginaryI]
(((-
> [ImaginaryI]) + @3)) f^4
@([Pi]/91))/3168))),
> SequenceForm[ aET(f,, 6, 4, )=,
> Times[
> Complex[ 0,
> Rational[ -1, 3168]],
> Plus[
> Complex[ 0, -1],
> Power[ 3,
> Rational[ 1, 2]]],
> Power[ f, 4],
> Power[
> Times[
> Rational[ 1, 91], Pi],
> Rational[ 1, 2]]]],
> Editable->False])
aET(f,[InvisibleSpace]6[InvisibleSpace]5[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]6[InvisibleSpace]6[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]7[InvisibleSpace]0[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]7[InvisibleSpace]1[InvisibleSpace])=[InvisibleS
pace]
> 0
aET(f,[InvisibleSpace]7[InvisibleSpace]2[InvisibleSpace])=[InvisibleS
pace]
> 0
$Aborted
In[38]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,7,3]]]]]
Out[38]=
> {54.478757 Second,0}
In[39]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,7,4]]]]]
Out[39]=
> {76.970704 Second,0}
In[40]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,7,5]]]]]
Out[40]=
> {60.329395 Second,0}
In[42]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,7,6]]]]]
Out[42]=
> {32.853831 Second,0}
In[43]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,7,7]]]]]
Out[43]=
> {32.139781 Second,0}
In[44]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,8,0]]]]]
Out[44]=
> {69.877317 Second,0}
In[45]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,8,1]]]]]
Out[45]=
> {91.335676 Second,0}
In[46]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,8,2]]]]]
Out[46]=
> {88.233249 Second,0}
In[47]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,8,3]]]]]
Out[47]=
> {77.997297 Second,0}
In[48]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,8,4]]]]]
Out[48]=
> {79.343742 Second,0}
In[49]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,8,5]]]]]
Out[49]=
> {62.095294 Second,0}
In[50]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,8,6]]]]]
Out[50]=
> {49.984301 Second,0}
In[51]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,8,7]]]]]
Out[51]=
> {33.587836 Second,0}
In[52]:=
> AbsoluteTiming[expandaa[FullSimplify[ComplexExpand[aET[f,8,8]]]]]
Out[52]=
> {32.811034 Second,0}
********************************************
aET[f,l,m] is the function I want to evaluate for {l,0,8} and for each=
=
> l, {m,-l,l}. As can be seen in the first Do loop, it stopped at =
> aET[f,6,0]; I deleted 'Aborted'. And as can be seen in the second Do =
> loop, it stopped at aET[f,7,2]. I finished the rest just by using the=
=
> expression expandaa[FullSimplify[ComplexExpand[aET[f,l,m]]]] again and=
=
> again. When I was doing this I noticed that the above expression =
> sometimes gets stuck and I have to do it one step at a time. e.g =
> aET[f,l,m], then ComplexExpand[aET[f,l,m]], then =
> FullSimplify[ComplexExpand[aET[f,l,m]]] and so on, then the whole =
> expression will work afterwards. This is also very strange.
-- =
DrMajorBob@bigfoot.com
===
Subject: Re: Re: Intensive numerical calculations
]zac[
>Suffice it to say that a dense representation will cause problems for
>>most software on many machines. As for a sparse represntation, and
>>computational speed, it will depend on what specifically you want to do.
>>Mathematica uses some fairly good libraries for certain linear algebra
>>operations on such matrices. If what you require is not well supported
>>then you might need to go to some other approach, perhaps via MathLink.
>>Daniel Lichtblau
>>Wolfram Research
My problem is not the dimension of the matrixes. Certainly the
> limitation on the packeds array (< 2^31)limits, but my true problem is
> the slowness in to pass these matrixes to the form c++ by matlink.
> That that profit inserting pieces in c++, I lose in the transfers
> through matlink. I have to develop a form (structural fem)
> personalized for the analysis of parts mechanics submitted to dynamic
> solicitations and I was considering mathematica because I knew it from
> the university. If I use c++ and MTL for example it'is ok There is a
> method for move more quickly big matrixes (unfortunately the matrixes
> become full with the progress of the footsteps and it would be for me
> too complicated to avoid this to the beginning) from Mathematica to
> an external form in c++?
If you provide simple examples and take the trouble to use correct
terminology then you will more likely get useful responses. For example,
there is no matlink (the program you have in mind, I suspect, is
MathLink). Moreover you still have not specified what is your data
format when it resides in Mathematica. SparseArray[...]? Something else?
Maybe what you will require is some form of Export. I believe that
function supports some matrix types but it is, as I note, unclear which
would be appropriate, as you gave no example.
As for matrix fill-in, I'd be really surprised if your C++ library code
uses a dense method for solving linear systems of the sort generated for
FEM, with dimension around 10^5. As noted in a prior response, that
would be close to 100 Gb, and that is a large chunk of memory to work
with. Not to mention time, since you would likely have an O(n^3)
algorithm, or at best maybe O(n^2.4) or so from asymptotically fastest
approaches to matrix multiplication.
Much more likely is that a Krylov type of method would be used. Similar
to what Mathematica might do in solving a sparse system using machine
double arithmetic.
Daniel Lichtblau
Wolfram Research
===
Subject: Re: Mathematica 6 save as PDF page size issues
Hi guys
the cell with the graphic and then right click on the bar next to the
cell and use File -> Save As... and then select PDF.
However, the problem is (partially) solved. The problem seems to have
been that the notebook I had was created in Mathematica 5 while I was
using v6. Strange as it may sound when I corrected all the
compatibility issues and re-evaluated the entire notebook to
regenerate the troublesome graphic anew it worked. Save as produced a
PDF with the correct page size.
While the problem is solved, it would still be nice not to have to re-
evaluate the notebook each time one has an notebook from the old
version and tries to do something similar...
===
Subject: Matrix Inverse Issue
I am having a problem with the matrix inverse for the following matrix in
Mathematica 6:
A = Table[If[j == i, 1 - i/10, If[j == i + 1, i/10, 0]], {i, 9}, {j, 9}]
{{9/10, 1/10, 0, 0, 0, 0, 0, 0, 0}, {0, 4/5, 1/5, 0, 0, 0, 0, 0,
0}, {0, 0, 7/10, 3/10, 0, 0, 0, 0, 0}, {0, 0, 0, 3/5, 2/5, 0, 0, 0,
0}, {0, 0, 0, 0, 1/2, 1/2, 0, 0, 0}, {0, 0, 0, 0, 0, 2/5, 3/5, 0,
0}, {0, 0, 0, 0, 0, 0, 3/10, 7/10, 0}, {0, 0, 0, 0, 0, 0, 0, 1/5, 4/
5}, {0, 0, 0, 0, 0, 0, 0, 0, 1/10}}
A Inverse[A]
{{1, -1/72, 0, 0, 0, 0, 0, 0, 0}, {0, 1, -1/14, 0, 0, 0, 0, 0, 0}, {0,
0, 1, -3/14, 0, 0, 0, 0, 0}, {0, 0, 0, 1, -8/15, 0, 0, 0, 0}, {0,
0, 0, 0, 1, -5/4, 0, 0, 0}, {0, 0, 0, 0, 0, 1, -3, 0, 0}, {0, 0, 0,
0, 0, 0, 1, -49/6, 0}, {0, 0, 0, 0, 0, 0, 0, 1, -32}, {0, 0, 0, 0,
0, 0, 0, 0, 1}}
I expected the identity matrix here but I get extra terms.
Am I doing something wrong?
Brian Gladman
===
Subject: Global Variables in Options?
Can Options contain global variables? (in 5.2)
For example, can I do
SetOptions[Plot, TextStyle->{FontSize->myFontSize}];
(* with no numerical value yet assigned to myFontSize *)
and then later on in the notebook write
myFontSize = 14; Plot[ <> ];
myFontSize = 16; Plot[ <> ];
Or must I structure this as
myFontSize = 14;
SetOptions[Plot, TextStyle->{FontSize->myFontSize}];
Plot[ <> ];
myFontSize = 16;
SetOptions[Plot, TextStyle->{FontSize->myFontSize}];
Plot[ <> ];
===
Subject: Re: IsExact
ClearAll[n, x, y, a, a1, a2, b, r];
c1 = {1, 2*I/5, E^(25*n), 3/4 + I, Cos[n*x*Pi], y*Sqrt[-5]};
c2 = {a/b, r + 2/5, a1, a2};
c3 = {1.5, 0, Sqrt[3], 0, 4};
c4 = {(r + 0.5)/3, 3/7, 3 + Sin[4*x*y]};
c5 = {1, 2, 3, 4, 5, 6} + 0.0;
c6 = {N[x]};
test = {c1, c2, c3, c4, c5, c6};
noReals = FreeQ[#, _Real] &;
noReals /@ test
{True, True, False, False, False, True}
That's correct if the undefined variables are exact. Define them, and you
may get different results. For c6, it also depends on whether x is defined
before, or after, c6:
Clear[x]
c6 = {N[x]}
noReals@c6
x = 7
noReals@c6
x = 7.
noReals@c6
{x}
True
7
True
7.
False
or
x = 7
c6 = {N[x]};
noReals@c6
7
{7.}
False
Bobby
> Let c be a 1D list of scalar coefficients, numeric or symbolic,
> real or complex. No entry is a list. Examples:
ClearAll[n,x,y,a,a1,a2,b,r];
> c1={1,2*I/5,E^(25*n),3/4+I,Cos[n*x*Pi],y*Sqrt[-5]};
> c2={a/b,r+2/5,a1,,,,,a2};
> c3={1.5,0,Sqrt[3],0,4};
> c4={(r+0.5)/3,3/7,3+Sin[4*x*y]};
> c5={1,2,3,4,5,6}+0.0;
> c6={N[x]};
I need a function IsExact[c] that returns False if
> at least one entry of c is floating, or if it contains one
> floating number; else True. For example, tests on
> c1 and c2 should return True; the others False.
Any simple way to implement this? It should work on V.5.
>
-- =
DrMajorBob@bigfoot.com
===
Subject: Re: IsExact
> Let c be a 1D list of scalar coefficients, numeric or symbolic,
> real or complex. No entry is a list. Examples:
ClearAll[n,x,y,a,a1,a2,b,r];
> c1={1,2*I/5,E^(25*n),3/4+I,Cos[n*x*Pi],y*Sqrt[-5]};
> c2={a/b,r+2/5,a1,,,,,a2};
> c3={1.5,0,Sqrt[3],0,4};
> c4={(r+0.5)/3,3/7,3+Sin[4*x*y]};
> c5={1,2,3,4,5,6}+0.0;
> c6={N[x]};
I need a function IsExact[c] that returns False if
> at least one entry of c is floating, or if it contains one
> floating number; else True. For example, tests on
> c1 and c2 should return True; the others False.
Any simple way to implement this? It should work on V.5.
>
Note that c6 is in fact exact, because N[x] is still (the symbol) x.
Daniel Lichtblau
Wolfram Research
===
Subject: Re: IsExact
> Let c be a 1D list of scalar coefficients, numeric or symbolic,
> real or complex. No entry is a list. Examples:
ClearAll[n,x,y,a,a1,a2,b,r];
> c1={1,2*I/5,E^(25*n),3/4+I,Cos[n*x*Pi],y*Sqrt[-5]};
> c2={a/b,r+2/5,a1,,,,,a2};
> c3={1.5,0,Sqrt[3],0,4};
> c4={(r+0.5)/3,3/7,3+Sin[4*x*y]};
> c5={1,2,3,4,5,6}+0.0;
> c6={N[x]};
I need a function IsExact[c] that returns False if
> at least one entry of c is floating, or if it contains one
> floating number; else True. For example, tests on
> c1 and c2 should return True; the others False.
Any simple way to implement this? It should work on V.5.
What is your definition of a floating number? c6 contains no numbers
for example so it should be exact, likewise for c4.
Ssezi
===
Subject: Re: IsExact
>Let c be a 1D list of scalar coefficients, numeric or symbolic,
>real or complex. No entry is a list. Examples:
ClearAll[n,x,y,a,a1,a2,b,r];
>c1={1,2*I/5,E^(25*n),3/4+I,Cos[n*x*Pi],y*Sqrt[-5]};
>c2={a/b,r+2/5,a1,,,,,a2};
>c3={1.5,0,Sqrt[3],0,4};
>c4={(r+0.5)/3,3/7,3+Sin[4*x*y]};
>c5={1,2,3,4,5,6}+0.0;
>c6={N[x]};
I need a function IsExact[c] that returns False if
>at least one entry of c is floating, or if it contains one
>floating number; else True. For example, tests on
>c1 and c2 should return True; the others False.
Any simple way to implement this? It should work on V.5.
>
Use Precision:
On your test cases:
In[114]:= IsExact /@ {c1, c2, c3, c4, c5, c6}
Out[114]= {True,True,False,False,False,True}
I don't know why you expect {N[x]} to not be exact. N[x] evaluates to x,
and {x} doesn't have any approximate numbers in it.
Carl Woll
Wolfram Research
===
Subject: Re: IsExact
> Let c be a 1D list of scalar coefficients, numeric or symbolic,
> real or complex. No entry is a list. Examples:
ClearAll[n,x,y,a,a1,a2,b,r];
> c1={1,2*I/5,E^(25*n),3/4+I,Cos[n*x*Pi],y*Sqrt[-5]};
> c2={a/b,r+2/5,a1,,,,,a2};
> c3={1.5,0,Sqrt[3],0,4};
> c4={(r+0.5)/3,3/7,3+Sin[4*x*y]};
> c5={1,2,3,4,5,6}+0.0;
> c6={N[x]};
I need a function IsExact[c] that returns False if
> at least one entry of c is floating, or if it contains one
> floating number; else True. For example, tests on
> c1 and c2 should return True; the others False.
>
my 2 cent:
IsExactQ[x_] := (Length[Cases[x, _Real, Infinity]] == 0)
it doesn't get the last one right, if x is not set to any value. But
this will not be possible, since c6 doesn't know anything about N having
been applied to x...
hth,
albert
===
Subject: Re: IsExact
ExactNumberQ[] may help.
Jens
> Let c be a 1D list of scalar coefficients, numeric or symbolic,
> real or complex. No entry is a list. Examples:
ClearAll[n,x,y,a,a1,a2,b,r];
> c1={1,2*I/5,E^(25*n),3/4+I,Cos[n*x*Pi],y*Sqrt[-5]};
> c2={a/b,r+2/5,a1,,,,,a2};
> c3={1.5,0,Sqrt[3],0,4};
> c4={(r+0.5)/3,3/7,3+Sin[4*x*y]};
> c5={1,2,3,4,5,6}+0.0;
> c6={N[x]};
I need a function IsExact[c] that returns False if
> at least one entry of c is floating, or if it contains one
> floating number; else True. For example, tests on
> c1 and c2 should return True; the others False.
Any simple way to implement this? It should work on V.5.
===
Subject: Re: IsExact
> Let c be a 1D list of scalar coefficients, numeric or symbolic,
> real or complex. No entry is a list. Examples:
ClearAll[n,x,y,a,a1,a2,b,r];
> c1={1,2*I/5,E^(25*n),3/4+I,Cos[n*x*Pi],y*Sqrt[-5]};
> c2={a/b,r+2/5,a1,,,,,a2};
> c3={1.5,0,Sqrt[3],0,4};
> c4={(r+0.5)/3,3/7,3+Sin[4*x*y]};
> c5={1,2,3,4,5,6}+0.0;
> c6={N[x]};
I need a function IsExact[c] that returns False if
> at least one entry of c is floating, or if it contains one
> floating number; else True. For example, tests on
> c1 and c2 should return True; the others False.
Any simple way to implement this? It should work on V.5.
I believe you are already aware that any global value for the symbols
used in the lists may affect the result in one way or another (so the
ClearAll).
Nevertheless, you will have to put a hold on
N[some_symbolic_expression], since after evaluation the element becomes
just some_symbolic_expression. Compare the result from c6 and c7.
Below, the function exactQ accepts a one dimensional list and returns
*True* only if none of its elements has head *Real* or *N*.
In[1]:=
exactQ[(lst_List)?VectorQ] := FreeQ[lst, _Real | N]
ClearAll[n, x, y, a, a1, a2, b, r];
c1 = {1, 2*(I/5), E^(25*n), 3/4 + I, Cos[n*x*Pi],
y*Sqrt[-5]};
c2 = {a/b, r + 2/5, a1, Null, Null, Null, Null, a2};
c3 = {1.5, 0, Sqrt[3], 0, 4};
c4 = {(r + 0.5)/3, 3/7, 3 + Sin[4*x*y]};
c5 = {1, 2, 3, 4, 5, 6} + 0.;
c6 = {N[x]};
c7 = {HoldForm[N[x]]};
exactQ /@ {c1, c2, c3, c4, c5, c6, c7}
{c6, c7}
Out[10]=
{True, True, False, False, False, True, False}
Out[11]=
{{x},{N[x]}}
Implemented and tested on Mathematica 5.2 for Microsoft Windows (June
20, 2005).
--
Jean-Marc
===
Subject: Name retrieval
Is there a way to retrieve a module name from inside the module
upon entry. Something like $ModuleName, if it happen to exist (?).
Is it for an error message telling the user where it happened.
===
Subject: Re: FW: Solving Nonlinear Equations
All [[]] instances can likely be eliminated, and should be. For instance,
since w, S, and delta have the same length, we have
m1 = Total[w S Exp[r-delta]]
Several of your expressions still have unmatched parentheses, though --
including the one for m1. For purposes of FindRoot, though, m1...m4 are
just numbers, so never mind.
Just guessing where parens should and shouldn't go, I get:
Clear[a, b, c, d, m1, m2, m3, m4]
step1 = {m1 == c - d*Exp[1/(2*b^2)]*Sinh[a/b],
m2 == c^2 + (c^2/2) (Exp[2/b^2] Cosh[2 a/b] - 1) -
2 c*d*Exp[1/(2 b^2)]*Sinh[a/b],
m3 == c^3 - 3*c^3*d*Exp[1/(2 b^2)]*Sinh[a/b] +
3*c (d^2/2)*(Exp[2/b^2] Cosh[2 a/b] - 1) + (d^3/
4) (3*Exp[1/(2 b^2)] Sinh[a/b] - Exp[9/(2 b^2)] Sinh[3 a/b]),
m4 == c^4 - 4 (c^3) d*Exp[1/(2 b^2)]*Sinh[a/b] +
3 (c*d)^2*(Exp[2/b^2] Cosh[2 a/b] - 1) + (d^3/4) +
c*d^3 (3*Exp[1/(2 b^2)] Sinh[a/b] - Exp[9/(2 b^2)] Sinh[3 a/b]) +
d^4/8 Exp[8/b^2]*Cosh[4 a/b] - 4*Exp[2/(b^2)] Cosh[2 a/b]} //
Simplify
{c == m1 + d [ExponentialE]^(1/(2 b^2)) Sinh[a/b],
m2 == 1/2 c (c + c [ExponentialE]^(2/b^2) Cosh[(2 a)/b] -
4 d [ExponentialE]^(1/(2 b^2)) Sinh[a/b]),
6 c d^2 + 4 m3 + d^3 [ExponentialE]^(9/(2 b^2)) Sinh[(3 a)/b] ==
4 c^3 + 6 c d^2 [ExponentialE]^(2/b^2) Cosh[(2 a)/b] +
3 d (-4 c^3 + d^2) [ExponentialE]^(1/(2 b^2)) Sinh[a/b],
3 c^2 d^2 + m4 + 4 c^3 d [ExponentialE]^(1/(2 b^2)) Sinh[a/b] +
c d^3 [ExponentialE]^(9/(2 b^2)) Sinh[(3 a)/b] ==
c^4 + d^3/
4 + (-4 + 3 c^2 d^2) [ExponentialE]^(2/b^2) Cosh[(2 a)/b] +
1/8 d^4 [ExponentialE]^(8/b^2) Cosh[(4 a)/b] +
3 c d^3 [ExponentialE]^(1/(2 b^2)) Sinh[a/b]}
Notice that c is given, immediately, in terms of other variables, so the
system reduces in size:
cRule = First@ToRules@First@step1;
step2 = DeleteCases[step1 /. cRule, True] // Simplify;
A little experimentation now shows that each equation of step2 can be
solved for d:
dSolns = Solve[#, d] & /@ step2;
Length /@ dSolns
{2, 4, 4}
Ten partial solutions!
Inspection of these (with your knowledge of the actual problem) may allow
you to eliminate some, but the test is whether one solution solves ALL
THREE equations in step2 -- which I doubt, but you may as well try, with
soln2 = Solve[step2, d]
I didn't let this run to completion, but if you let it run and it
succeeds, you'll have a rule for setting d, and the system is down to two
equations (step3). Then you can try to solve for a or b to get further, or
use the new dRule to initialize for FindRoot.
If Solve doesn't succeed, you can still use the two solutions from step2's
first equation as starting points for d in FindRoot. Solve's failure may
mean that NO overall solution exists, but then again, FindRoot may find
something Solve cannot.
Good luck!!
Bobby
> Let me fill the missing gaps on my question:
> m1= Sum[w[[i]]S[[i]]Exp[(r-delta[[i]]),{i,Length[S]}];
> m2=
>
Sum[w[[i]]w[[j]]S[[i]]S[[j]]Exp[(2r-delta[[i]]-delta[[j]]+rho[[i,j]]sig[[i]]
> sig[j]])T,{i,Length[S]},{j,Length[S]}];
> m3=
>
Sum[w[[i]]w[[j]]w[[k]]S[[i]]S[[j]]S[[k]]Exp[(3r-delta[[i]]-d[[j]]-delta[[k]]
> +rho[[i,j]]sig[[i]]sig[j]]+rho[[i,k]]sig[[i]]sig[k]]+rho[[j,k]]sig[[j]
]sig[k
> ]])T,{i,Length[S]},{j,Length[S]},{k,Length[S]}];
> m4=
>
Sum[w[[i]]w[[j]]w[[k]]w[[l]]S[[i]]S[[j]]S[[k]]S[[l]]Exp[(4r-delta[[i]]-d[[j]
>
]-delta[[k]]-delta[[l]]+rho[[i,j]]sig[[i]]sig[j]]+rho[[i,k]]sig[[i]]sig[k]]+
> rho[[j,k]]sig[[j]]sig[k]]+rho[[i,l]]sig[[i]]sig[l]]+rho[[j,l]]sig[[j]]
sig[l]
> ]+rho[[k,l]]sig[[k]]sig[l]])T,{i,Length[S]},{j,Length[S]},{k,Length[S]
},{l,L
> ength[S]}];
> With
>
r=0.063;T=1;S=Table[1,{i,7}];w={0.1,0.15,0.15,0.1,0.05,0.2,0.25};delta={0.01
>
69,0.0136,0.0239,0.0362,0.0192,0.0081,0.0166};sig={0.1155,0.1453,0.2068,0.14
>
62,0.1799,0.1559,0.1568};rho={{1,0.35,0.1,0.27,0.04,0.17,0.71},{0.35,1.,0.39
>
,0.27,0.5,-0.08,0.15},{0.1,0.39,1.,0.53,0.7,-0.23,0.9},{0.27,0.27,0.53,1.,0.
> 46,-0.22,0.32},{0.04,0.5,0.7,0.46,1.,-0.29,0.13},{0.17,-0.08,-0.23,-0.
22,-0.
> 29,1.,-0.03},{0.71,0.15,0.09,0.32,0.13,-0.03,1.}};
> FindRoot[{m1==c-d*Exp[1/(2*b^2)]*Sinh[a/b],
>> m2==c^2+(c^2/2)(Exp[2/b^2]Cosh[2a/b]-1)-2c*d*Exp[1/(2b^2)]*Sinh[a=
/b],
> m3==c^3-3*c^3*d*Exp[1/(2b^2)]*Sinh[a/b],+3*c(d^2/2))*(Exp[2/b^2]Co=
sh[2a/b]-1
>> )+(d^3/4)(3*Exp[1/(2b^2)]Sinh[a/b]-Exp[9/(2b^2)]Sinh[3a/b]),
> m4==c^4-4(c^3)d*Exp[1/(2b^2)]*Sinh[a/b]+3(c*d)^2))*(Exp[2/b^2]Cosh=
[2a/b]-1)+
> (d^3/4)+c*d^3(3*Exp[1/(2b^2)]Sinh[a/b]-Exp[9/(2b^2)]Sinh[3a/b])+(d^4/8=
)(Exp[
>> 8/(b^2)]*Cosh
>> [4a/b]-4*Exp[2/(b^2)]Cosh[2a/b]),{{a,-1.},{b,1.},{c,1.},{d,0.05}}] gi=
ves
> {a->12.1929,b->9.05339,c->0.33727,d->0.393214}. I know that these are
> coorrect roots because the results of the underlying problem tally wit=
h =
> what
> I expect. I must emphasise that the initial values of a, b, c, and d =
> were a
> product of trial and error. However, when I change inputs to
> T=5;r=0;S={100,100,100,100};w={0.25,0.25,0.25,0.25};delta={0=
,0,0,0};sig={0.4
> ,0.4,0.4,
> 0.4};rho={{1.0,0.5,0.5,0.5},{0.5,1.0,0.5,0.5},{0.5,0.5,1.0,0.5},{0.5=
,0.5,0.5
> ,1.0}} I just can't seem be lucky to hit the jackpot initial values.=
My
> main point is how do I get input initial values without relying on tri=
al =
> and
> error, or what is the alternative approach?
> P.S. (I'm aware about the potential confusion that C, and D are likel=
y =
> to
> cause on the system as global variables, I apologise for not using the=
> actual variables used)
> MD Biyana
-----Original Message-----
===
> Subject: Re: Solving Nonlinear Equations
That's not a legal syntax (mismatched brackets, etc.), and if it were,=
=
> you
> didn't give the initial values or the values of m1, m2, m3, and m4, so=
...
> what can we do?
In addition, C and D are system-defined symbols. FindRoot probably use=
s =
> D to
> take derivatives, so you're just asking for trouble with variable name=
s =
> like
> that. I never, never, EVER start one of my own variables with a capita=
l;
> that makes it obvious whose symbol it is.
Bobby
>> I'm using Mathematica V6.0.1 and I have a system of 4 nonlinear =
>> equations
>> which I'm trying to solve using FindRoot:
>> FindRoot[{m1==C-D*Exp[1/(2*B^2)]*Sinh[A/B],
>> m2==C^2+(D^2/2)(Exp[2/B^2]Cosh[2A/B]-1)-2C*D*Exp[1/(2B^2)]*Sinh[A=
/B],
> m3==C^3-3*C^3*D*Exp[1/(2B^2)]*Sinh[A/B],+3*C(D^2/2))*(Exp[2/B^2]Co=
sh[2A/B]-1
>> )+(D^3/4)(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B]),
> m4==C^4-4(C^3)D*Exp[1/(2B^2)]*Sinh[A/B]+3(C*D)^2))*(Exp[2/B^2]Cosh=
[2A/B]-1)+
> (D^3/4)+C*D^3(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B])+(D^4/8=
)(Exp[
>> 8/(B^2)]*Cosh
> [4A/B]-4*Exp[2/(B^2)]Cosh[2A/B]),{{A,initA},{B,initB},{C,initC},{D,ini=
tD}}]
>> I get the message FindRoot::cvmit : Failed to converge to the =
>> requested
>> accuracy... which I suspect is a result of initial values of A, B,C,=
>> and D.
>> What trick can one use to get accepatble initial values?
>> MD Biyana
>> ********************
>> Nedbank Limited Reg No 1951/000009/06. The following link displays th=
e
>> names of the Nedbank Board of Directors and Company Secretary.
>> [ http://www.nedbank.co.za/terms/DirectorsNedbank.htm ]
>> This email is confidential and is intended for the addressee only. Th=
e
>> following link will take you to Nedbank's legal notice.
>> [ http://www.nedbank.co.za/terms/EmailDisclaimer.htm ]
>> ********************
>
-- =
DrMajorBob@bigfoot.com
===
Subject: FW: Solving Nonlinear Equations
Let me fill the missing gaps on my question:
m1= Sum[w[[i]]S[[i]]Exp[(r-delta[[i]]),{i,Length[S]}];
m2=
Sum[w[[i]]w[[j]]S[[i]]S[[j]]Exp[(2r-delta[[i]]-delta[[j]]+rho[[i,j]]sig[[i]]
sig[j]])T,{i,Length[S]},{j,Length[S]}];
m3=
Sum[w[[i]]w[[j]]w[[k]]S[[i]]S[[j]]S[[k]]Exp[(3r-delta[[i]]-d[[j]]-delta[[k]]
+rho[[i,j]]sig[[i]]sig[j]]+rho[[i,k]]sig[[i]]sig[k]]+rho[[j,k]]sig[[j]]sig[k
]])T,{i,Length[S]},{j,Length[S]},{k,Length[S]}];
m4=
Sum[w[[i]]w[[j]]w[[k]]w[[l]]S[[i]]S[[j]]S[[k]]S[[l]]Exp[(4r-delta[[i]]-d[[j]
]-delta[[k]]-delta[[l]]+rho[[i,j]]sig[[i]]sig[j]]+rho[[i,k]]sig[[i]]sig[k]]+
rho[[j,k]]sig[[j]]sig[k]]+rho[[i,l]]sig[[i]]sig[l]]+rho[[j,l]]sig[[j]]sig[l]
]+rho[[k,l]]sig[[k]]sig[l]])T,{i,Length[S]},{j,Length[S]},{k,Length[S]},{l,L
ength[S]}];
With
r=0.063;T=1;S=Table[1,{i,7}];w={0.1,0.15,0.15,0.1,0.05,0.2,0.25};delta={0.01
69,0.0136,0.0239,0.0362,0.0192,0.0081,0.0166};sig={0.1155,0.1453,0.2068,0.14
62,0.1799,0.1559,0.1568};rho={{1,0.35,0.1,0.27,0.04,0.17,0.71},{0.35,1.,0.39
,0.27,0.5,-0.08,0.15},{0.1,0.39,1.,0.53,0.7,-0.23,0.9},{0.27,0.27,0.53,1.,0.
46,-0.22,0.32},{0.04,0.5,0.7,0.46,1.,-0.29,0.13},{0.17,-0.08,-0.23,-0.22,-0.
29,1.,-0.03},{0.71,0.15,0.09,0.32,0.13,-0.03,1.}};
FindRoot[{m1==c-d*Exp[1/(2*b^2)]*Sinh[a/b],
> m2==c^2+(c^2/2)(Exp[2/b^2]Cosh[2a/b]-1)-2c*d*Exp[1/(2b^2)]*Sinh[a/b],
>
m3==c^3-3*c^3*d*Exp[1/(2b^2)]*Sinh[a/b],+3*c(d^2/2))*(Exp[2/b^2]Cosh[2a/b]-1
> )+(d^3/4)(3*Exp[1/(2b^2)]Sinh[a/b]-Exp[9/(2b^2)]Sinh[3a/b]),
>
m4==c^4-4(c^3)d*Exp[1/(2b^2)]*Sinh[a/b]+3(c*d)^2))*(Exp[2/b^2]Cosh[2a/b]-1)+
>
(d^3/4)+c*d^3(3*Exp[1/(2b^2)]Sinh[a/b]-Exp[9/(2b^2)]Sinh[3a/b])+(d^4/8)(Exp[
> 8/(b^2)]*Cosh
> [4a/b]-4*Exp[2/(b^2)]Cosh[2a/b]),{{a,-1.},{b,1.},{c,1.},{d,0.05}}] gives
{a->12.1929,b->9.05339,c->0.33727,d->0.393214}. I know that these are
coorrect roots because the results of the underlying problem tally with
what
I expect. I must emphasise that the initial values of a, b, c, and d were a
product of trial and error. However, when I change inputs to
T=5;r=0;S={100,100,100,100};w={0.25,0.25,0.25,0.25};delta={0,0,0,0};sig={0.4
,0.4,0.4,
0.4};rho={{1.0,0.5,0.5,0.5},{0.5,1.0,0.5,0.5},{0.5,0.5,1.0,0.5},{0.5,0.5,0.5
,1.0}} I just can't seem be lucky to hit the jackpot initial values. My
main point is how do I get input initial values without relying on trial
and
error, or what is the alternative approach?
P.S. (I'm aware about the potential confusion that C, and D are likely to
cause on the system as global variables, I apologise for not using the
actual variables used)
MD Biyana
-----Original Message-----
===
Subject: Re: Solving Nonlinear Equations
That's not a legal syntax (mismatched brackets, etc.), and if it were, you
didn't give the initial values or the values of m1, m2, m3, and m4, so...
what can we do?
In addition, C and D are system-defined symbols. FindRoot probably uses D
to
take derivatives, so you're just asking for trouble with variable names
like
that. I never, never, EVER start one of my own variables with a capital;
that makes it obvious whose symbol it is.
Bobby
I'm using Mathematica V6.0.1 and I have a system of 4 nonlinear equations
> which I'm trying to solve using FindRoot:
> FindRoot[{m1==C-D*Exp[1/(2*B^2)]*Sinh[A/B],
> m2==C^2+(D^2/2)(Exp[2/B^2]Cosh[2A/B]-1)-2C*D*Exp[1/(2B^2)]*Sinh[A/B],
>
m3==C^3-3*C^3*D*Exp[1/(2B^2)]*Sinh[A/B],+3*C(D^2/2))*(Exp[2/B^2]Cosh[2A/B]-1
> )+(D^3/4)(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B]),
>
m4==C^4-4(C^3)D*Exp[1/(2B^2)]*Sinh[A/B]+3(C*D)^2))*(Exp[2/B^2]Cosh[2A/B]-1)+
>
(D^3/4)+C*D^3(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B])+(D^4/8)(Exp[
> 8/(B^2)]*Cosh
>
[4A/B]-4*Exp[2/(B^2)]Cosh[2A/B]),{{A,initA},{B,initB},{C,initC},{D,initD}}]
> I get the message FindRoot::cvmit : Failed to converge to the
requested
> accuracy... which I suspect is a result of initial values of A, B,C,
> and D.
> What trick can one use to get accepatble initial values?
> MD Biyana
********************
> Nedbank Limited Reg No 1951/000009/06. The following link displays the
> names of the Nedbank Board of Directors and Company Secretary.
> [ http://www.nedbank.co.za/terms/DirectorsNedbank.htm ]
> This email is confidential and is intended for the addressee only. The
> following link will take you to Nedbank's legal notice.
> [ http://www.nedbank.co.za/terms/EmailDisclaimer.htm ]
> ********************
>
--
DrMajorBob@bigfoot.com
********************
Nedbank Limited Reg No 1951/000009/06. The following link displays the names
of the Nedbank Board of Directors and Company Secretary. [
http://www.nedbank.co.za/terms/DirectorsNedbank.htm ]
This email is confidential and is intended for the addressee only. The
following link will take you to Nedbank's legal notice. [
http://www.nedbank.co.za/terms/EmailDisclaimer.htm ]
********************
===
Subject: Position of tooltip?
The default position of the tooltip puts the text underneath
my mouse-cursor and I can't make out the text.
This can be helped a little by using
Tooltip[{x,y},label,LabelStyle->{Large}]
But, what I would prefer is to include a graphics directive
like Offset[{-36,-36}] into the LabelStyle....
Craig Carter
===
Subject: Re: IsExact
This assumes, though, that you don't use variables such as x[1.]
Bhuvanesh,
Wolfram Research
===
Subject: Re: ParametricPlot3D from 5.2 to 6.0
With the following notebook method order seems to have changed. I didn't managed to obtain a similar
>rendering with the star 3D surface.
Can someone help to find how to describe the star the same way again ?
--
>Fran=E7ois LE COAT
>Author of Eureka 2.12 (2D Graph Describer, 3D Modeller)
>
>
I like the effect the Max has of speeding up the output.
This code works in 5.x Mathematica here: ( I don't have 6.0: I doubt iy
will run on my older operating system )
xmin := 0
xmax := 2*Pi
ymin := 0
ymax := Pi
ro[t_, p_] := Max[(1 - 3*Sin[n*p]*Cos[5*t]), 0]
xxx[t_, p_] := ro[t, p]*Sin[p]*Cos[t]
yyy[t_, p_] := ro[t, p]*Sin[p]*Sin[t]
zzz[t_, p_] := ro[t, p]*Cos[p]
Table[ParametricPlot3D[{yyy[t, p], -xxx[t, p], zzz[t, p]}, {t, xmin,
xmax}, {
p, ymin, ymax}, PlotPoints -> {
100, 50}, Axes -> False, Boxed -> False, PlotRange -> All], {n, 1, 5}]
FullSimplify[ExpandAll[xxx[t, p]^2 + yyy[t, p]^2 + zzz[t, p]^2]]
Coming from the FullSimplify:
Cos[5*t]=Sin[5*t+Pi/2]
Your star like output is a fake
as these are rose like parametrics.
Code for a true star-like parametric from :
http://local.wasp.uwa.edu.au/~pbourke/surfaces_curves/barthdecic/index.html
Clear[x, y, z, p, a]
a = 1;
p = (1 + Sqrt[5])/2;
x = r*Sin[p0]*Cos[t];
y = r*Sin[p0]*Sin[t];
z = r*Cos[p0];
implicit = ExpandAll[8 (x^2 - p^4 y^2) (y^2 - p^4 z^2) (z^2 - p^4 x^2)
(x^4 +
y^4 + z^4 - 2 x^2 y^2 - 2 x^2 z^2 - 2 y^2 z^2) +
a (3 + 5 p) (x^2 + y^2 + z^2 - a)^2*(x^2 + y^2 + z^2 - (2 - p) a)^2];
Clear[p0, t];
(* flat radial version*)
Table[Plot3D[-Re[r] /. Solve[implicit == 0 , r][[n]], {p0, 0, Pi}, {t, 0,
2*
Pi}], {n, 1, 10}];
(* projection onto sphere as radial*)
Clear[ro, xxx, yyy, zzx]
xmin := 0
xmax := 2*Pi
ymin := 0
ymax := Pi
ro[t_, p0_] := -Re[r] /. Solve[implicit == 0 , r][[n]]
xxx[t_, p0_] := ro[t, p0]*Sin[p0]*Cos[t]
yyy[t_, p0_] := ro[t,
p0]*Sin[p0]*Sin[t]
zzz[t_, p0_] := ro[t, p0]*Cos[p0]
Table[ParametricPlot3D[{yyy[t, p0], xxx[t, p0], zzz[t, p0]}, {t, xmin,
xmax},
{p0, ymin, ymax}, PlotPoints -> {40, 20},
PlotRange -> All], {n, 1, 10}]
It is kind of clunky and doesn't work very well,
but it is a better real star than yours apparently.
Roger Bagula
===
Subject: Re: ParametricPlot3D from 5.2 to 6.0
If I use this form with the star 3D surface, that's because
it is generated with the help from my Eureka 2.12 software. If
you look at the documentation
the system of axis is right handed like it is used in French
mathematics, at the opposite of Mathematica's system of axis being
left handed.
Some other 3D shapes are there
--
Fran=E7ois LE COAT
Author of Eureka 2.12 (2D Graph Describer, 3D Modeller)
> It matters little in THIS case, but Set is faster than SetDelayed,
the functions are not needed, and I see no reason to switch x and y or
change signs, so on principal I'd write it as
>
> rho = Max[1 - 3 Sin[2 p] Sin[5 t + Pi/2], 0];
> x = rho Sin[p] Cos[t];
> y = rho Sin[p] Sin[t];
> z = rho Cos[p];
> ParametricPlot3D[{x, y, z}, {t, 0, 2 [Pi]}, {p, 0, [Pi]},
> PlotPoints -> {11, 5}, Mesh -> All, MaxRecursion -> 0,
> PlotRange -> All, NormalsFunction -> None]
>
> Anyway, I like the more accurate flower petal version:
>
> ParametricPlot3D[{x, y, z}, {t, 0, 2 [Pi]}, {p, 0, [Pi]},
> PlotRange -> All, PerformanceGoal -> Quality]
>
>>
>> xmin := 0
>> xmax := 2*Pi
>> ymin := 0
>> ymax := Pi
>> ro[t_, p_] := Max[1 - 3*Sin[2*p]*Sin[5*t + Pi/2], 0]
>> xxx[t_, p_] := ro[t, p]*Sin[p]*Cos[t]
>> yyy[t_, p_] := ro[t, p]*Sin[p]*Sin[t]
>> zzz[t_, p_] := ro[t, p]*Cos[p]
>> ParametricPlot3D[{yyy[t, p], -xxx[t, p], zzz[t, p]}, {t, xmin, xmax},=
>> {p,ymin, ymax}, PlotPoints -> {11, 5}, Mesh -> All, MaxRecursion ->=
0,
>> PlotRange -> All, NormalsFunction -> None]
>>
> try:
>
> xmin := 0
> xmax := 2*Pi
> ymin := 0
> ymax := Pi
> ro[t_, p_] := Max[1 - 3*Sin[2*p]*Sin[5*t + Pi/2], 0]
> xxx[t_, p_] := ro[t, p]*Sin[p]*Cos[t]
> yyy[t_, p_] := ro[t, p]*Sin[p]*Sin[t]
> zzz[t_, p_] := ro[t, p]*Cos[p]
> ParametricPlot3D[{yyy[t, p], -xxx[t, p], zzz[t, p]}, {t, xmin,
> xmax}, {p, ymin, ymax}, PlotPoints -> {11, 5}, MaxRecursion -> 0,=
> PlotRange -> All, PerformanceGoal -> Speed]
>
>> With the following notebook
>> I had the following rendering
> using Mathematica v. <= 5.2. With Mathematica 6.0 the interpolati=
on
>> method order seems to have changed. I didn't managed to obtain a
similar
>> rendering with the star 3D surface.
>>
>> Can someone help to find how to describe the star the same way
again ?
===
Subject: tooltips and mouseover in Histograms, PieCharts, BarPlots?
Tooltips doesn't seem to be integrated into Histograms and
Barcharts. Can anyone suggest a simple way to get a
mouseover/tooltip to show when the mouse is in a particular
region (without building everything from scratch with
graphics objects...)
For example, in a pie chart of shoe sizes, it would be
interesting to have a mouseover indicate the names of those
people in each category...
===
Subject: Re: Style in Manipulate
> Re Mathematica 6.0.1 under WinXP.
The code below produces red text that is neither italicized nor 30-
> point. Yet I'm following the helptext for Style (Example #2).
> Bruce
Manipulate[
> Grid@{{ Text@Style[StringForm[Factors of ``, n],Red,Italic,30]},
> {Divisors@n}},
{n,{2,5,6,8,12,18,45000},ControlType->Setter},
> TrackedSymbols->{n}]
>
Bruce ... The code works correctly on my MacBook Pro Core Duo
Syd Geraghty
In[2]:= $Version
Out[2]= 6.0 for Mac OS X x86 (32-bit) (June 19, 2007)
In[3]:= $System
Out[3]= Mac OS X x86 (32-bit)
===
Subject: Re: Style in Manipulate
It works for me, also under Windows XP. The Factors of .... part is
red, italicized, and 30-point; the list of factors is not.
> Re Mathematica 6.0.1 under WinXP.
The code below produces red text that is neither italicized nor 30-point.
Yet I'm following the helptext for Style (Example #2).
> Bruce
Manipulate[
> Grid@{{ Text@Style[StringForm[Factors of ``,
n],Red,Italic,30]},{Divisors@n}},
{n,{2,5,6,8,12,18,45000},ControlType->Setter},
> TrackedSymbols->{n}]
>
--
Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
===
Subject: Re: Style in Manipulate
> Re Mathematica 6.0.1 under WinXP.
The code below produces red text that is neither italicized nor 30-point.
Yet I'm following the helptext for Style (Example #2).
> Bruce
Manipulate[
> Grid@{{ Text@Style[StringForm[Factors of ``,
n],Red,Italic,30]},{Divisors@n}},
{n,{2,5,6,8,12,18,45000},ControlType->Setter},
> TrackedSymbols->{n}]
Bruce,
I do have a clue on what happened on your system, but the very same code
on my system displays big red italic letters! Have a look at
http://homepages.nyu.edu/~jmg336/mathematica/BruceColletti.png
or
http://homepages.nyu.edu/~jmg336/mathematica/BruceColletti.pdf
--
Jean-Marc
===
Subject: Drawing tick labels without ticks
Can anyone suggest a simple method for keeping tick labels in a graph
without also drawing axes or the ticks themselves? As an example,
ListPlot[{1, 2, 3, 4, 5}, AxesStyle -> Opacity[0], TicksStyle ->
Opacity[1]]
comes close to what I'm after, but doesn't quite get there. I'd like
for nothing to appear in the plot except the data points and the tick
labels.
There doesn't seem to be a way to target specifically the tick labels
without also afftecting the tick marks or the axes. LabelStyle will
target tick labels, but it has a lower precedence than both AxesStyle
and TickStyle, so if I use either of those options to turn off the
axes and ticks, it will also turn off labels.
It's my hope that there is a simple solution that I'm overlooking. If
the only way around this is to go through a complicated process of
extracting tick labels from a dummy graphic and then pasting them in
for your help!
===
Subject: Re: JLink
Mathematica 6 comes with an outdated Java. Therefore, it may be
necessary to use a newer version. A clumsy solution is to change the
Java in the installation. However, there was a better method that worked
before v6:
InstallJava takes an option CommandLine that specifies a command line
to start Java. In version 6 this does no more work correctly. If I say:
InstallJava[CommandLine->name of new java]
the old Java of mathematica is loaded, despite the option. However, if I
prevent mathematica to find the java executable by renaming the
corresponding folder, the correct java is now loaded.
Daniel
Daniel,
Java is now launched at startup time, so when you call
InstallJava[CommandLine->...] J/Link just returns the current Java
link. What you need to do is force Java to restart with your desired
options:
ReinstallJava[CommandLine->...]
Incidentally, the pre-launch of Java has been anticipated for a long
time, so the J/Link User Guide has been warning about it for several
years: Programmers should not assume that they have the ability to
control the launch of the Java runtime, as it might already be
running. If for some reason you absolutely must apply options to
control the launch of the Java runtime, use ReinstallJava instead of
InstallJava.
--Todd
===
Subject: Bad imports of data files -- extra empty lists showing up?
I noticed this problem the other day, on different data sets, not
thinking much of it. Then, when it cropped up again, I started to get
worried. I'm really not sure how to think about it, and so am requesting
some
advice from the experts. I have tried rewriting this message a few times,
and
can't figure out how to state the problem very clearly, so please bear with
me.
I know that attachments aren't allowed, but my problem is that if I
copy-and-paste the troublesome dataset into this message (I've tried),
whatever formatting is causing the problem is lost. For example, I'll paste
the data into this message, then copy it from the message to a text file,
then save that and import it into Mathematica. The problem disappears. So if
anyone is curious, perhaps they can email me directly and I can send some
sample bad datasets.
The data was taken using a VB program on a windows machine, and this
version of Mathematica is running on a linux machine. However, 1) the
problem
crops up in perhaps 10 - 25% of the files so far, ALL of which were
originally produced on a windows machine; 2) the problem does not occur in
the same place in each file, IF it occurs at all; 3) if I re-do the import,
and the file imports incorrectly, the problems occur at the same places in
the file; 4) if I remove portions of the file (using a text editor,
perhaps),
the problems may occur in different spots, or the problems may disappear.
What I've tried:
Import the data sets using Import[file name, Table].
Typically
the datasets have .txt or .dat extensions. Some files consist of
number
triplets; some of doublets; they're all TAB-separated.
Expected behavior: the data is imported correctly; files with n lines of
m
numbers per line should show up as tables consisting of n length-m lists.
This is what happens most of the time.
Actual behavior: A given file will import correctly, but with occasional
empty lists interspersed in among the data points. For example, a 2*10^5
length dataset has empty lists ( {} ) at seven different places in it. A
10^4
length dataset has only one empty list.
So far, I've just been importing the datasets, searching for lines which
do
not contain the expected doublets or triplets, and just deleting those
lines.
But that's obviously extra work (even if Mathematica does it for me). I've
been able to cut some of these example data files down a bit, and still
retain the bad behavior. If anyone can shed some light on this for me,
I'd
much appreciate it!
--
Curtis Osterhoudt
cfo@remove_this.lanl.and_this.gov
PGP Key ID: 0x4DCA2A10
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
===
Subject: Exporting numbered files: apparent hangup?
If a recent one-time experiment was yielding valid results, an attempt
to Export a set of sequentially numbered image files using
Do[
g=DensityPlot[ <>];
Export[Fresnel reflection<>ToString[PaddedForm[k, 3,
NumberPadding -> {0, }]]<>.jpg, g],
{k, kmin, kmax}];
ran more or less forever (in 5.2), producing no error messages, but also
no output. Changing the input to
Do[
g=DensityPlot[ <>];
Export[Fresnel reflection<>ToString[PaddedForm[k, 3,
NumberPadding -> {0, }]], g, JPG],
{k, kmin, kmax}];
worked just fine, however.
===
Subject: Cell brackets on left ?
A colleague new to Mathematica asked if there was any way to put the
cell brackets on the left side of the notebook instead of the right.
He was having difficulty reading a title on the left and then moving
across a large expanse of white space to find the corresponding
bracket on the right to open it up, and asked if it wouldn't make more
sense to have the brackets on the left where they would be close to
the content of the cell. After browsing around the options inspector
and stylesheet editor, I'm pretty sure there isn't an option to do
that, but I'm wondering if that wouldn't be a useful option to have.
Mike Burns
===
Subject: Re: FindFit and complex function?
>I have ran into a problem of fitting my experimental data points to
>a function in mathematica. The function comes from a solution of
>five algebraic equations with 5 variables. Very straight forward.
>Unfortunately cubic roots are present in the solution so when the
>function is evaluated at fixed parameters it always return a small
>imaginary part with the real part. The real parts are quite
>meaningful and imaginary parts are extremely small. For all
>practical purposes I can just drop the imaginary part. When I build
>a model function, which is just a linear combination of 5 solutions,
>I can evaluate it with fixed parameters and see that it describes my
>experimental points rather well. But FindFit fails to perform a
>search always stopping at the starting value. Any ideas on how to
>either drop imaginary part of the function completely or make
>FindFit work with a function that returns complex numbers?
It isn't entirely clear to me what expression you are trying to
fit your data to. It sounds like you may be using a polynomial.
If so, that tends to be numerically unstable. Try replacing the
polynomial with a linear combination of Chebyshev functions.
This will be much more stable and may eliminate your problems
with spurious imaginary parts.
--
To reply via email subtract one hundred and four
===
Subject: problem with parsing InputForm scientific notation (eg. 3.`*^-7)
Can anyone confirm this report?
Steps to reproduce:
1. Enter 3.`*^-7 (without quotation marks) into an Input cell and
evaluate it.
2. Go back to the Input cell, put your cursor at the beginning and
enter RealDigits[
3. Hit the End key, type ] and then re-evaluate the cell, which by
now reads RealDigits[3.`*^-7], but don't enter that directly.
I have encountered other errors where InputForm messes up the syntax
checker, but I haven't been able to make a small reproducible example
like this one.
Version 6.0.1 on MS Windows XP SP2
--
http://chris.chiasson.name/
===
Subject: Improper Integral & Mathematica
Hi all ! :-)
how to solve:
Integrate[(e^x) / (1 + e^(2x)), {x, - Infinity, + Infinity }]
using Mathematica? I'm trying e^x = t but won't work...
TNX!
===
Subject: Coordinate problems with Inset (and a bug)
**Part 1 of post **
Here is a problem I used to have with Mathematica 5.2 and the
Rectangle[coord,graphics] function to draw insets in a graphics. This
syntax is not working anymore in Mathematica 6, it has been replaced by
Inset,
which has much more powerful placement capabilities. Nevertheless, I
still cannot do what I want.
So, here we go: I plot data, using ListLinePlot, ususally with Frame-
>True, Background->Gray, which represents the timecourse of
experimental biological data. At certain timepoints something happens
in the experiment, e.g. I show a light for 1 second. I would like to
indicate this event in the plot by plotting a white rectangle under
the data trace during the appropriate time (as a Prolog).
The problem is: The x-coordinates of the rectangle are absolute
coordinates (the time when the light goes on and off), while the y-
coordinates should span the whole plot, or the bottom 1/5th of the
plot, and are therefor relative, or scaled, coordinates. I cannot
figure out how to combine absolute coordinates in one dimension with
Scaled[] coordinates in the other dimension.
I know that I can get around this problem by using one of two tricks:
either pre-computing the range of my data, and using absolute y-
coordinates (min and max of the data). Alternatively I can use
standard absolute y-coordinates that go way beyond the range of my
data, then only the part within the plotregion is shown, and it LOOKS
the way I want (it just seems like less than elegant solution).
**Part 2 of post**
Now to an apparent bug in Inset:
data=Range[20]/2;
rect=Graphics[Rectangle[]];
(* This works fine: *)
ListLinePlot[data, Frame -> True,
Prolog -> Inset[rect, {2, 5}, {0, 0}, {2, 2}]]
Notice that a rectangle of size 2x2 is drawn, with its left bottom
edge ({0,0}) placed at position {2,5} in the plot.
According to the help file of Inset:
y coordinates can be numbers, Automatic or Top, Center, Bottom,
Baseline or Axis.
The y-coordinate 5 is roughly in center of the plot, so I thought
the following should work and produce roughly the same result (but it
doesn't):
(* Here, no rectangle is drawn: *)
ListLinePlot[data, Frame -> True,
Prolog -> Inset[rect, {2, Center}, {0, 0}, {2, 2}]]
The reason is that now, for some reason, Inset interprets the x-
coordinate as a relative (scaled) coordinate, so the rectangle
vanishes off to the right. In order to see the rectangle, the x-
coordinate has to be a fraction now. So, this brings back the
rectangle:
ListLinePlot[data, Frame -> True,
Prolog -> Inset[rect, {.15, Center}, {0, 0}, {2, 2}]]
Is this a bug or a feature?????
thomas
===
Subject: version 6 Plot3D exporting results in HUGE files
I did the following in v6.0.1 (which I will refer to as v6 hereafter):
generated a surface using the Plot3D command, clicked on the resulting
surface graphic, then Save Selection As > EPS.
The resulting EPS file was over 4400 KB!
I compiled the same code in v5.2 using the exact same steps. The
resulting EPS file was 700 KB.
This is immaterial except now when I include the EPS files in a LaTeX
document and convert the dvi file to either PS or PDF, the pages with
v6 generated surfaces render EXTREMELY slowly while the v5.2 generated
surfaces render very quickly.
Has anyone noticed the same thing? This is very disappointing for
someone who wants to use Mathematica to generate high quality graphics
for inclusion in technical documents.
I am running Mathematica v6.0.1 on Windows XP on a Dell Latitude D800.
FYI, the same behavior occurs in v6 if I Save As>PDF instead of going
the EPS route.
JD
===
Subject: Add custom points to automatically generated Ticks?
I have an ordinary plot like Plot[x^2,{x,0,10}] and I would like to
add to the x-axis one or two special points , to point out where
certain parameters are located. How to do this in a graphically
attractive way? I have tried to use Epilog with a (vertical) Line and
a Text, but I can't get the Text to be displayed properly below the x-
axis.
I have read about Ticks and I was wondering whether there is an easy
way to use that, were easy would mean that I don't have to specify
the whole set of Ticks manually, but can first make a plot without any
additional points, then somehow subtract from there the Ticks
generated by Mathematica, then add one or two custum ones and finally
create a new plot with those adjusted Ticks.
Any hints?
===
Subject: Re: FindFit and complex function?
Post working code to get better answers, but Re or Chop might help.
Bobby
> Hello everyone,
I have ran into a problem of fitting my experimental data points to a
> function in mathematica.
> The function comes from a solution of five algebraic equations with 5
> variables. Very straight forward. Unfortunately cubic roots are present
> in the solution so when the function is evaluated at fixed parameters it
> always return a small imaginary part with the real part. The real parts
> are quite meaningful and imaginary parts are extremely small. For all
> practical purposes I can just drop the imaginary part. When I build a
> model function, which is just a linear combination of 5 solutions, I can
> evaluate it with fixed parameters and see that it describes my
> experimental points rather well. But FindFit fails to perform a search
> always stopping at the starting value. Any ideas on how to either drop
> imaginary part of the function completely or make FindFit work with a
> function that returns complex numbers?
Michael
--
DrMajorBob@bigfoot.com
===
Subject: Re: FindFit and complex function?
SetOptions[Roots, Cubics -> False, Quartics -> False];
before Solve worked like a charm. FindFit works with produced model no
problem.
All best,
Michael
> Hello everyone,
>> I have ran into a problem of fitting my experimental data points to a
>> function in mathematica.
>> The function comes from a solution of five algebraic equations with 5
>> variables. Very straight forward. Unfortunately cubic roots are
>> present in the solution so when the function is evaluated at fixed
>> parameters it always return a small imaginary part with the real
>> part. The real parts are quite meaningful and imaginary parts are
>> extremely small. For all practical purposes I can just drop the
>> imaginary part. When I build a model function, which is just a linear
>> combination of 5 solutions, I can evaluate it with fixed parameters
>> and see that it describes my experimental points rather well. But
>> FindFit fails to perform a search always stopping at the starting
>> value. Any ideas on how to either drop imaginary part of the function
>> completely or make FindFit work with a function that returns complex
>> numbers?
>> Michael
>>
> Assuming that you are using Solve to solve your equations, you can set
> an option to return Root objects instead of radicals. Root objects can
> be numericalized more reliably than radicals. For example:
In[136]:= Solve[x^3 - 3 x - 1 == 0, x] // N
Out[136]= {{x - 1.87939+ 0. [ImaginaryI]}, {x -> -1.53209 +
> 1.11022*10^-16 [ImaginaryI]}, {x -> -0.347296 +
> 1.11022*10^-16 [ImaginaryI]}}
Now, set options for Roots and try again:
In[137]:= SetOptions[Roots, Cubics -> False, Quartics -> False];
In[138]:= Solve[x^3 - 3 x - 1 == 0, x] // N
Out[138]= {{x -> -1.53209}, {x -> -0.347296}, {x -> 1.87939}}
This time there are no spurious imaginary parts.
Carl Woll
> Wolfram Research
===
Subject: Re: FindFit and complex function?
have you tried Chop to chop off tiny imaginary parts ?
Can you use a constrained fit, to ensure that for all
parameter choices the fitting function, say f, takes real values?
Minimize
Real[f] + If[ Chop[ Im[ f ] ] != 0, Infinity, 0]
instead of f ?
Bye
Ben
On 24 Aug., 08:15, Michael Ignatov function in mathematica.
> The function comes from a solution of five algebraic equations with 5
> variables. Very straight forward. Unfortunately cubic roots are present
> in the solution so when the function is evaluated at fixed parameters it
> always return a small imaginary part with the real part. The real parts
> are quite meaningful and imaginary parts are extremely small. For all
> practical purposes I can just drop the imaginary part. When I build a
> model function, which is just a linear combination of 5 solutions, I can
> evaluate it with fixed parameters and see that it describes my
> experimental points rather well. But FindFit fails to perform a search
> always stopping at the starting value. Any ideas on how to either drop
> imaginary part of the function completely or make FindFit work with a
> function that returns complex numbers?
Michael
===
Subject: Re: FindFit and complex function?
>Hello everyone,
I have ran into a problem of fitting my experimental data points to a
>function in mathematica.
>The function comes from a solution of five algebraic equations with 5
>variables. Very straight forward. Unfortunately cubic roots are present
>in the solution so when the function is evaluated at fixed parameters it
>always return a small imaginary part with the real part. The real parts
>are quite meaningful and imaginary parts are extremely small. For all
>practical purposes I can just drop the imaginary part. When I build a
>model function, which is just a linear combination of 5 solutions, I can
>evaluate it with fixed parameters and see that it describes my
>experimental points rather well. But FindFit fails to perform a search
>always stopping at the starting value. Any ideas on how to either drop
>imaginary part of the function completely or make FindFit work with a
>function that returns complex numbers?
Michael
>
>
Assuming that you are using Solve to solve your equations, you can set
an option to return Root objects instead of radicals. Root objects can
be numericalized more reliably than radicals. For example:
In[136]:= Solve[x^3 - 3 x - 1 == 0, x] // N
Out[136]= {{x ->
1.87939+ 0. [ImaginaryI]}, {x -> -1.53209 +
1.11022*10^-16 [ImaginaryI]}, {x -> -0.347296 +
1.11022*10^-16 [ImaginaryI]}}
Now, set options for Roots and try again:
In[137]:= SetOptions[Roots, Cubics -> False, Quartics -> False];
In[138]:= Solve[x^3 - 3 x - 1 == 0, x] // N
Out[138]= {{x -> -1.53209}, {x -> -0.347296}, {x -> 1.87939}}
This time there are no spurious imaginary parts.
Carl Woll
Wolfram Research
===
Subject: Re: FindFit and complex function?
> I have ran into a problem of fitting my experimental data points to a
> function in mathematica.
> The function comes from a solution of five algebraic equations with 5
> variables. Very straight forward. Unfortunately cubic roots are present
> in the solution so when the function is evaluated at fixed parameters it
> always return a small imaginary part with the real part. The real parts
> are quite meaningful and imaginary parts are extremely small. For all
> practical purposes I can just drop the imaginary part. When I build a
> model function, which is just a linear combination of 5 solutions, I can
> evaluate it with fixed parameters and see that it describes my
> experimental points rather well. But FindFit fails to perform a search
> always stopping at the starting value. Any ideas on how to either drop
> imaginary part of the function completely or make FindFit work with a
> function that returns complex numbers?
The easiest way to discard very small imaginary parts is to use *Chop*.
For instance,
In[1]:= Exp[N[Range[4] Pi I]]
Out[1]= {-1. + 1.22465*10^-16 [ImaginaryI],
1.- 2.44929*10^-16 [ImaginaryI], -1. + 3.67394*10^-16 [ImaginaryI],
1.- 4.89859*10^-16 [ImaginaryI]}
In[2]:= Chop[%]
Out[2]= {-1., 1., -1., 1.}
--
Jean-Marc
===
> If the standard comment were changed to something like . . . affects
> printing, but not evaluation *of the expression inside the wrapper*
Better to delete the comment entirely. There's no way to rescue it.
I think what they usually mean, in effect, is that First@anyWrapper@x ==
x. That's USEFUL INFORMATION, at least.
It's also true for any function that remains unevaluated at the argument.
First@Cos@x == x, for instance, if x is undefined or exact (but not if x
is Real). Hence one way of rewriting the comment might be
...affects display but remains unevaluated.
But that's not transparently correct either, since
NumberForm[7,1,NumberPadding->{0,}]
%
gives this output:
07
7
But also
NumberForm[7,1,NumberPadding->{0,}];
%
07
(The wrapper goes away in the process of display, so both examples make
sense... if you hold your mouth right.)
So... six years on, I have little idea what they mean by wrapper, except
that it warns me to figure out each situation as it comes. And that's not
so hard, really, so long as we don't take Help literally.
> x=7; PaddedForm[x, 3, NumberForm->{0,} ]
> produces 0007 -- which doesn't match my naive interpretation of padding
> something out to three significant figures
Amen to that, too. But now you know what to expect, and all it took was
trying it.
Bobby
> PaddedForm is a wrapper - like MatrixForm, and many others. WRI have a
>> standard comment in relation to these - PaddedForm acts as a
.89¥[Thorn]wrapper.89¥ÿ,
>> which affects printing, but not evaluation.
>> The wording of this has always seemed to me unfortunate, because if you
>> leave wrapper round an object it looks OK, but can't be incorporated in
>> a further calculation - in other words a wrapper certainly does affect
>> evaluation!
Amen. Been caught by this repeatedly with TableForm -- especially if
> it's something like Table[ - - lengthy expression - - ]//TableForm.
If the standard comment were changed to something like . . . affects
> printing, but not evaluation *of the expression inside the wrapper*,
> you'd at least.
By the way, if my test in 5.2 the other day was correct,
x=7; PaddedForm[x, 3, NumberForm->{0,} ]
produces 0007 -- which doesn't match my naive interpretation of padding
> something out to three significant figures, especially since it
> expresses x = 7777 correctly as *four* significant figures. (It doesn't
> make James Bond very happy either).
--
DrMajorBob@bigfoot.com
===
My question was prompted out of a wish to save myself from reinventing the
wheel. The LinTicks function produces nice ticks for plots, and I've dug
into it before to make my own definitions, but I wanted to avoid that in
this
case. The answers given allow me to manipulate the values returned by
LinTicks. I'll summarize them below.
> If you really need to re-activate PaddedForm structures - rather than
> just avoid them, you could use:
yy /. PaddedForm[x_,_]->x
> you can use *First* to extract the original
> number. (Use FullForm[y] to see the structure of y.) For instance,
In[1]:= y = PaddedForm[1.23456, {3, 4}]
Out[1]//PaddedForm= !(*
> TagBox[
> InterpretationBox[< 1.2300>,
> 1.23456,
> AutoDelete->True],
> PaddedForm[#, {3, 4}]& ])
In[2]:= % + 1000 == y + 1000
Out[2]= 1001.23 == 1000 + !(*
> TagBox[
> InterpretationBox[< 1.2300>,
> 1.23456,
> AutoDelete->True],
> PaddedForm[#, {3, 4}]& ])
In[3]:= %% + 1000 == First @ y + 1000
Out[3]= True
--
Curtis Osterhoudt
cfo@remove_this.lanl.and_this.gov
PGP Key ID: 0x4DCA2A10
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
===
Subject: Re: Solving Nonlinear Equations
That's not a legal syntax (mismatched brackets, etc.), and if it were, you
didn't give the initial values or the values of m1, m2, m3, and m4, so.. .
what can we do?
In addition, C and D are system-defined symbols. FindRoot probably uses D
to take derivatives, so you're just asking for trouble with variable names
like that. I never, never, EVER start one of my own variables with a
capital; that makes it obvious whose symbol it is.
Bobby
I'm using Mathematica V6.0.1 and I have a system of 4 nonlinear equati=
ons
> which I'm trying to solve using FindRoot:
> FindRoot[{m1==C-D*Exp[1/(2*B^2)]*Sinh[A/B],
> m2==C^2+(D^2/2)(Exp[2/B^2]Cosh[2A/B]-1)-2C*D*Exp[1/(2B^2)]*Sinh[A/=
B],
> m3==C^3-3*C^3*D*Exp[1/(2B^2)]*Sinh[A/B],+3*C(D^2/2))*(Exp[2/B^2]Co=
sh[2A/B]-1
> )+(D^3/4)(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B]),
> m4==C^4-4(C^3)D*Exp[1/(2B^2)]*Sinh[A/B]+3(C*D)^2))*(Exp[2/B^2]Cosh=
[2A/B]-1)+
> (D^3/4)+C*D^3(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B])+(D^4/8=
)(Exp[
> 8/(B^2)]*Cosh
> [4A/B]-4*Exp[2/(B^2)]Cosh[2A/B]),{{A,initA},{B,initB},{C,initC},{D,ini=
tD}}]
> I get the message FindRoot::cvmit : Failed to converge to the reques=
ted
> accuracy... which I suspect is a result of initial values of A, B,C, =
=
> and D.
> What trick can one use to get accepatble initial values?
> MD Biyana
********************
> Nedbank Limited Reg No 1951/000009/06. The following link displays the=
=
> names of the Nedbank Board of Directors and Company Secretary. =
> [ http://www.nedbank.co.za/terms/DirectorsNedbank.htm ]
> This email is confidential and is intended for the addressee only. The=
=
> following link will take you to Nedbank's legal notice. =
> [ http://www.nedbank.co.za/terms/EmailDisclaimer.htm ]
> ********************
>
-- =
DrMajorBob@bigfoot.com
===
Subject: Re: Solving Nonlinear Equations
Use NMinimize with an objective function of 0 and your equations as
constraints. This should work better since NMinimize is a global
optimizer.
I'm using Mathematica V6.0.1 and I have a system of 4 nonlinear equations
> which I'm trying to solve using FindRoot:
FindRoot[{m1==C-D*Exp[1/(2*B^2)]*Sinh[A/B],
m2==C^2+(D^2/2)(Exp[2/B^2]Cosh[2A/B]-1)-2C*D*Exp[1/(2B^2)]*Sinh[A/B],
m3==C^3-3*C^3*D*Exp[1/(2B^2)]*Sinh[A/B],+3*C(D^2/2))*(Exp[2/B^2]Cosh[2A/B]-1
> )+(D^3/4)(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B]),
m4==C^4-4(C^3)D*Exp[1/(2B^2)]*Sinh[A/B]+3(C*D)^2))*(Exp[2/B^2]Cosh[2A/B]-1)+
>
(D^3/4)+C*D^3(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B])+(D^4/8)(Exp[
> 8/(B^2)]*Cosh
>
[4A/B]-4*Exp[2/(B^2)]Cosh[2A/B]),{{A,initA},{B,initB},{C,initC},{D,initD}}]
I get the message FindRoot::cvmit : Failed to converge to the
requested
> accuracy... which I suspect is a result of initial values of A, B,C, and
> D.
> What trick can one use to get accepatble initial values?
MD Biyana
********************
> Nedbank Limited Reg No 1951/000009/06. The following link displays the
> names of the Nedbank Board of Directors and Company Secretary. [
> http://www.nedbank.co.za/terms/DirectorsNedbank.htm ]
> This email is confidential and is intended for the addressee only. The
> following link will take you to Nedbank's legal notice. [
> http://www.nedbank.co.za/terms/EmailDisclaimer.htm ]
> ********************
===
Subject: Re: Solving Nonlinear Equations
> I'm using Mathematica V6.0.1 and I have a system of 4 nonlinear equations
> which I'm trying to solve using FindRoot:
>
> FindRoot[{m1==C-D*Exp[1/(2*B^2)]*Sinh[A/B],
>
> m2==C^2+(D^2/2)(Exp[2/B^2]Cosh[2A/B]-1)-2C*D*Exp[1/(2B^2)]*Sinh[A/B],
>
>
m3==C^3-3*C^3*D*Exp[1/(2B^2)]*Sinh[A/B],+3*C(D^2/2))*(Exp[2/B^2]Cosh[2A/B]-1
> )+(D^3/4)(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B]),
>
>
m4==C^4-4(C^3)D*Exp[1/(2B^2)]*Sinh[A/B]+3(C*D)^2))*(Exp[2/B^2]Cosh[2A/B]-1)+
>
(D^3/4)+C*D^3(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B])+(D^4/8)(Exp[
> 8/(B^2)]*Cosh
>
[4A/B]-4*Exp[2/(B^2)]Cosh[2A/B]),{{A,initA},{B,initB},{C,initC},{D,initD}}]
>
> I get the message FindRoot::cvmit : Failed to converge to the
requested
> accuracy... which I suspect is a result of initial values of A, B,C, and
D.
> What trick can one use to get accepatble initial values?
First, note that the expression you posted contains several syntax
errors (missing parentheses, curly bracket, comma in the middle of an
equation, possibly many others but I gave up trying to fix it in a
meaningful way).
Second, though the initial values may influence the results (and the
method used by FindRoot), it might be interesting to adjust some of the
internal parameters such as AccuracyGoal, MaxIterations, PrecisionGoal,
WorkingPrecision, to name a few.
--
Jean-Marc
===
Subject: Switching between open notebooks
I prefer using keyboard commands and
I dont really like the mechanism of switching between active
(selected) notebooks from FrontEnd menu. I have found a solution which
might be helpful for others.
I set keyboard shortcut ALT-` to rotate open notebooks which is similar
to
ALT-TAB command of choosing active programs in Windows.
Below are steps to activate this mechanism:
1. Find the file MenuSetup.tr. You can find it path by evaluation of
the command:
ToFileName[{$TopDirectory,SystemFiles,FrontEnd,TextResources,W
indows}]
2. Copy this file keeping the same directory structure into your
$UserBaseDirectory
3. Put the following line
,Delimiter,
Item[&Switch Windows,
KernelExecute[SetSelectedNotebook[Last[
DeleteCases[Notebooks[],MessagesNotebook[]]]]],
MenuKey[`,Modifiers->{Command}],
MenuEvaluator -> Automatic]
after the line Item[Start Windows Listing, MenuListWindows,
MenuAnchor->True]
The command and shortcut is optional, you can choose other combination
4. Restart Mathematica
This should activate the shortcut command ALT-` to swith active
windows.
Unfortunately the solution isn't perfect because it uses the commands of
kernel.
Please let me know if there is a better solution.
--
Yuri Kandrashkin, PhD
http://spinalgebra.com - Mathematica based applications:
- Magnetic Resonance with SpinAlgebra
- Work with systems of Units
===
Subject: Re: Specifying x-range for ListPlot
> Is it possible to specify x-range for ListPlot? For instance I have
> points {1,1},{2,2} and would like ListPlot's x-range to go from 0 to 3
See if this works:
ListPlot[{{1, 1}, {2, 2}}, PlotRange -> {{0, 3}, {ymin, ymax}}];
You can put anything you want for ymin and ymax.
===
Subject: RE: Specifying x-range for ListPlot
Hi Yaroslav
> Is it possible to specify x-range for ListPlot? For instance
> I have points {1,1},{2,2} and would like ListPlot's x-range
> to go from 0 to 3
Yep. You just need to specify ranges for both axes.
ListPlot[{{1, 1}, {2, 2}}, PlotRange -> {{0, 3}, All}]
Dave.
===
Subject: Re: Specifying x-range for ListPlot
> Is it possible to specify x-range for ListPlot? For instance I have
> points {1,1},{2,2} and would like ListPlot's x-range to go from 0 to 3
ListPlot[{{1, 1}, {2, 2}}, PlotRange -> {{0, 3}, Automatic}]
--
Jean-Marc
===
Subject: Re: Specifying x-range for ListPlot
ListPlot[{{1, 1}, {2, 2}}, PlotRange -> {{0, 3}, All}]
Jens
> Is it possible to specify x-range for ListPlot? For instance I have
> points {1,1},{2,2} and would like ListPlot's x-range to go from 0 to 3
===
Subject: explanation of the evaluation properties of 2nd args of Block With
& Module via example
As part of a replacement, the process of evaluation of the second
arguments of Block, With, and Module that have a head of Condition
(/;) may be explained by the analogous behavior of a (possibly
nested) expression containing RuleCondition and $ConditionHold:
In[1]:=
HoldComplete@a/.a:>Block[{b=4},b+1/;True]
HoldComplete@a/.a:>With[{b=4},b+1/;True]
HoldComplete@a/.a:>Module[{b=4},b+1/;True]
%//ReleaseHold(*the temporary value is still stored, and will take
effect if released*)
Out[1]= HoldComplete[5]
Out[2]= HoldComplete[4+1]
Out[3]= HoldComplete[b$66+1]
Out[4]= 5
In[5]:=
b=4;
HoldComplete@a/.a:>RuleCondition[b+1,True]
HoldComplete@a/.a:>RuleCondition[$ConditionHold[blah+1]/.blah->4,True]
HoldComplete@a/.a:>RuleCondition[$ConditionHold[b+1],True]
%//ReleaseHold(*the value is still stored, and will take effect if
released*)
b=.;
Out[6]= HoldComplete[5]
Out[7]= HoldComplete[4+1]
Out[8]= HoldComplete[b+1]
Out[9]= 5
--
http://chris.chiasson.name/
===
Subject: Behaviour of Mathematica varies according to size of digital image
imported
I'm using Import to read a stack of digital images into a list in
order to create an animation. However, the way Mathematica treats my
list depends on the size of the image - a strange behaviour which I
don't understand. The following is an example:
Case1: Using png or jpeg files with image size 96 x 256 (height,
width)
(* files is a list of the filenames to import - 10 images in my case*)
In[216]:= Clear[imglist]
imglist = Import[#] & /@ files ;
Dimensions[imglist[[All, 1, 1]]]
Out[218]={10, 96, 256, 3}
Case 2: Using png or jpeg files of any other width. I've tried images
of width 512, 257,255. Whenever the width is not 256 they all give the
same result
In[216]:= Clear[imglist]
imglist = Import[#] & /@ files ;
Dimensions[imglist[[All, 1, 1]]]
Out[218]= {10}
which is a real problem as I interpolate between the different images
to get a smoother animation. I've tried all sorts of tricks to get
around case 2 and get a list of image data as in case1 (using Apply,
Graphics-> List rules etc...) to no avail.
I'm using the latest Mathematica 6.0.1 and Windows XP SP2
I would be grateful for any help. It has taken me a better part of a
day to track down the problem.
===
Subject: BarChart inside a Frame. How to remove Labels from the top of the
frame? How to put x-axis label below and not on the side?
Mathematica 6.0.1
This is really annoying. I wanted a BarChart inside a frame. All works ok,
except it insists on putting the bar labels on top of the frame as well as
on the bottom of the frame, like this:
BarChart[{1, 2, 3}, Frame -> True]
I can remove the labels altogether, and use FrameTicks, but it still does it
again !
BarChart[{1, 2, 3}, Frame ->
True,BarLabels->None,FrameTicks->{{1,2,3},{0,1}}]
I think BarChart conflict with Frame somehow.
The only reason I wanted to put the BarChart inside a frame, is that with a
frame, when I put the x-label, it will go below and not on the side.
I wanted to write a large x-label, and just using BarChart, the x-label was
extending too far to the right since it start at the right edge of the axis,
as you see from this example
BarChart[{1, 2, 3}, AxesLabel -> {x-axis label}]
Is there a way to solve this problem? Either just use BarChart without
Frame, but tell it to put the x-label BELOW, or use a Frame with BarChart
but not have the bar labels at top and bottom as well?
Nasser
===
Subject: Re: fit a BinomialDistribution to exptl data?
> Floor[n] is the value of n to take.
Is there a simple rationale for that?
It seems to me the optimal integer n could lie on EITHER side of
FindMaximum's or FindFit's optimal Real.
Bobby
>> Given a list of data values, or a list of x-y data points for
>> plotting the data as an empirical distribution function, how can I
>> fit a BinomialDistribution to the data? The help documentation for
>> FindFit shows examples in which the user indicates which function
>> should be fit (e.g. FindFit[data, a x Log[b + c x], {a, b, c}, x]),
>> and I've been unable to find an example in which a statistical
>> distribution is being fit to data. Mathematica complains when I try the
>> following with an xy list of data that specified an EDF: FindFit
>> [xyvals, CDF[BinomialDistribution[n, pp], k], {n, pp}, k].
>> G
>> --
>> Gordon Robertson
>> Canada's Michael Smith Genome Sciences Centre
>> Vancouver BC Canada
>
> Non-default starting values are needed. By default, FindFit will use a
> starting value of 1 for each parameter, which will be problematic in
> this case. The starting value for n should be at least as large as the
> largest binomial in the sample, and the value for pp should be strictly
> between 0 and 1. Here is an example.
In[1]:= binom = RandomInteger[BinomialDistribution[20, .4], 10]
Out[1]= {10, 7, 5, 9, 8, 12, 7, 7, 10, 9}
In[2]:= edf = Sort[Tally[binom]];
In[3]:= edf[[All, 2]] = Accumulate[edf[[All, 2]]]/Length[binom];
In[4]:= FindFit[edf,
> CDF[BinomialDistribution[n, pp], k], {{n, Max[binom] + 1}, {pp,
> .5}},
> k]
Out[4]= {n -> 17.3082, pp -> 0.4773}
> Floor[n] is the value of n to take.
Note that FindFit gives a least squares fit of the edf to the cdf.
> Alternatively, a maximum likelihood estimate of the parameters can be
> obtained by maximizing the log likelihood function (the sum of the logs
> of the pdf with unknown parameters evaluated at the data points) with
> respect to the parameters.
> In[5]:= loglike
> PowerExpand[
> Total[Log[Map[PDF[BinomialDistribution[n, pp], #] &,
> binom]]]];
> Constraints should be used to keep the parameters in the feasible range.
In[6]:= FindMaximum[{loglike, n >= Max[binom] && 0 < pp < 1}, {n,
> Max[binom] + 1}, {pp, .5}]
Out[6]= {-20.6326, {n -> 14.9309, pp -> 0.56259}}
> Darren Glosemeyer
> Wolfram Research
--
DrMajorBob@bigfoot.com
===
Subject: Re: fit a BinomialDistribution to exptl data?
In R one can use the package gamlss.
It compares the data to a number of statistical distributions and gives a
measure of a possible fit. See:
http://studweb.north.londonmet.ac.uk/~stasinom/gamlss.html
Until now I have the impression that Mathematica V6.0 is not able to do
this. So, besides Mathematica I use R.
with friendly greetings,
P_ter
===
Subject: version 6 Plot3D exporting results in HUGE files
I did the following in v6.0.1 (which I will refer to as v6 hereafter):
generated a surface using the Plot3D command, clicked on the resulting
surface graphic, then Save Selection As > EPS.
The resulting EPS file was over 4400 KB!
I compiled the same code in v5.2 using the exact same steps. The
resulting EPS file was 700 KB.
This is immaterial except now when I include the EPS files in a LaTeX
document and convert the dvi file to either PS or PDF, the pages with
v6 generated surfaces render EXTREMELY slowly while the v5.2 generated
surfaces render very quickly.
Has anyone noticed the same thing? This is very disappointing for
someone who wants to use Mathematica to generate high quality graphics
for inclusion in technical documents.
I am running Mathematica v6.0.1 on Windows XP on a Dell Latitude D800.
FYI, the same behavior occurs in v6 if I Save As>PDF instead of going
the EPS route.
JD