Carl Love

Carl Love

26361 Reputation

25 Badges

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

MaplePrimes Activity

These are answers submitted by Carl Love

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.

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];

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);


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

                  "C:\Program Files\Maple 17"

You could do something like this:

sineplot:= (Amp,freq,phase)->
     plot(sine(Amp, freq, phase, 't'), 't'= 0 .. 1, title = cat(freq, " sine wave cycles")):


Even if you set all four parameters to 1, the resulting polynomial is not solvable.

I would guess that this is related to the bug discussed in this thread. An interesting difference is that that error was "invalid character in short integer encoding 70 F".

It's hard to diagnose without seeing your code. Please upload it. But it's probably not anything wrong that you are doing; rather it's a bug in Maple. You may be able to work around the bug by changing the value of Digits. In the other case, Digits:= 20 worked.

Simply use allvalues(%). This will divide the right side of the expression into two parts, one for each solution of the quadratic. After that, you'll need to work with the parts separately.

@verdin Ahh, I see. I think that what you want is the ?debugger. In particular, see ?stopat.

You can work with the RootOf symbolically. But, from your title, I think that your goal is to find where the gradient of f is 0. To do that, you should solve all three derivatives for 0 simultaneously:

solve({D[1](f)(a,b,c), D[2](f)(a,b,c), D[3](f)(a,b,c)}, {a,b,c});

Or, to generalize the number of variables:

V:= [a,b,c]:
solve({'D[k](f)(V[])' $ 'k'= 1..nops(V)}, {V[]});

Use command readstat("...") or readline(-1). This will wait for user input before continuing. You can ignore the content of the input if you want.

Note that your sequence has 11 elements, not 10. There are several ways to do what you want.

for j to 11 do  i:= -0.5+(j-1)*0.1; array1[j]:= sin(i) end do:

array1:= Vector(11, j-> sin(-0.5+(j-1)*0.1)):

array1:= <seq(sin(i), i= -0.5..0.5, 0.1)>:

To omit the zero, it is easiest to start with the first array and then exclude the middle index. You need 10 elements.

array2:= array1[[1..5, 7..11]]:

array2:= array1[[1..5, -5..-1]]:


They are not equal. What makes you think that they are? There are three plus/minus signs that switch among the four roots.

Sorry, I didn't read your post carefully at first, specifically the x in the example call Test(f(x)), until Markiyan pointed out my error. So, here's my corrected Answer.  The original answer is below.

Test:= (f::patfunc(anything,nothing))-> subsop(1= 10, f):


The (anything,nothing) typespec is to restrict Test to functions of one argument. That can be easily changed if you want.
Error, invalid input: Test expects its 1st argument, f, to be of type patfunc(anything, nothing), but received f(x, y)

If you want the following to return f(g(10)) instead, I can change it. Let me know.

My erroneous original answer:

You do it just the way that you just did it:

Test:= proc(f) f(10) end proc:
Test(x-> x^2);

(You can include return in your procedure if you want. I omitted it because it is superfluous in the last statement of a procedure.)

Tables are what Maple calls a "mutable" data structure. This is a difficult concept to understand.  Most data structures (such as lists and sets) are not mutable. Mutable data structures cannot be compared for equality or membership by any of the standard commands. They would have to be checked elementwise or with verify. The equality and membership tests will check for identity of tables though. Another option for comparisons is to convert tables to lists.

Here are several examples. Please study these very carefully and let me know if you have any questions. I emphasize again that this is a difficult concept to learn.




     table([a=0,b=0,c=0,d=0]), table([a=6,b=1,c=2,d=0]),
     table([a=6,b=5,c=5,d=7]), table([a=7,b=1,c=2,d=0]),

table( [( c ) = 0, ( d ) = 0, ( b ) = 0, ( a ) = 0 ] ), table( [( c ) = 2, ( d ) = 0, ( b ) = 1, ( a ) = 6 ] ), table( [( c ) = 5, ( d ) = 7, ( b ) = 5, ( a ) = 6 ] ), table( [( c ) = 2, ( d ) = 0, ( b ) = 1, ( a ) = 7 ] ), table( [( c ) = 8, ( d ) = 8, ( b ) = 8, ( a ) = 8 ] )

is(T1 = table([a=0,b=0,c=0,d=0]));


T:= {
     [{a,b,c,d}, T1, 8], [{a,b,c,d}, T2, 8], [{a,b,c,d}, T3, 8],
     [{a,b,c,d}, T4, 8], [{a,b,c,d}, T5, 8]

member([{a,b,c,d}, T1, 8], T);


member([{a,b,c,d}, table([a=0,b=0,c=0,d=0]), 8], T);


Table to list conversion procedure:

TtoL:= ex-> subsindets(subsindets(ex, name(table), op), table, x-> op(2,x));

proc (ex) options operator, arrow; subsindets(subsindets(ex, name(table), op), table, proc (x) options operator, arrow; op(2, x) end proc) end proc


{[{a, b, c, d}, [c = 0, d = 0, b = 0, a = 0], 8], [{a, b, c, d}, [c = 2, d = 0, b = 1, a = 6], 8], [{a, b, c, d}, [c = 2, d = 0, b = 1, a = 7], 8], [{a, b, c, d}, [c = 5, d = 7, b = 5, a = 6], 8], [{a, b, c, d}, [c = 8, d = 8, b = 8, a = 8], 8]}

member(TtoL([{a,b,c,d}, table([a=0,b=0,c=0,d=0]), 8]), TtoL(T));





First 356 357 358 359 360 361 362 Last Page 358 of 381