Carl Love

Carl Love

28110 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@torabi Yes, Maple has no numeric solver for elliptic PDEs. You're out of luck.

@John Fredsted I think that it's the best option so far (for a small integer like 7). I didn't hold out any hope of the combinat:-randcomb being efficient.

Is f3(x) a known function? Can h3 be given a value before solving? On a quick read through, I don't see anything that makes this system nonlinear.

@Carl Love Here's a novel approach, and it's a short one-liner.

GenXY:= ()-> combinat:-randcomb(7, 2)[];

This generates a uniform distribution.

@Kitonum The distribution that you're sampling has the same problem as John's. See the histograms that I posted in a Reply to his Answer.

@John Fredsted 

The difference in the distributions being sampled is profound, as the following histograms show. Figuring out why this difference occurs might be a good problem for a junior- or senior-level probability course.


restart:

GenXY:= module()
local
     R:= RandomTools:-Generate(list(integer(range= 1..7), 2), makeproc),
     ModuleApply:= proc()
     local x:= 0, y:= 0;
          while x=y do  (x,y):= R()[]  end do;
          `if`(x<y, [x,y], [y,x])[]
     end proc
;
end module:
     

GenXY2:= proc()  local y:= rand(2..7)(); (rand(1..y-1)(), y)  end proc:

(A,B):= 'Matrix(7,7)'$2:

to 2^17 do
     (x,y):= GenXY();
     A[x,y]:= A[x,y]+1;
     (x,y):= GenXY2();
     B[x,y]:= B[x,y]+1
end do:

plotopts:=
     heights= histogram, gap= 1/3, axes= normal,
     tickmarks=[[seq(x+.5=x, x= 1..7)]$2, DEFAULT], labels= ['x','y',count]
:

#plots:-display(<plots:-matrixplot~([A,B], plotopts)>^+);

Side-by-side plots don't display on MaplePrimes, so here they are plotted individually.

plots:-matrixplot(A, plotopts); plots:-matrixplot(B, plotopts);

 

 

NULL


Download two_distributions.mw

@yongling93 In that case, you want to store your bits in a Matrix.  Then all your shifting (what you call "crossover") can be done with surprisingly simple indexing commands. Like this:

B:= Matrix([[0,0,1,1,0,0,1], [0,0,1,1,1,0,0],[0,1,0,1,0,1,0], [1,0,0,1,1,1,0]]):
Bnew:= copy(B):
Bnew[[4,1,2,3], 3..5]:= B[.., 3..5]:
Bnew;

B;

I converted this from a Question to a Post because the question asks for open-ended discussion and opinions rather than definite answers.

@Carl Love Please let me know the outcome of this assignment. I particularly want to know if my guess about the professor trying to stump you with a impossible n was correct.

@adrian5213 Just add ,rn to the return statement.

Do you mean the tensor package? There is no standard package named debever, but ?debever takes you to help about the tensor package.

Here's a Maple worksheet that does it.


restart:

temps:= [0, 10, 20, 30, 50, 80, 100]:

 

concs:= [1,2,4,8,12,16,20,24]:

 

densities:= Matrix(
     8, 7,
     [[1.0033, 1.0029, 1.0013, .9987, .9910, .9749, .9617],
      [1.0067, 1.0062, 1.0045, 1.0018, .9940, .9780, .9651],
      [1.0135, 1.0126, 1.0107, 1.0077, .9999, .9842, .9718],
      [1.0266, 1.0251, 1.0227, 1.0195, 1.0116, .9963, .9849],
      [1.0391, 1.0370, 1.0344, 1.0310, 1.0231, 1.0081, .9975],
      [1.0510, 1.0485, 1.0457, 1.0422, 1.0343, 1.0198, 1.0096],
      [1.0625, 1.0596, 1.0567, 1.0532, 1.0454, 1.0312, 1.0213],
      [1.0736, 1.0705, 1.0674, 1.0641, 1.0564, 1.0426, 1.0327]
     ]
):

n:= nops(concs):  m:= nops(temps):

Temps:= <`$`~(temps, n)>:

Concs:= <op~([concs $ m])>:

Densities:= <convert(densities, list)>:

 

V:= [t,c]:  deg:= [3,3]:

poly33:= [op(expand(mul(add(V[j]^k, k= 0..deg[j]), j= 1..nops(V))))]:

dens:= Statistics:-LinearFit(poly33, <Temps | Concs>, Densities, V);

HFloat(0.999827834949608)+HFloat(0.0035296553038636205)*c-HFloat(2.4310027666692226e-5)*c^2+HFloat(2.1317696091887753e-7)*c^3+HFloat(2.7032609112586373e-5)*t-HFloat(2.1306485300650898e-5)*t*c+HFloat(5.109610725598598e-7)*t*c^2-HFloat(5.615941220840037e-9)*t*c^3-HFloat(6.015095308141257e-6)*t^2+HFloat(2.2177754561062198e-7)*t^2*c-HFloat(4.0121110835311455e-9)*t^2*c^2+HFloat(9.663636955724667e-11)*t^2*c^3+HFloat(1.5893434605505464e-8)*t^3-HFloat(1.4989540552602354e-10)*t^3*c-HFloat(4.967636004952312e-12)*t^3*c^2-HFloat(4.948269477780804e-13)*t^3*c^3

(1)


plots:-display(
     plot3d(dens, t= 0..100, c= 0..24),
     plots:-pointplot3d(convert(<Temps|Concs|Densities>, listlist), color= red),
     axes= normal
);

 

 


Download NH4Cl_density.mw

@adrian5213 Yes, it's easy using the same binary converter that I gave above with a new operator that gives the quotient and remainder.

`&B`:= (ex::uneval)->
     subsindets(eval(subsindets(ex, integer, convert, decimal, 2)), integer, convert, binary):

QR:= proc(N::integer, n::integer) local r, q:= iquo(N,n,r); [q,r] end proc:

&B QR(010100111, 10010);

@tomleslie You don't need to worry about options c[3], c[4], c[5]. The first, c[3], only applies if itask = 4 or 5; you're using itask = 1 (the default). The other two, c[4] and c[5], only apply if you're using one of the -band submethods of lsode; you're using submethod adamsfull. These options specify how many super- and sub-diagonals, respectively, of the jacobian to use. Personally, I think that using a jacobian-based method for such a "wild" RHS is a bad idea. I think that the submethod should be changed to adamsfunc, which uses no jacobian.

@Kitonum Sigh. I guess that it's yet another difference between 1D and 2D input. I guess that as the 2D input is internally translated to 1D, an extra level of evaluation occurs.

First 432 433 434 435 436 437 438 Last Page 434 of 710