Joe Riel

9660 Reputation

23 Badges

20 years, 15 days

MaplePrimes Activity


These are replies submitted by Joe Riel

I don't use match much, but couldn't think of a simpler way to do this. I'm surprised that there isn't a more general degree function, one that works on non-polynomials and non-integral powers. Maybe I'm overlooking something.

That works as well.  In fact, you could do the following to create a list of the files names:

files := [cat]("file", 1..3, ".txt");   
               files := ["file1.txt", "file2.txt", "file3.txt"]

That works as well.  In fact, you could do the following to create a list of the files names:

files := [cat]("file", 1..3, ".txt");   
               files := ["file1.txt", "file2.txt", "file3.txt"]

A practical point that we overlooked is accessing these files.  The call to fopen returns a file handle (a posint) that can be used for later reference, rather than the filename.  Thus,

for i to 3 do
  fd[i] := fopen(sprintf("file%d.txt", i), 'WRITE');
end do:

Then you could do

for i to 3 do
    fprintf(fd[i], "Writing to file %d\n", i);
end do;
 
When finished,
 
fclose(seq(fd[i], i=1..3));

 

A practical point that we overlooked is accessing these files.  The call to fopen returns a file handle (a posint) that can be used for later reference, rather than the filename.  Thus,

for i to 3 do
  fd[i] := fopen(sprintf("file%d.txt", i), 'WRITE');
end do:

Then you could do

for i to 3 do
    fprintf(fd[i], "Writing to file %d\n", i);
end do;
 
When finished,
 
fclose(seq(fd[i], i=1..3));

 

I stumbled across that help page while writing my previous comment; it has a nice example. Thanks for the additions to my short list.  I'm curious how many users (presumably power users) have created custom extensions.  I've only used the print extension and type extensions.

I suspect that for backwards compatibility the global name mechanism must be, or at least will be, retained. What other procedures use  that hack?  I can think of diff, expand, convert, and evalf.

I'm more or less with Robert on this.  Years ago I set all sorts of stuff in my init file.  Not so much any more. There are a few reasons for this.  First, the really useful stuff (e.g custom procedures) now get saved into their own libraries. Second, I prefer that my setup be closer to generic.  That way I don't have to chase down weird differences and I can be reasonably confident stuff that works on my box should work elsewhere.

My initialization files now just set libname, using a somewhat tricky approach (I run linux, so one user initialization file must work for all versions of maple; I do this by having it determine the release and read secondary initialization files accordingly).

If you do add a print statement, you might want to disable it when running tty maple.  That can be done with

    if IsWorksheetInterface() then
        printf("Running my init file\n");
    end if:

You could get trickier, I suppose, and have it launch a maplet so that the text doesn't get embedded into the initial blank worksheet that opens, however, doing so means you have to load more packages into Maple.

I'm more or less with Robert on this.  Years ago I set all sorts of stuff in my init file.  Not so much any more. There are a few reasons for this.  First, the really useful stuff (e.g custom procedures) now get saved into their own libraries. Second, I prefer that my setup be closer to generic.  That way I don't have to chase down weird differences and I can be reasonably confident stuff that works on my box should work elsewhere.

My initialization files now just set libname, using a somewhat tricky approach (I run linux, so one user initialization file must work for all versions of maple; I do this by having it determine the release and read secondary initialization files accordingly).

If you do add a print statement, you might want to disable it when running tty maple.  That can be done with

    if IsWorksheetInterface() then
        printf("Running my init file\n");
    end if:

You could get trickier, I suppose, and have it launch a maplet so that the text doesn't get embedded into the initial blank worksheet that opens, however, doing so means you have to load more packages into Maple.

> Student:-Calculus1:-CriticalPoints(5*x^4+3*x^3-3*x^2+x+2,x);

                          1/2 (2/3)                      1/2 (1/3)
              (407 + 40 30   )      + 49 + 3 (407 + 40 30   )
           [- ----------------------------------------------------]
                                            1/2 1/3
                             20 (407 + 40 30   )

Oops, I put in the wrong expression.  I see what you mean.  Use the numeric option so Maple doesn't search for a symbolic solution.

Student:-Calculus1:-CriticalPoints(2*x^5-5*x^4+3*x^3-3*x^2+x+2,x,numeric);
                          [0.2035696006, 1.652979521]
 

> Student:-Calculus1:-CriticalPoints(5*x^4+3*x^3-3*x^2+x+2,x);

                          1/2 (2/3)                      1/2 (1/3)
              (407 + 40 30   )      + 49 + 3 (407 + 40 30   )
           [- ----------------------------------------------------]
                                            1/2 1/3
                             20 (407 + 40 30   )

Oops, I put in the wrong expression.  I see what you mean.  Use the numeric option so Maple doesn't search for a symbolic solution.

Student:-Calculus1:-CriticalPoints(2*x^5-5*x^4+3*x^3-3*x^2+x+2,x,numeric);
                          [0.2035696006, 1.652979521]
 

I'm not sure what you mean.  Did you do

PQ := P*Q

That isn't what you want.  PQ generally means the directed vector from P to Q.  If we undertand X to be the vector from the origin O to point X (i.e. OX), then X = (X-O).  Similarly PQ = Q-P.

Hmm.  That might not be entirely convincing.  More to the point, consider the addition of two vectors, PQ + QR.  That is we add the vector from P to Q to the vector from Q to R.  The result, by vector addition, is the vector from P to R.  So PR = PQ + QR.    To make this work algebraically you need to define PQ as Q-P, etc.  Actually, other definitions are possible, for example, one could define PQ to be P-Q (the negative of the usual), but that isn't so convenient since it means OP = O-P which is more or less the same as -P (O=0) and we'd rather associate the point P with the vector from the origin to P rather than the other way.

I'm not sure what you mean.  Did you do

PQ := P*Q

That isn't what you want.  PQ generally means the directed vector from P to Q.  If we undertand X to be the vector from the origin O to point X (i.e. OX), then X = (X-O).  Similarly PQ = Q-P.

Hmm.  That might not be entirely convincing.  More to the point, consider the addition of two vectors, PQ + QR.  That is we add the vector from P to Q to the vector from Q to R.  The result, by vector addition, is the vector from P to R.  So PR = PQ + QR.    To make this work algebraically you need to define PQ as Q-P, etc.  Actually, other definitions are possible, for example, one could define PQ to be P-Q (the negative of the usual), but that isn't so convenient since it means OP = O-P which is more or less the same as -P (O=0) and we'd rather associate the point P with the vector from the origin to P rather than the other way.

Maple is case sensitive. The name of the procedure is CriticalPoints, not criticalpoints.  You will need to with the Student[Calculus1] package. See the help page.  Click the icon that makes the help page an executable worksheet, then try it out.

Maple is case sensitive. The name of the procedure is CriticalPoints, not criticalpoints.  You will need to with the Student[Calculus1] package. See the help page.  Click the icon that makes the help page an executable worksheet, then try it out.

First 153 154 155 156 157 158 159 Last Page 155 of 195