Joe Riel

9530 Reputation

23 Badges

20 years, 26 days

MaplePrimes Activity


These are answers submitted by Joe Riel

A different way to do this is

add(charfcn[-infinity..-1](x), x = L);

Use y1(t) where you have y1.  What is the y2 doing there?  Why are there different equations for the initial condition y1(0)? Maybe you meant to specify D(y1)(0) (derivative of y1 at t=0)?

W:=add((k^(2*i))*add((e^(j))*w[i,j](r,t),j=0..2),i=0..2):
P:=add((k^(2*i+1))*add((e^(j))*w[i,j](r,t),j=0..2),i=0..2):
expand((k/(2*r))*(diff(W,r)*diff(P,t)-diff(W,t)*diff(P,r)));

                                                                0

Technically that input is but one Maple statement, a call to rtable_scanblock with four arguments. 

The first argument, M, is the rtable (Array, Matrix, etc) that will be scanned. 

The second argument, [rtable_dims(M)], evaluates to a list of ranges and specifies the portion of M to be scanned. In this case it specifies the entire rtable.

The third argument is the procedure that is used for the scanning.  It takes three arguments, val, ind, res.  During the scan, this procedure will be applied to each entry in M.  The first argument, val, will be passed the value stored in M.  The second argument, ind, will be passed a list corresponding to the index of the entry.  The third argument, res, will be passed the result of the previous call to this procedure.  The procedure itself returns a list of two items, index and value of the largest entry found so far.  If the new value is greater than what was stored, its index and value is returned, otherwise the old one is. 

The final argument to rtable_scanblock is the initial value used for the 'res' argument in the previously described procedure. The returned result of the call to rtable_scanblock is the final value of res, which is a list consisting of a list of the indices of the maximum value and the maximum value.

If you want to better understand how this operates, modify the scanning procedure so that it calls the debugger:

rtable_scanblock(M, rtable_dims(M), 
proc(val,ind,res)
DEBUG();
if val > res[2] then [ind,val] else res fi;
end proc, [[1,1],-infinity]);

then you can step through the procedure as it is called by rtable_scanblock.

There is a subtle flaw with this statement.  Can you figure out what it is?  How can it be corrected?

The Maple assignment operator is :=, so do

A[1] := B[3];

 

 

eqs := [23*c1^5 + c1^4 = 13, a*c1^5 = 2]:
x := [c1^5, c1^4]:
feq := map( x -> x = freeze(x), x):
subs(feqs, eqs);
    [23 freeze/R0 + freeze/R1 = 13, a freeze/R0 = 2]
LinearAlgebra:-GenerateMatrix(%, rhs~(feqs));
                             [23    1]  [13]
                             [       ], [  ]
                             [a     0]  [ 2]




Is this what you want?

try
   X := timelimit(1, f(...));
catch "time expired":
   X := _some_other_value;
end try;

The problem specification is lacking in detail.  For example,

  f := () -> 0;

satisfies the requirements in that the output is always an odd or even integer (here it's always even).

Maple's printf command does not provide an explicit repeat flag.  There are a few ways around this. One way is to use ?cat with the $ operator to duplicate the format string:

printf(cat("\n", "-+8.4f%" $ 10), e[5], ... );

Note: I don't know why MaplePrimes inserted newlines when formatting that line.

Another possiblity is to insert the output into a Vector

printf("\n-+8.4f%", < e[5], ... > );

To specify a dos path in Maple, as a string, which is what the ?system command uses, you have to escape the backslashes used as component separators.  That means preceding them with another backslash.  Thus

system("dir c:\\Users\\joe\\maple");

I've done a quick profile of your code. It is immediately apparent that almost all the time is being spent in the calls to CurveFitting:-ArrayInterpolation. While I haven't looked closely enough to be sure, it appears as though you could remove those calls from the loops and pass the vector of x-coordinates (as the second argument), rather than calling the function with a single x-coordinate.  That should save a huge amount of time.

That is, do not do this

for i to 1000 do
    y := ArrayInterpolation(xy_data, x[i]);
    ... y ...
end do;

Instead, do this

y := ArrayInterpolation(xy_data, x);
for i to 1000 do
   ... y[i] ....
end do;

I'd probably do

add(add(`if`(i+j<=8, A[i]*B[j],0),i=1..6),j=1..6);

Use ?evalc:

evalc(Re(5*Dirac(x)+3*I));
                                                5*Dirac(x)

Your computation of the transfer function is correct, however, that is only a partial answer. One way to compute it is to use ?DynamicSystems:

deq := diff(y(t),t,t)+1/4*diff(y(t),t)+y(t)=g(t):
sys := DynamicSystems:-TransferFunction(deq,g,y):
sys:-tf;

I suspect that you want to find the complete solution, using the definition of g and the initial conditions.  That can be done with ?dsolve:

dreq := g(t) = piecewise(t<=5,0,4);
ini := {y(0)=0, D(y)(0)=0};
dsolve( eval({deq},dreq) union ini );


On Linux, Ctrl-Shift-Tab works.  Alternatively, you can do Alt-w #, where # is the tab number.

First 41 42 43 44 45 46 47 Last Page 43 of 114