Carl Love

Carl Love

28070 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

Don't repeat your Questions. It's very annoying to the moderators.

You got an Answer in about 35 minutes. I think that that's a pretty good response rate.

@WernerP There's no need for implicitplot3d or high values of numpoints. Your code can be simplified to

A:= plot3d(5, theta= -Pi..Pi, phi= arccos(4/5)..arccos(3/5), coords= spherical):
B:= plot3d(5, theta= -Pi..Pi, phi= 0..Pi/2, coords= spherical, transparency= .6):
C1:= plot3d([3, theta, z], theta= -Pi..Pi, z= 0..4, coords= cylindrical):
C2:= plot3d([4, theta, z], theta= -Pi..Pi, z= 0..3, coords= cylindrical):
plots:-display(
     {A, B, C1, C2}, scaling= constrained, labels= [X,Y,Z],
     axes= normal, style= patchnogrid, color= yellow
);

@epostma Thanks! Unfortunately, I think that it'll require that kernel work because according to the Maple Programming Guide, section 9.6 "Overloading Built-in Routines," select, etc., aren't on that short list of overloadables. This is surprising because I'd expect to be able to use select on any container object.

To get the plot in the lower hemisphere also, as well as the plot of the sphere itself, you can use

f:= (r,phi)-> sqrt(25-r^2):
P1:= plot3d(
     [[r*cos(phi), r*sin(phi), f(r,phi)], [r*cos(phi), r*sin(phi), -f(r,phi)]],
     r= 3..4, phi= 0..2*Pi, labels= ['x','y','z'],
     color= black, style= patchnogrid, glossiness= 0
):
P2:= plot3d(5, phi= -Pi/2..Pi/2, theta= 0..2*Pi, coords= spherical):
plots:-display([P2,P1], axes= box, scaling= constrained);

@farazhedayati Unfortunately Kitonum's procedure relies on the variables in the expression being x and y. Your variables are x and a. So, call it like this:

ContoursWithLabels(subs(a= y, PP), -3..3, -3..3);

Of course, you may want to change the ranges.

I'll post a correction to the procedure in a little while, if someone else doesn't beat me to it.

 

@a_simsim Get rid of the line return z. The fsolve itself should be the return value. The fsolve doesn't assign the value of z; it just returns a numeric value for z.

@acer To appreciate the difference in timing, you'd need to do a bunch of short messages. I didn't do it, but it's obvious that there'd be some savings. Every little bit helps.

@acer Sure it can be done that way:

BySubs:= module()
local
     b, k,
     All:= seq(Bits:-Split(k, bits= 8), k= 0..254, 2),
     Subs:= {seq(b= [b[1..2][], 1 -~ b[3..7][], b[8]], b= All)},
     ModuleApply:= block-> subs(Subs, block)
;
     All:= 'All'  #garbage collection
end module:

@Carl Love I was motivated by Joe's idea that there were a very limited number of possible eight-bit lists. If they all have leading zeros, as yours do, then there's 128. So we can use the subs command directly, making every possible substitution. This is significantly faster (than even the LinearAlgebra:-Modular method) for long messages:

BySubs:= proc(block)
local k, b, All:= [seq(Bits:-Split(k, bits= 8), k= 0..254, 2)];
     subs({seq(b= [b[1..2][], 1 -~ b[3..7][], b[8]], b= All)}, block)
end proc;

This processes a million-byte message in 60 milliseconds.

@Kitonum Your shorter code can be shortened further to

block1:= [seq(subsop(seq(j= 1-B[j], j= 3..7), B), B= block)];

which removes one level of indexing.

The matrix operations are far more efficient (by a factor of about 30) if performed in LinearAlgebra:-Modular. The drawback is that the syntax used by that package is difficult to understand. Here's a procedure for it;

FlipBits:= proc(block)
uses LAM= LinearAlgebra:-Modular;
local Block:= LAM:-Mod(2, block, integer[kernelopts(wordsize)/8]);
    LAM:-AddMultiple(
         2,
         LAM:-Create(2, nops(block), 7-3+1, 1, integer[kernelopts(wordsize)/8]),
         Block, 1..-1, 3..7,
         Block, 1..-1, 3..7
    );
    Block
end proc:

To use it:

block:= ListTools:-Reverse~(Bits:-Split~(convert(message, bytes), bits= 8)):
Block:= FlipBits(block):
cblock:= convert(Block, listlist):

with that last line being not needed if you want to stay in Matrix form.

This is also far faster than the subsop method.

 

@Joe Riel Do you know if using subsop on a long list is just as inefficient as assignments? I would think so, but I haven't been able to confirm it. I made the original message 1000 times longer and compared my code with Kitonum's shorter code. Kitonum's was faster by a little bit.

@ecterrab You said that the Document mode has additional features (over the Worksheet mode). What are some of those features?

Is the Worksheet mode considered to be for more-computational work while the Document mode is for more-expository work?

@Christopher2222 

With some small adjustments, the plots are almost identical. I used Maple's ColorTools to find colors matching the Mathematica plot. I also adjusted the transparency, thickness, labels, and number of subticks on each axis.

I'll agree that Maple's orange is actually red. Maple's green and blue seem okay, although they're different shades than Mathematica's colors corresponding to those names.

restart:
Options:=  
     t= -6..6,
     color= ["Resene Horizon", "Resene YellowSea", "Resene Citron"], #i.e., blue, orange, green
     filled= [transparency= .85], thickness= 4, labels= [``$2],
     axis[1]= [tickmarks= [subticks= 3]], axis[2]= [tickmarks= [subticks= 4]]
:
plot([seq(Statistics:-PDF(Normal(0,i), t), i= [.75, 1, 2])], Options);
plot([seq(Statistics:-PDF(Normal(i,1.5), t), i= [-1, 1, 2])], Options);

Compare with the Mathematica plot:

 

@Christopher2222 Of course, I have assumed that you've already executed

with(Statistics):
X := RandomVariable(Normal(0, 1))
;

before executing my command!!!

First 420 421 422 423 424 425 426 Last Page 422 of 709