Carl Love

Carl Love

26488 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

It took me awhile to finish this. It ended up being about 300 lines. This is the first multi-threaded application I've written, other than just using Threads:-Map or Threads:-Seq. But it's done: A fully functional multi-threaded combinations filter. Suggestions for improvement are most welcome.  In particular, it would be great if the processor utilization could be increased.


ComboFilter:= module()
(*________________________________________________________________________
This is a multi-threaded combinations filter.  It generates all k-subsets
of an n-set, applies a user-specified filter to them, and writes the
remaining combinations to a file using a user-specified format.  It is
intended to be used in situations where it is not feasible to represent all
combinations in memory at once (the same situations where one would use
combinat:-nextcomb).  The generation, filtering, and writing are handled
in separate threads.  The memory usage is about 7 times (very rough
estimate) the memory needed for a list of combinations of length 'blocksize'
(see the Parameters).

Parameters: See comment at the ModuleApply.
Returns: NULL: The output goes to a file.
````````````````````````````````````````````````````````````````````````````*)
uses  
    M= Threads:-Mutex,
    LOCK= Threads:-Mutex:-Lock,
    UNLOCK= Threads:-Mutex:-Unlock,
    CV= Threads:-ConditionVariable,
    WAIT= Threads:-ConditionVariable:-Wait,
    SIGNAL= Threads:-ConditionVariable:-Signal
;
local
    GenerateSignal,
    FilterBuffer, FilterBufferLock, FilterSignal,
    WriteBuffer, WriteBufferLock, WriteSignal,
    Combo,

    # Some macros to shorten the ubiquitous userinfo statements
    _:= userinfo,
    C:= (5, ComboFilter),
    q:= (C, "Acquired."),
    w:= s-> (C, sprintf("Waiting for %s.", s)),
    u:= s-> (C, sprintf("Unlocked %s lock.", s)),
    s:= s-> (C, sprintf("%s signalled.", s)),
    longbuffer:= B-> `if`(nops(B) > 9, [B[1..9][], `...`], B),    
(*_________________________________________________________________________
Generate is the first of the three main threads. It uses combinat:-nextcomb
to generate combinations and then places them in FilterBuffer, a
list shared with thread Filter and access-controlled by
FilterBufferLock. It sends FilterSignal to Filter and waits on
GenerateSignal from Filter.

Parameters: n::posint, blocksize::posint, preciseorder::truefalse (see
comment at ModuleApply).
Returns: NULL
```````````````````````````````````````````````````````````````````````````*)
(*
#**************************************************************************#
In each of the three main procedures, code in a comment box (like this)    #
is the main algorithm; everything else is for thread synchronization.        #
#**************************************************************************#*)
Generate:= proc(n::posint, blocksize::posint, preciseorder::truefalse)
    local buffer, more:= true, i, j;
        while more do
            #******************************************************#
            buffer:= table();                                #
            if preciseorder then                            #
                for j to blocksize do                        #
                    buffer[j]:= Combo;                        #
                    Combo:= combinat:-nextcomb(Combo, n);        #
                    if Combo = FAIL then  #End                #
                        more:= false;                         #
                        break                            #
                    end if                                #
                end do;                                       #
                buffer:= [seq](buffer[i], i= 1..min(j, blocksize))#                
            else                                             #
                to blocksize do                                 #
                    buffer[Combo]:= ();                        #
                    Combo:= combinat:-nextcomb(Combo, n);        #
                    if Combo = FAIL then  #End                  #
                        more:= false;                         #
                        break                                 #
                    end if                                     #
                end do;                                    #
                buffer:= [indices](buffer, ':-nolist')            #
            end if;                                        #
            #******************************************************#
            _(w("FB lock"));  
            LOCK (FilterBufferLock);_(q);
                # Wait for Filter to empty the buffer.
                while FilterBuffer <> () do
                    SIGNAL (FilterSignal);_(s("Filter"));
                    _(w("GenerateSignal"));  
                    WAIT (GenerateSignal, FilterBufferLock);_(q)
                end do;
                #************************#
                FilterBuffer:= buffer;    #
                #************************#
                _(C, longbuffer(FilterBuffer));
                SIGNAL (FilterSignal);_(s("Filter"));
            UNLOCK (FilterBufferLock);_(u("FB"))
        end do;
        
        #Send final signal to Filter thread, so that it can end.
        _(w("final lock"));  
        LOCK (FilterBufferLock);_(q);
            # Wait for Filter to empty the buffer.
            while FilterBuffer <> () do
                SIGNAL (FilterSignal);_(s("Filter"));
                _(w("GenerateSignal."));
                WAIT (GenerateSignal, FilterBufferLock);_(q)
            end do;        
            FilterBuffer:= [];
            SIGNAL (FilterSignal);_(s("Filter"));
        UNLOCK (FilterBufferLock);_(u("FB"));    
        [][]    
    end proc,
(*_____________________________________________________________________
Filter is the second of the three main threads. It uses Threads:-Map
to apply a user-specified filter to the combinations in FilterBuffer
and then places the remaining combinations in WriteBuffer, a list
shared with Write and accessed-controlled by WriteBufferLock. It sends
GenerateSignal to Generate and waits on FilterSignal from Generate; it
sends WriteSignal to Write and waits on FilterSignal from Write.

Parameter: filter::procedure (see comment at ModuleApply)
Returns: NULL
```````````````````````````````````````````````````````````````````````*)
    Filter:= proc(filter::procedure)
    local buffer, more:= true;
        while more do
            _(w("FB lock"));  
            LOCK (FilterBufferLock);_(q);
                while FilterBuffer = () do
                    SIGNAL (GenerateSignal);_(s("Generate"));
                    _(w("FilterSignal"));  
                    WAIT (FilterSignal, FilterBufferLock);_(q)
                end do;
                #******************************************************#
                if FilterBuffer = [] then                         #
                    more:= false;                                 #
                    buffer:= "empty"  #Signal Write process to end.     #
                else                                          #
                    buffer:= FilterBuffer                         #
                end if;                                        #
                #******************************************************#
                FilterBuffer:= (); #Signal to Generate
            UNLOCK (FilterBufferLock);_(u("FB"));
               #******************************************#
            if buffer <> "empty" then                  #
                buffer:= Threads:-Map(filter, buffer) #
            end if;                                     #
            #******************************************#
            _(w("WB lock"));  
            LOCK (WriteBufferLock);_(q);
                # Wait for WriteBuffer to empty.
                while WriteBuffer <> () do
                    SIGNAL (WriteSignal);_(s("Write"));
                    _(w("FilterSignal"));  
                    WAIT (FilterSignal, WriteBufferLock);_(q);
                end do;
                _(C, longbuffer(buffer));
                #************************#
                WriteBuffer:= buffer;    #
                #************************#
                SIGNAL (WriteSignal);_(s("Write"));
            UNLOCK (WriteBufferLock);_(u("WB"))
        end do;
        [][]
    end proc,
(*__________________________________________________________________________
Write is the third of the three main threads.  It writes the contents of
WriteBuffer to a file using a user-specified formatting procedure.  It waits
on WriteSignal from Filter and sends FilterSignal to Filter.

Parameters: filename::string, format::procedure (see comment at
ModuleApply).
Returns: NULL: Output goes to a file.
`````````````````````````````````````````````````````````````````````````````*)
    Write:= proc(format::procedure)
    local
        buffer,
        OutFile:= FileTools:-Text:-Open(Filename)
    ;
        do
            _(w("WB lock"));
            LOCK (WriteBufferLock);_(q);
                while WriteBuffer = () do
                    SIGNAL (FilterSignal);_(s("Filter"));
                    _(w("WriteSignal"));  
                    WAIT (WriteSignal, WriteBufferLock);_(q);
                end do;

                if WriteBuffer = "empty" then  #End
                    UNLOCK (WriteBufferLock);
                    break  
                end if;
                #************************#            
                buffer:= WriteBuffer;    #
                #************************#
                WriteBuffer:= (); #Signal to Filter to fill it.
            UNLOCK (WriteBufferLock);_(u("WB"));
               #***********************#
            format(OutFile, buffer) #
            #***********************#
        end do;
        [][]
    end proc,
(*________________________________________________________________________
ModuleApply: Generates first combination, initiates all the Threads, and
waits.

Parameters:
n::posint: The set that the combinations are drawn from
k::posint: The size of a combination.

Keyword parameters (default values are specified with :=):

blocksize::posint:= 1:
The number of combinations to be treated as one "block". It does not need to
be a divisor of binomial(n,k); if necessary, a shorter final block will be
used.

filter::procedure:= C-> C:
The procedure used to filter the combinations.  It should be a procedure
such that if L is a list of combinations, then map(filter, L) yields the
combinations that are to be kept.  This is achieved by the procedure
returning either its input or NULL.  The default filter keeps everything.

filename::string:= cat(currentdir(), kernelopts(diresep), "Combos.m"):
The name of the output file.

format::procedure:= (F,B)-> fprintf(F, "%m", B):
The procedure used to write one block of output to the file. The procedure
takes two arguments: F, the file pointer, and B, a list (possibly empty!)
of combinations. The default uses Maple's ".m" format, which is very
quick to read and write but is not human readable while it's in the file.

preciseorder::truefalse:= false:
Boolean option that specifies that the combinations be placed in the file
in their canonical order. This is slightly less efficient, so the default
is false.
`````````````````````````````````````````````````````````````````````````*)                
    ModuleApply:= proc(
        n::posint, k::posint,
        {
            blocksize::posint:= 1,
             filter::procedure:= (C-> C),
             format::procedure:= ((F,B)-> fprintf(F, "%m", B)),
             preciseorder::truefalse:= false
         }
    )    
         GenerateSignal:= CV:-Create();
         FilterBuffer:= [][];  
         FilterBufferLock:= M:-Create();  FilterSignal:= CV:-Create();
        WriteBuffer:= [][];  
        WriteBufferLock:= M:-Create();  WriteSignal:= CV:-Create();
        
        Combo:= combinat:-firstcomb(n, k);
        try        
            Threads:-Wait(
                map(
                    Threads:-Create,
                    [
                        'Generate(n, blocksize, preciseorder)',
                        'Filter(filter)',
                        'Write(format)'
                    ]
                )[]
            )
        catch: error
        finally
            FileTools:-Text:-Close(Filename);
            CV:-Destroy(GenerateSignal, WriteSignal, FilterSignal);
            M:-Destroy(WriteBufferLock, FilterBufferLock);
        end try;        
        [][]
    end proc
;
export
    # The default name of the output file. Change it by assigning to
    # the module export: ComboFilter:-Filename:= ...;
    Filename:= cat(currentdir(), kernelopts(':-dirsep'), "Combos.m"),
(*__________________________________________________________________________
Reader is a little submodule for reading the output files assuming that the
default format was used.
````````````````````````````````````````````````````````````````````````````*)
    Reader:= module()
    local
        File,
        (*____________________________________
          The ModuleApply just opens the file.
        ```````````````````````````````````````*)
        ModuleApply:= proc()
            File:= FileTools:-Text:-Open(Filename);
            [][]
        end proc
    ;
    export
        (*____________________________________________________________________
          Read() returns the contents of one block, or NULL if at end-of-file.
        ``````````````````````````````````````````````````````````````````````*)
        Read:= proc()
            if FileTools:-AtEndOfFile(File) then
                _(1, ComboFilter, "At end of file.");
                FileTools:-Text:-Close(File);
                [][]
            else
                fscanf(File, "%m")[]
            end if
        end proc
    ;
    end module
;
end module;

   
   

module () local GenerateSignal, FilterBuffer, FilterBufferLock, FilterSignal, WriteBuffer, WriteBufferLock, WriteSignal, Combo, _, C, q, w, u, s, longbuffer, Generate, Filter, Write, ModuleApply; export Filename, Reader; end module

To load the module, place cursor in the Code Edit Region above, right-click, and select Execute Code.

(**)

infolevel[ComboFilter]:= 5:

Set name of the output file.

(**)

ComboFilter:-Filename:= "C:/Users/Carl/Combos.m":

(**)

binomial(99, 4);

3764376

(**)

CodeTools:-Usage(ComboFilter(99, 4, blocksize= 2^20, filter= (C-> C)));

Filter: Waiting for FB lock.

Filter: Acquired.
Filter: Generate signalled.
Filter: Waiting for FilterSignal.
Write: Waiting for WB lock.
Write: Acquired.
Filter: Acquired.
Write: Filter signalled.
Write: Waiting for WriteSignal.
Filter: Generate signalled.
Filter: Waiting for FilterSignal.

Generate: Waiting for FB lock.
Generate: Acquired.

Generate: [{3 73 90 95} {3 29 43 88} {3 24 68 82} {2 68 71 96} {2 63 89 90} {1 13 74 89} {1 69 75 88} {1 13 49 92} {1 35 37 84} ...]
Generate: Filter signalled.
Generate: Unlocked FB lock.
Filter: Acquired.
Filter: Unlocked FB lock.

Filter: Waiting for WB lock.
Filter: Acquired.
Filter: [{3 73 90 95} {3 29 43 88} {3 24 68 82} {2 68 71 96} {2 63 89 90} {1 13 74 89} {1 69 75 88} {1 13 49 92} {1 35 37 84} ...]
Filter: Write signalled.
Filter: Unlocked WB lock.
Filter: Waiting for FB lock.
Filter: Acquired.
Write: Acquired.
Filter: Generate signalled.
Filter: Waiting for FilterSignal.
Write: Unlocked WB lock.

Write: Waiting for WB lock.
Write: Acquired.
Write: Filter signalled.
Write: Waiting for WriteSignal.
Filter: Acquired.
Filter: Generate signalled.
Filter: Waiting for FilterSignal.

Generate: Waiting for FB lock.
Generate: Acquired.
Generate: [{9 14 90 97} {13 26 51 72} {13 25 75 83} {13 25 31 81} {10 21 23 68} {12 27 81 89} {12 17 59 74} {10 15 31 43} {11 61 91 95} ...]
Generate: Filter signalled.
Generate: Unlocked FB lock.
Filter: Acquired.
Filter: Unlocked FB lock.

Filter: Waiting for WB lock.
Filter: Acquired.
Filter: [{9 14 90 97} {13 26 51 72} {13 25 75 83} {13 25 31 81} {10 21 23 68} {12 27 81 89} {12 17 59 74} {10 15 31 43} {11 61 91 95} ...]
Filter: Write signalled.
Filter: Unlocked WB lock.
Filter: Waiting for FB lock.
Filter: Acquired.
Filter: Generate signalled.
Filter: Waiting for FilterSignal.
Write: Acquired.
Write: Unlocked WB lock.

Write: Waiting for WB lock.
Write: Acquired.
Write: Filter signalled.
Write: Waiting for WriteSignal.
Filter: Acquired.
Filter: Generate signalled.
Filter: Waiting for FilterSignal.

Generate: Waiting for FB lock.
Generate: Acquired.
Generate: [{24 39 47 53} {21 47 62 91} {23 62 70 95} {30 33 35 56} {29 52 63 87} {20 40 41 71} {23 51 81 89} {29 52 57 74} {23 37 55 94} ...]
Generate: Filter signalled.
Generate: Unlocked FB lock.
Filter: Acquired.
Filter: Unlocked FB lock.

Filter: Waiting for WB lock.
Filter: Acquired.
Filter: [{24 39 47 53} {21 47 62 91} {23 62 70 95} {30 33 35 56} {29 52 63 87} {20 40 41 71} {23 51 81 89} {29 52 57 74} {23 37 55 94} ...]
Filter: Write signalled.
Filter: Unlocked WB lock.
Filter: Waiting for FB lock.
Filter: Acquired.
Filter: Generate signalled.
Filter: Waiting for FilterSignal.
Write: Acquired.
Write: Unlocked WB lock.

Write: Waiting for WB lock.
Write: Acquired.
Write: Filter signalled.
Write: Waiting for WriteSignal.
Filter: Acquired.
Filter: Generate signalled.
Filter: Waiting for FilterSignal.

Generate: Waiting for FB lock.
Generate: Acquired.
Generate: [{62 67 78 80} {39 64 85 98} {44 50 53 75} {39 48 65 68} {37 38 52 56} {57 69 70 74} {57 65 68 92} {56 64 79 92} {55 67 78 91} ...]
Generate: Filter signalled.
Generate: Unlocked FB lock.
Generate: Waiting for final lock.
Filter: Acquired.
Generate: Acquired.
Generate: Filter signalled.
Generate: Unlocked FB lock.
Filter: Unlocked FB lock.

Filter: Waiting for WB lock.
Filter: Acquired.
Filter: [{62 67 78 80} {39 64 85 98} {44 50 53 75} {39 48 65 68} {37 38 52 56} {57 69 70 74} {57 65 68 92} {56 64 79 92} {55 67 78 91} ...]
Filter: Write signalled.
Filter: Unlocked WB lock.
Write: Acquired.
Filter: Waiting for FB lock.
Filter: Acquired.
Filter: Unlocked FB lock.
Filter: Waiting for WB lock.
Filter: Acquired.
Filter: empty
Filter: Write signalled.
Filter: Unlocked WB lock.
Write: Unlocked WB lock.

Write: Waiting for WB lock.
Write: Acquired.
memory used=7.27GiB, alloc change=368.00MiB, cpu time=2.59m, real time=2.02m

Read the output file back in (just as an example):

(**)

ComboFilter:-Reader():

(**)

L:= []:

(**)

while L <> () do
     L:= ComboFilter:-Reader:-Read():
     if L <> () then
          print(nops(L));
          print(L[1..8])
     end if
od:

1048576

[{3, 73, 90, 95}, {3, 29, 43, 88}, {3, 24, 68, 82}, {2, 68, 71, 96}, {2, 63, 89, 90}, {1, 13, 74, 89}, {1, 69, 75, 88}, {1, 13, 49, 92}]

1048576

[{9, 14, 90, 97}, {13, 26, 51, 72}, {13, 25, 75, 83}, {13, 25, 31, 81}, {10, 21, 23, 68}, {12, 27, 81, 89}, {12, 17, 59, 74}, {10, 15, 31, 43}]

1048576

[{24, 39, 47, 53}, {21, 47, 62, 91}, {23, 62, 70, 95}, {30, 33, 35, 56}, {29, 52, 63, 87}, {20, 40, 41, 71}, {23, 51, 81, 89}, {29, 52, 57, 74}]

618648

[{62, 67, 78, 80}, {39, 64, 85, 98}, {44, 50, 53, 75}, {39, 48, 65, 68}, {37, 38, 52, 56}, {57, 69, 70, 74}, {57, 65, 68, 92}, {56, 64, 79, 92}]

Read: At end of file.

(**)

 


Download Para_Combos.mw

(I've only looked at the Gauss-Seidel; I assume that the Jacobi has the same problem.)

The problem is that x, which has the value Vector([0,0,0]), is passed in as an argument to parameter x. The first line of the procedure is x:= Vector(n). Since x has a value, this becomes Vector([0,0,0]):= Vector(3). You have something that cannot be assigned to on the left side of :=, hence the error message. 

There were a few other errors in your procedure, which I cleaned up. Here it is:

 

Método de Gauss-Seidel

gauss_seidel:= proc(A::Matrix, b::Vector, x_init::Vector, e::float)
local
     i, j, soma,
     n:= LinearAlgebra:-Dimension(b),
     x:= copy(x_init),
     x0:= Vector(n, fill= infinity),
     g:= Vector(n),
     C:= Matrix(n)
;
     for i to n do
          g[i]:= b[i]/A[i,i];
          for j to n do
               if i=j then
                    C[i,j]:= 0
               else
                    C[i,j]:= -A[i,j]/A[i,i]
               end if
          end do
     end do;
     while LinearAlgebra:-Norm(x - x0) > e do
          x0:= copy(x);
          for i to n do
               soma:=0;
               for j to n do
                    soma:= soma + C[i,j]*x[j]
               end do;
               x[i]:= soma + g[i]
          end do
     end do;
     x
end proc:

A:= Matrix([[4,1,1],[-2,5,1],[3,1,6]]);

A := Matrix(3, 3, {(1, 1) = 4, (1, 2) = 1, (1, 3) = 1, (2, 1) = -2, (2, 2) = 5, (2, 3) = 1, (3, 1) = 3, (3, 2) = 1, (3, 3) = 6})

b:= Vector([5,0,-6.5]);

b := Vector(3, {(1) = 5, (2) = 0, (3) = -6.5})

(**)

x:= Vector([0,0,0]);

x := Vector(3, {(1) = 0, (2) = 0, (3) = 0})

gauss_seidel(A, b, x, 0.001);

Vector(3, {(1) = 1.49999631754557, (2) = .999955463867186, (3) = -1.99999073608398})

Compare with known solution:

LinearAlgebra:-LinearSolve(A,b);

Vector(3, {(1) = 1.50000000000000, (2) = 1., (3) = -2.})

(**)

 

NULL

 

Download Método_de_Gauss-Sei.mw

There is still the possibility of an infinite loop if the errors are never less than e.

Hopefully you can now fix the Jacobi on your own.

I assume this work is for educational value. If instead it is for production use, there are much more efficient ways to do it.

You need to use different loop index variables for your inner and outer loops. You have i for both.

Bonus: Here's your procedure in a more-standard style. Note that the outer loop doesn't even need an index variable.

randomDeck:= proc(n::posint)
local
     deck:= [seq](1..52),
     randomDeck:= [],
     i,
     succes:= 0
;
     to n do
          randomDeck:= Statistics:-Shuffle(deck);
          for i to nops(deck) do
               if deck[i] = randomDeck[i] then
                    succes:= succes + 1;
                    break
               end if
          end do
     end do;
     succes
end proc:

In both plots, change g[k] to rhs(g[k]). In the first plot, change plot(F(x), x= 1..2) to plot(F, 1..2).

You can extend the power of the expand command by adding a simple procedure:

`expand/.`:= proc()
local p,a;
     if membertype(`+`, [args], 'p') then
          add(thisproc(args[1..p-1], a, args[p+1..-1]), a= args[p])
     else
          `.`(args)
     end if
end proc:

ex:= {[1]}.{[2]}.({[2, 3]}-{[3, 2]}).({[1, 3]}-{[3, 1]}):
expand(ex);

@Michael_Ormstrup There are several easy ways to do that, but they all involve changing the way the arguments are input. If that is an option for you, let me know, and I'll expand on it. The problem with the way that the parameters are currently is that if you omit f2, giving it a default value 0, then a takes the place of f2. And who's to say that that doesn't mean that the user intended for f2 to be the horizontal line y = a?

Now here's a slightly-less-than-easy way to make 0 the default value for f2 and keep the user interface exactly the way it is now:

  1. Change parameters 2 through 4 to different names: That is, change proc(f1,f2,a,b, {...}) to proc(f1,F2,A,B, {...}).
  2. Add f2, a, b to the local variables.
  3. Make the first actual statement (after the local declaration):
    (f2,a,b):= `if`(_params['B'] = NULL, [0,F2,A], [F2,A,B])[];

But, I recommend that you clean up the way that the arguments are passed, which would involve making a small change from the user's perspective.

d:= unapply(d(B), B):

D(d)(0);

Ordinarily, D would work on a procedure in exactly the way that you tried to use it. But, in this case it doesn't know what to do about the Determinant.

I don't think that you'll get any answer, or at least any useful answer, from solve except for certain specific values of R. For example,

solve(eval([Er1, Ez1], R=z1), {z1, rho1});

Although it is possible to convert a RootOf to a numeric solution, I recommend that you use fsolve directly; like this:

Sol:= r-> fsolve(eval([Er1, Ez1], R= r), {z1=0, rho1= 4/7}):
Sol(.3);

Z1:= r-> eval(z1, Sol(r)):
Rho1:= r-> eval(rho1, Sol(r)):
plot([Rho1, Z1], 0.1..2);

I am not a Mathematica user, so I can't make a comparison, but you can check Maple's ?Grid package and see for yourself if it's comparable. It was introduced in Maple 15.

The line in your codeyvals := op(2, pts1[i]), op(2, pts2[i]);needs to be changed toyvals := pts1[i,2], pts2[i,2];
As to why there was a change, I don't have the older Maple to check, so I can't be sure of this: I think that the points data in the plots in the older Maple were in listlist (or list of lists) form, and now they are in Matrix form. Using op to index into a Matrix doesn't work.

In addition to the other Answers, note that the capitalization of Maple commands matters. You mentioned linsolve, but your screen shot shows that you used Linsolve. They are different commands.

Like Jerome, I recommend that you use LinearSolve in the LinearAlgebra package.

If your function is a polynomial, then you can do this:

f:= randpoly([a,x]);

solve({diff(f,x)>0, x>0, a>0}, {x}, parametric= full, parameters= {a});

 

 

 

See ?solve,parametric and ?solve,ineq .

If your function is not a polynomial, then you should post it: There's a good chance that an ad hoc technique can be worked out.

If f(x,y,t) is an unevaluated function call, then you can do

e:= eval(e, y= NULL);

But if f is a defined function, then you'll need to provide a more-specific example before the question can be answered.

Here are your two plot commands:

plot([ns, r, t = 10^11..10^15], 0.8..1.2, 0..1);
plot([ns, r, t = 10^11..10^17], 0.8..1.2, 0..1);

So, the second plot has a range 100 times larger than the first, yet you are using the same view window. Both plots use 210 points for the whole range. So in the second plot, those points are spaced out much more.

It seems that when the assignment to a variable occurs in a Maple-language procedure, that variable does not appear in the Variables sidebar in the Standard GUI. But if the assignment occurs in a kernel procedure, then it will appear. For example,

P:= proc(x) x:= 3 end proc:
p(y);

                                              3
y;

                                     3

But y does not appear in the Variables list.

The procedures that you used, quo and rem, are Maple-language procedures; whereas iquo and irem are kernel procedures. So,

iquo(9, 3, 'r');

and now r appears in the list.

 

First 345 346 347 348 349 350 351 Last Page 347 of 382