80 Reputation

5 Badges

7 years, 325 days

MaplePrimes Activity

These are questions asked by w-Teilchen

Hej hej,

is there a way to obtain confidence intervals for the parameters in a NonlinearFit? To give you an impression of the problem which I was working on, I created a minimial working example (not sure wheather that actually helps). In this particular case, I have two parameters to fit the coefficients of a binomial series to some data I obtained. Beyond the values of the parameters (in a least square fit), I'm also interested in some kind of confidence interval, to get a feeling about how realiable my values are. Is there a direct (or even indirect) way to obtain such a thing. Either directly as a Maple function (confidenceintervals is not supported for NonlinearFit, if I'm not mistaken) or as something I can implement myself (within a reasonable time frame, as in hours rather than days).
Thanks in advance!



restart; with(plots); with(Statistics)

alpha[0] := 1.000000000:

m__max := 4:

model := Fit(pochhammer(z__1, m)*h__exp^m/factorial(m), [seq(m, m = 0 .. m__max)], [seq(alpha[m], m = 0 .. m__max)], m, output = [leastsquaresfunction, residuals], weights = [seq(1/abs(alpha[m]), m = 0 .. m__max)], iterationlimit = 10000)

model := [pochhammer(1.42349754368085, m)*16.2763580438677^m/factorial(m), Vector[row](5, {(1) = 0., (2) = -0.120508651249829e-1, (3) = 0.113910530162494e-1, (4) = 0.348907003220054e-3, (5) = -0.305508272150429e-2})]


plots[multiple](logplot, [{seq([m, alpha[m]], m = 0 .. m__max)}, style = point, color = black], [{seq([m, model[1]], m = 0 .. m__max)}])



Download nonlinearfit-problem.mw

Hej everyone,

I am trying to run a Maple script for multiple parameters on our cluster, so far so good. I found that I can pass for example a:=1 and b:=2 to a Maple script using

maple -c "a:=1;" -c "b:=2;" < script.mpl

Is that the best/only way? For convenience I would like to read the parameters from a file, my first idea was to work with sed, so I tried

maple $(sed -n 1'p' data) < script.mpl

This should take the first line from data (which is -c "a:=1;" -c "b:=2;"), so that I would expect to get the same result.
Unfortunately, this is not the case, only the first parameter a:=1 is passed correctly and non of the further parameters.

I've appended the files, I used.

This may be not a Maple problem but rather me making a mistake using sed, but maybe you can see where I made a mistake.

Thanks in advance,






Download script.mw

The mw-file has to be exported as an mpl-file first. In my case data just contains one line: -c "a:=1;" -c "b:=2;" -c "c:=3;" (I couldn't upload either)


I seem to run into problems with (quantum) perturbation theory. In the following minimal working example, an energy denominator, as occuring in perturbation theory is not evaluated if I previously assume that the quantum number is a positive integer. It's supposed to return an error, as the energy denominator is 0.

restart; with(Physics)

a := Annihilation(N, 1, notation = explicit):

psi := Ket(N, m);

Physics:-Ket(N, m)


E := proc (g) options operator, arrow; (1/2)*g*(g-1)-mu*g end proc:

simplify(value(Typesetting:-delayDotProduct(Typesetting:-delayDotProduct(Dagger(psi), 1/(E(m)-H)), psi)))



assume(`in`(m, nonnegint), m > 0);

simplify(value(Typesetting:-delayDotProduct(Typesetting:-delayDotProduct(Dagger(psi), 1/(E(m)-H)), psi)))

-2*Physics:-Bracket(Physics:-Bra(N, m), 1/(-2*mu*Physics:-`*`(`a-`[N[1]], `a+`[N[1]])+2*mu*m-m^2+Physics:-`*`(Physics:-`^`(`a-`[N[1]], 2), Physics:-`^`(`a+`[N[1]], 2))-4*Physics:-`*`(`a-`[N[1]], `a+`[N[1]])+2*mu+m+2), Physics:-Ket(N, m))


Parse:-ConvertTo1D, "invalid input %1", `.`(Dagger(psi), 1/(E-H), psi)




Download energy_denominator.mw


Best regards,


Hello everyone,

I've been trying to do some perturbation theory and ran into some problems I don't quite understand. I implemented the Hamiltonian of the Bose-Hubbard model and treated the hopping as a perturbation. Calculating the second order energy shift is easily accomplished, but when I'm only interested in one of the two occuring terms, I run into problems. The calculation takes minutes to finally fail, giving me an "too many levels of recursion"-error. I need to be able to just pick a few terms for some calculations, I'm doing, and can't figure out what I might be doing wrong. Here is the source code (download is below):

restart; with(Physics); Setup(mathematicalnotation = true)

a__1 := Annihilation(N, 1):

assume(`and`(`in`(m, nonnegint), m > 0)):

Physics:-Ket(N, m, m)


H := Physics:-`*`(Physics:-`*`(1/2, n__1), n__1-1)+Physics:-`*`(Physics:-`*`(1/2, n__2), n__2-1):

`&Delta;E__2` := Physics:-`*`(Physics:-`*`(2, d), simplify(value(Typesetting:-delayDotProduct(Typesetting:-delayDotProduct(Typesetting:-delayDotProduct(Typesetting:-delayDotProduct(Dagger(psi), V), 1/(E(m, m)-H)), V), psi))))



simplify(value(((Dagger(psi).c__2)*a__1.(1/(E(m, m)-H)).c__1)*a__2.psi))

Error, (in PatternMatching:-AlgStruct:-Match) too many levels of recursion



Download too_many_levels_of_recursion.mw

It would be great, if someone could point out the mistake, I'm making. I copy/pasted the last line, so there shouldn't be any typos.

Thanks in advance,



when using Statistics:-Histogram i received the following strange result for the ordinate:

Statistics:-Histogram([0.587944711e-1, 0.587944836e-1, 0.589720582e-1]);

Download Histogram.mw


1 2 3 Page 2 of 3