Carl Love

Carl Love

28160 Reputation

25 Badges

14 years, 18 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@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.

@Markiyan Hirnyk 

It is obvious that Preben did not intend for his code to be executed in isolation but rather using the OP's definition of unitcircle. If you do it that it way then it runs fine.

@H-R Thank you. You now have enough reputation to vote.

@H-R Yes, the operand numbers of a function never change. In f(a,b), the f is operand 0, a is operand 1, and b is operand 2. For nonassociative infix operators that only take two operands (=, <=, <, >, >=, .., ::, ^), operand 1 is always the left side.

So, if the left side of BC4 will always be the sum (and only the sum), then op([1,1], BC4) will safely extract the operand of the sum. This operand is a product (of type `*`). The select command will select factors of that product based on a boolean condition. The condition is that the factor has a subexpression of type sinh(algebraic), which means the function sinh applied to any single type algebraic argument. See ?select , ?hastype , ?type,algebraic , ?type,structure .

Please supply the code for function f. If I change your f to something simple like 1, then I do not get white lines.

Do the white lines appear on the plot in the worksheet? Or do they only appear after you've transferred the plot somewhere else?

First 530 531 532 533 534 535 536 Last Page 532 of 711