Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 358 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

You wrote:

The resulotion of plot is not so good, and when I export this plot as jpeg file, quality of resolution deteriotate even more, I mean pixel tear out on zooming the image. How I fix this issue which I guess might be due to wrong way of exporting plot ?

JPEG is not a good format for most plots. JPEG is intended for photos (the P in JPEG stands for Photographic), which have continuous color changes. Plots tend to have crisp, abrupt, discontinuous color changes, especially in the transition from foreground to background. The "pixels tearing out" is JPEG's attempt to convert those abrupt changes into continuous ones.

On the other hand, the G in both PNG and GIF stands for Graphics. These are better than JPEG for most plots.

You had many syntax errors---too many for me to list right now---and your procedure CreaF would've been very inefficient if it had worked. Here's a better way:

f:= (x,y,i,j)-> ((x+j-1)/2^i, (y+2^i-j-1)/2^i):
CreaF:= (i::posint)-> unapply(Vector(2^i-1, j-> f(x,y,i,j)), (x,y)):

And call it like this:

CreaF(2)(.35,.465)[1];

     0.875000000000000e-1, .616250000000000

Note that I changed the call order from your CreaF(2)[1](.35,.465) because I thought that that would generally be more efficient. In other words, CreaF now returns a procedure which returns a Vector as opposed to CreaF returning a Vector of procedures. If you need it to be the latter way, let me know.

Your implementation of Kitonum's Answer is much longer than it needs to be, and takes much more time. Here's my one-liner procedure for it:

DeleteZeroColumns:= (M::Matrix)-> M[.., remove(k-> M[1,k]=0, [$1..op([1,2],M)])]:

This runs in 3 to 4 milliseconds on an 8x3000 Matrix. The code op([1,2],M) returns the number of columns of M.

If the first argument to display is an array of plots, then you'll get a table of plots. If the first argument is a list of plots, then you'll get them all plotted in the same coordinate plane.

In Maple 2016: Suppose that A is the 5x2 Matrix. Then do

[seq(convert(v[], list), v= Iterator:-CartesianProduct(convert(A, listlist)[]))];

To see the full solution for 2nd-4th degree polynomials with variable coefficients, use option explicit:

solve(myeq, y, explicit);

Use PDEtools:-dchange to convert to polar coordinates, where the boundary condition is simpler.

PDE:= diff(u(x,y), x$2) + diff(u(x,y), y$2) = 1:
PDEp:= PDEtools:-dchange({x= r*cos(theta), y= r*sin(theta)}, PDE, simplify);

     PDEp := ((diff(u(r, theta), r, r))*r^2+(diff(u(r, theta), r))*r+diff(u(r, theta), theta, theta))/r^2

pdsolve({PDEp, u(1, theta) = 0});

     u(r, theta) = (1/4)*r^2+_F1(I*ln(r)+theta)+_F2(-I*ln(r)+theta)

Change y^`*` to `y*`.

(Some of this will repeat what Joe said, but I have the improved code also.)

Your hunch that hash tables would be better is spot on. Although your algorithm is impressive, your Maple implementation of it suffers from the most common of newbie efficiency mistakes: building a set or list by iteratively appending to an existing set or list. (I even used to do it myself, many, many years ago.) This can be corrected by building a table instead and then using indices or entries to build the set or list.

It only required a trivial change to make this change for your big set, orbits. This simple change reduced the run time to under 15 seconds. By also correcting the same mistake for your small set orbit and converting your small list interl to one built with a single seq, I shaved off another three seconds. By converting some of the other for loops to seqs, I shaved off another second. Moving the computation of d2 outside the inner loop saved another three seconds (an idea that I got from Joe). Remembering the previously computed values of d3 saved another 6 seconds (an idea that I got from Joe). The final code's memory usage is 22.18 M, and its time is under 3 seconds. Here is the code:

HEX:= proc()
local orbit, orbits:= table(), idx2, idx3, d2, d3, pos,
    interl, r, entry, refl, q,
    Base3:= proc(n) option remember; convert(n, base, 3) end proc
;
    for idx2 from 2^6 to 2*2^6-1 do
        d2:= convert(idx2, base, 2);
        for idx3 from 3^6 to 2*3^6-1 do
            d3:= Base3(idx3);
            interl:= [seq([d2[pos], d3[pos]][], pos= 1..6)];
            orbit:= table();
            orbit[seq(interl[[seq(q, q= 1+r..12), seq(q, q= 1..r)]], r= 0..11, 2)]:= ();
            for refl from 0 to 11 by 4 do
                entry:= interl[[seq(q, q= 1+refl..12), seq(q, q= 1..refl)]];
                orbit[entry[[1, seq(12-q, q= 0..10)]], entry[[3, 2, 1, seq(12-q, q= 0..8)]]]:= ()
            od;
            orbits[{indices(orbit, nolist)}]:= ()
        od
    od;
    nops([indices(orbits, nolist)])
end proc:

This code isn't intended to be run as 2D input, which fails by prematurely evaluating ().

You already have the correct implicit solution. It's what you called implicitsoln1. There's no way to get an explicit solution, i.e., a solution without RootOf and with y isolated on one side of the equation, which is probably why your instructor asked you for the implicit solution.

In the expression D(u)(x,0), you need to specify the independent variable with respect to which the derivative is being taken. So, you can change it to D[1](u)(x,0) for the derivative with respect to x or D[2](u)(x,0) for the derivative with respect to t.

You can start by reading ?HelpTools and its subpages. You should create your help file as a worksheet rather than as a .txt file.

The Answers of John and Kitonum have given a minor symptomatic solution to your problem but have failed to mention that your code can be vastly simplified.

If f and h are both sets, then all you need is

f intersect h;

The following works if f or h are sets or lists or a mixture:

select(`in`, f, h);

The print command is very, very rarely a good way to get your results. Whenever you feel tempted to use print, you should try to think of another way, or ask a Question here.

You want 20 arrays each with 20 elements? Use a 20x20 Matrix. Fill it with a single call to Sample:

X:= Matrix((20$2), datatype= float[8]):
N:= Statistics:-RandomVariable(Normal(0,1)):
Statistics:-Sample(N, X):

Now the jth column of X can be accessed as X[..,j] and is equivalent to a 20-element Vector.

(I know that the above commands can be shortened. I wrote it the way I did for pedagogy.)

Since q[2] is 0, this is trivial in that the sum reduces to one term. But I'll assume that you want to do this in more general cases. Also, I'll assume that x = x[1] and y = x[2]; otherwise, the answer is, of course, 0.

q:= <1,0>:
add(add(diff(a*x[1]*(1-x[1])-b*x[1]*x[2], x[j], x[k])*q[j]*q[k], j= 1..2), k= 1..2);

First 220 221 222 223 224 225 226 Last Page 222 of 395