Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 37 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

Where is the N that you want to set to 100? I found an N in your code, and I set it to 100 with no problem. I also set k to 100 with no problem.

@quann169 I don't know anything about IDE, but did you remember to put the $ in the first column?

The code in your file is a statement defining a procedure. When that statement is executed by the read, it defines the procedure at the top level rather than as part of the module.

@derekcowley Oh, I think that I understand now what you want: You want to express a polynomial as a sum of terms each of which is factored a particular way. That's much more difficult than just factoring. I can't immediately think of a way to do that. Certainly the factor command cannot do it. It may be possible using simplify with side relations. The side relations would be p1 - p2 = p12, p1 - p3 = p13, etc., (every possible pair of p's is equated to a unique variable). I may be able to work on it tonight.

@derekcowley 

You seem to expect that your expression T2 ((24) or (25)) will be divisible by p1-p2. I am saying that it is obviously not divisible by that.

@Markiyan Hirnyk 

What are you talking about??? The only thing that I did to make the OP's code work was to change the fsolve command as indicated. The answer is complete and true.

I get sqrt(14) for both norms. What do you get?

@Markiyan Hirnyk 

Here is my executed worksheet. I get similar results with Maple 18.00, with Digits = 15, and/or with alfa set to 1/5 rather than 0.2.

fsolve_problem.mw

 

It is natural to think that specfunc(name, `+`) would be the correct typespec. However, x+y is not considered a function by Maple (so specfunc doesn't apply), even though it is the result of applying the function `+` to arguments of type name. It's kind of like sin(0) is not of type specfunc(anything, sin) because sin(0) is not a function after it's evaluated (it's just 0).

`+` and `*` are their own fundamental types.

@Preben Alsholm 

This can also be written

map(`/`, c, d);

which avoids two calls to user arrow procedures.

@Carl Love I still don't see your attached file.

Update: Okay, I got the attached file now.

To attach a file using the MaplePrimes editor, use the green uparrow, which is the last tool on the second row of the toolbar.

@k20057 5 Why do you allow [1, 1, 1, 4, 1, 1] under the Fermi-Dirac model? Shouldn't it be forbidden because more than two particles have one unit of energy?

@acer How do you create a PlotComponent and name it Plot0?

@k20057 5 But I did not remove any of the functionality of the original code! I only added functionality. If you want a Bose-Einstein sample of size 100,000, it is done like this:


restart:

QuantumDistribution:= proc(
     n::nonnegint, #Number of quanta of energy
     k::posint,    #Number of particles
     {model::identical("Bose-Einstein","Maxwell-Boltzmann","Fermi-Dirac"):= NULL},
     {output::identical(exact, sampler, population):= exact}
)
local C, Population, sz, Rand;
     if model = "Maxwell-Boltzmann" then
          Population:= combinat:-composition(n+k, k)
     else
          # Bose-Einstein:
          Population:= select(p-> nops(p)=k, combinat:-partition(n+k, n+1));
          if model = "Fermi-Dirac" then
               Population:= select(C-> ListTools:-FindRepetitions(C,2) = [], Population)
          end if
     end if;
     sz:= nops(Population);
     userinfo(1, QuantumDistribution, NoName, "Population size = ", sz);
     Population:= [seq(C-~1, C= Population)];
     if output = 'exact' then

          (lhs=rhs/sz)~([{Statistics:-Tally(op~(Population))[]}[]])
     elif output = 'sampler' then
          Rand:= rand(1..sz);
          ()-> Population[Rand()]
     else
          # output = 'population'
          Population
     end if
end proc:

R:= QuantumDistribution(9, 6, model= "Bose-Einstein", output= sampler):

n:= 10^5: #Sample size

S:= ['R()' $ n]:

T:= [{map(lhs=rhs/n, Statistics:-Tally(op~(S)))[]}[]]:

Decimal versions of sampled values:

ES:= evalf(%);

[0. = 2.26359000000000, 1. = 1.54463000000000, 2. = .882690000000000, 3. = .538230000000000, 4. = .309940000000000, 5. = .194810000000000, 6. = .114910000000000, 7. = 0.754900000000000e-1, 8. = 0.377900000000000e-1, 9. = 0.379200000000000e-1]

 


Download QuantumDistribution.mw

 

Please upload your file as a Maple worksheet (extension .mw), not as a .doc file.

First 528 529 530 531 532 533 534 Last Page 530 of 709