Carl Love

Carl Love

26663 Reputation

25 Badges

11 years, 231 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

For what it's worth, it's trivial to take an existing plot and convert the Matrix to a listlist (which is the Mapleish name for the structure is your older plot). Let's say that plot is stored at P. Then

evalindets(P, Matrix, convert, listlist);

I am curious if others think that this changes the appearence of the plot. I'm not sure. I am sure that your M12 plot has better anti-aliasing. (Look very closely at the section -1..1 on the M12 plot. Depending on the quality of your eyesight, you may need to export the plot to a JPEG viewer and zoom in.). The M17 plot may not have any anti-aliasing. Can you check the anti-aliasing setting on both versions of Maple? But, alas, I don't think that anti-aliasing is the complete answer to the difference. The M17 plot is too nasty for that to be the only problem. (And we discussed this at length with respect to plot(sin(x), x= 0..2*Pi) a month or two ago.)

Take your expression newpar (the first, unerroneous one) and apply the following transformation:

evalindets(newpar, 'RootOf'(algebraic), allvalues@(e-> RootOf(op(e), index= 1)));

Let me know how that goes. I couldn't test it on your actual code because it wasn't attached to your post.

To make an actual histogram, we take a random sample of the Poisson distribution and use Statistics:-Histogram. I chose a sample size of 2^13. The default is that the bars (bins) are bounded by the integer values. That doesn't make sense to me. I want the bars centered on the integer values. So I set the binbounds as n-1/2..n+1/2.

Take the previous code, and simply change the line defining H[n] to

H[n]:= Histogram(Sample(Poisson(n), 2^13), binbounds= [seq](-1/2+k, k= 0..25));

Statistics:-DensityPlot will plot an ordinary plot of the PDF for a continuous distribution, and it will plot something like a histogram for a discrete distribution. So, it can be used for both plots. If you want an actual histogram, we can draw a random sample from the Poisson and use Statistics:-Histogram. (Let me know.) I also updated your string plotting to modernity with typeset.

Note that the second parameter to Normal is not the variance; rather, it is the square root of the variance. Also, the expressions "NormalPDF", "PoissonPDF", and "ProbHist" are meaningless in Maple.

with(plots): with(Statistics):
for n from 1 to 15 do
     tracker[n]:= textplot([18,0.3,typeset(lambda = n)], color= blue);
     H[n]:= DensityPlot(Poisson(n));
     N[n]:= DensityPlot(
          Normal(n, sqrt(n)), range = 0..25, color= "Niagara Red"
     );
     P[n]:= display([H[n], N[n], tracker[n]])
od:
display(
     [seq](P[n], n= 1..15), insequence=true,
     title= typeset(
          "Normal approx. to the Poisson. ",
          lambda,
          " is increasing from 1 to 15."
     )
);

Try solve(q,z) assuming z>0 and solve(q,z) assuming z<0. I get two solutions for each.

f:= (x,y)-> 5/(1+x^2+y^2):
X:= t-> 2+3*cos(t):  Y:= t-> -1+2*sin(t):
plots:-display([
     plot3d(f(x,y), x= -4..7, y= -4..4),
     plots:-spacecurve(
          [X(t), Y(t), f(X(t),Y(t))], t= 0..2*Pi,
          color= black, thickness= 3
     )
]);

The coefficient is not a matrix; it is the determinant of a matrix, which is a scalar. I think that finding a closed form for this sum is well beyond the capability of any current CAS.

Here's a procedure for generating the determinant, which might help you in finding a closed form for the determinant at least. The determinants are not extremely complicated.

DetAn:= (n::nonnegint)-> LinearAlgebra:-Determinant(
     Matrix(
          n, n,
          (i,j)->
               if j >= i and (j-i)::even then
                    (j-i+1)*(j-1)!/(i-1)!*a(j-i+1)*x
               elif i-j = 1 then  -1
               else  0
               end if
     )
):

Part of the problem is that your Matrix M is created inside the i and j loops. I say "part" because when I take the creation outside the loop, there are new problems that pop up that I don't understand yet. But certainly it cannot possibly work with the Matrix being created inside the loop.

Could you isolate the relevant section of code for me and place it in a plain text file? From the final restart to the end of the file. I have a lot of trouble working with 2d input, especially with a section of code of this size.

You need some {} in your last command. Change dsolve(sys2, [x1(t), x2(t), x3(t)]) to dsolve({sys2}, [x1(t), x2(t), x3(t)]).

If ex is your expression, then simply

series(ex, c= infinity, 3);

I guess this is a bug in solve. I don't know about avoiding it, but you can easily correct if after the fact like this:

solve(f(x)=y, x);

subsindets(%, list, op);

I have worked a little with your code. I cannot back-up your claim that the numeric rank is taking any significant amount of time. I haven't found what's taking the majority of the time, but it's not the rank. The rank for a 1000 x 50 or so Matrix from your program takes about 5 millisecs.

To find exactly how the time is divided among the various parts of your program, use ?exprofile. And to count how many times each part of your program is executed, use ?excallgraph. I haven't had a chance yet to use these on your program.

Symbolic rank is a another matter. Computing the symbolic rank of a dense 6x6 matrix of rational functions is a formidable task. For matrices of your size, it is out of the question. But, do you really need an ironclad mathematical proof that the rank is a certain value? When you evaluate a symbolic matrix at random values for the symbols, the probability that the rank of the numeric matrix differs from the rank of the symbolic matrix is infintesimal---it's like the probability of picking 0 when picking a random real from the interval (-1,1). But you should randomly generate real reals, or real floats, so to speak, rather than the 2-decimal-place ones that you are using. And there's no need to check the numeric rank multiple times. Two is enough. If the numeric rank differs (which might be due to numeric instability) between the two, then try a third.

The curve-fitting commands seem to object to infinite sums. We can get around that problem by making the model a procedure. To deal with the problem of the sum not converging (for x < C), we note that for x = C the sum is exactly Pi^2/6.

restart:
Model:= proc(x,A,B,C)
local n,S;
     S:= evalf(Sum(exp(-n^2*(x-C))/n^2, n= 1..infinity));
     A*x+B*`if`(S::numeric, S, evalf(Pi^2/6))
end proc:

I'm using the same data as Markiyan.
N:= 5:
X:= Vector([1, 2, 3, 4, 5], datatype = float[8]):
Y:= Vector([2, 2, 6, 6, 8], datatype = float[8]):

Command below takes a few seconds.
Out:= Statistics:-NonlinearFit(
     Model, X, Y,
     output= [parametervector, residualstandarddeviation]
):
params:= convert(Out[1],list);
   [1.5912704466501741, 0.1423486016778657, 0.9999710638062892]

std_dev:= Out[2];
                        1.25577015469616

P1:= plot(x-> Model(x,params[]), 0..6):
P2:= plot(
     ['[X[k], Y[k]]' $ 'k'= 1..N],
     style= point, symbol= cross, symbolsize= 20
):
plots:-display([P1,P2], gridlines= false);

NonlinearFit.mw

 

You could select a section of code with the mouse, then from the Edit menu select Execute --> Selection.

Did you try View(img_edge)? That almost seems too obvious an answer. So, do you mean that you can't find the file edge.jpg on your hard drive? It helps if you specify a directory (folder) with the filename. For example,

Write("C:/Users/Carl/desktop/edge.jpg", img_edge);

Your file is probably in the directory (folder) specified by currentdir();

For me, that would be

currentdir();
                  "C:\Program Files\Maple 17"

First 358 359 360 361 362 363 364 Last Page 360 of 384