Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

How generate all possible samples of size n = 2 that can be drawn with replacement from this population [0,1,2]?

It occurs to me using these commands.

 restart; with(combinat); choose([0, 0, 1, 1, 2, 2], 2);

        [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]]

 permute([0, 0, 1, 1, 2, 2], 2);

[[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]

I am planning to use the "schedual task" in windows to try to launch
maple in the background (run under some different user account)
to do some computations.

For this pupose I have designed a little counter that is located in the
Start up code region:

for i from 0 to 100 do
if DataTable1(1, 1)=i then DataTable1(1,1):=i+1:  break; end if:
end do:

the DataTale will tell me how many times the worksheet has been opened
just to check...

Is there any way to reverse an axis in the plot command? I solved the baristochrone problem as 
a school project,but I did it using an upside-down Y axis. Of course, when I try to make a graph with
my solution, I'm getting a regular cycloid instead of an inverted one, since I was using a 
reverted Y axis when solving the problem. 

Help would be very appreciated as I couldn,t find anything on the subject.

Here is a short wrapper which automates repeated calls to the DirectSearch 2 curve-fitting routine. It offers both time and repetition (solver restart) limits.

The global optimization package DirectSearch 2 (see Application Center link, and here) has some very nice features. One aspect which I really like is that it can do curve-fitting: to fit an expression using tabular data. By this, I mean that it can find optimal values of parameters present in an expression (formula) such that the residual error between that formula and the tabular data is minimized.

Maple itself has commands from the CurveFitting and Statistics packages for data regression, such as NonlinearFit, etc. But those use local optimization solvers, and quite often for the nonlinear case one may need a global optimizer in order to produce a good fit. The nonlinear problem may have local extrema which are not even close to being globally optimal or provide a close fit.

Maplesoft offers the (commercially available) GlobalOptimization package as an add-on to Maple, but its solvers are not hooked into those mentioned curve-fitting commands. One has to set up the proper residual-based objective function onself in order to use this for curve-fitting, and some of the bells and whistles may be harder to do.

So this is why I really like the fact that the DirectSearch 2 package has its own exported commands to do curve-fitting, integrated with its global solvers.

But as the DirectSearch package's author mentions, the fitting routine may sometimes exit too early. Repeat starts of the solver, for the very same parameter ranges, can produce varying results due to randomization steps performed by the solver. This post is branched off from another thread which involved such a problematic example.

Global optimization is often a dark art. Sometimes one may wish to simply have the engine work for 24 hours, and produce whatever best result it can. That's the basic enhancement this wrapper offers.

Here is the wrapper, and a few illustrative calls to it on the mentioned curve-fitting example that show informative  progress status messages, etc. I've tried to make the wrapper pretty generic. It could be reused for other similar purposes.

Other improvements are possible, but might make it less generic. A target option is possible, where attainment of the target would cause an immediate stop. The wrapper could be made into an appliable module, and the running best result could be stored in a module local so that any error (and ensuing halt) would not wipe out the best result from potentially hours and hours worth of conputation.

restart:
randomize():

repeater:=proc(  funccall::uneval
               , {maxtime::numeric:=60}
               , {maxiter::posint:=10}
               , {access::appliable:=proc(a) SFloat(a[1]); end proc}
               , {initial::anything:=[infinity]}
              )
          local best, current, elapsed, i, starttime;
            starttime:=time[real]();
            elapsed:=time[real]()-starttime;
            i:=1; best:=[infinity];
            while elapsed<maxtime and i<=maxiter do
              userinfo(2,repeater,`iteration `,i);
              try
                timelimit(maxtime-elapsed,assign('current',eval(funccall)));
              catch "time expired":
              end try;
              if is(access(current)<access(best)) then
                best:=current;
                userinfo(1,repeater,`new best `,access(best));
              end if;
              i:=i+1;
              elapsed:=time[real]()-starttime;
              userinfo(2,repeater,`elapsed time `,elapsed);
            end do;
            if best<>initial then
              return best;
            else
              error "time limit exceeded during first attempt";
            end if;
          end proc:


X := Vector([seq(.1*j, j = 0 .. 16), 1.65], datatype = float): 

Y := Vector([2.61, 2.62, 2.62, 2.62, 2.63, 2.63, 2.74, 2.98, 3.66,
             5.04, 7.52, 10.74, 12.62, 10.17, 5, 2.64, 11.5, 35.4],
            datatype = float):

F := a*cosh(b*x^c*sin(d*x^e));

                                    /   c    /   e\\
                         F := a cosh\b x  sin\d x //

infolevel[repeater]:=2: # or 1, or not at all (ie. 0)
interface(warnlevel=0): # disabling warnings. disable if you want.

repeater(DirectSearch:-DataFit(F
                      , [a=0..10, b=-10..10, c=0..100, d=0..7, e=0..4]
                      , X, Y, x
                      , strategy=globalsearch
                      , evaluationlimit=30000
                              ));
repeater: iteration  1
repeater: new best  9.81701944539358706
repeater: elapsed time  15.884
repeater: iteration  2
repeater: new best  2.30718902535293857
repeater: elapsed time  22.354
repeater: iteration  3
repeater: new best  0.627585701120743822e-4
repeater: elapsed time  30.777
repeater: iteration  4
repeater: elapsed time  47.959
repeater: iteration  5
repeater: new best  0.627585700905294148e-4
repeater: elapsed time  55.221
repeater: iteration  6
repeater: elapsed time  60.009
 [0.0000627585700905294, [a = 2.61748237902808, b = 1.71949329097179, 

   c = 2.30924401405164, d = 1.50333106110324, e = 1.84597267458055], 4333]


# without userinfo messages printed
infolevel[repeater]:=0:
repeater(DirectSearch:-DataFit(F
                      , [a=0..10, b=-10..10, c=0..100, d=0..7, e=0..4]
                      , X, Y, x
                      , strategy=globalsearch
                      , evaluationlimit=30000
                              ));

 [0.0000627585701341043, [a = 2.61748226209478, b = 1.71949332125427, 

   c = 2.30924369227236, d = 1.50333090706676, e = 1.84597294290477], 6050]


# illustrating early timeout
infolevel[repeater]:=2:
repeater(DirectSearch:-DataFit(F
                      , [a=0..10, b=-10..10, c=0..100, d=0..7, e=0..4]
                      , X, Y, x
                      , strategy=globalsearch
                      , evaluationlimit=30000
                              ),
         maxtime=2);

repeater: iteration  1
repeater: elapsed time  2.002
Error, (in repeater) time limit exceeded during first attempt

# illustrating iteration limit cutoff
infolevel[repeater]:=2:
repeater(DirectSearch:-DataFit(F
                      , [a=0..10, b=-10..10, c=0..100, d=0..7, e=0..4]
                      , X, Y, x
                      , strategy=globalsearch
                      , evaluationlimit=30000
                              ),
         maxiter=1);

repeater: iteration  1
repeater: new best  5.68594272127419575
repeater: elapsed time  7.084
 [5.68594272127420, [a = 3.51723075672918, b = -1.48456068506828, 

   c = 1.60544055207338, d = 6.99999999983179, e = 3.72070034285212], 2793]


# giving it a large total time limit, with reduced userinfo messages
infolevel[repeater]:=1:
Digits:=15:
repeater(DirectSearch:-DataFit(F
                      , [a=0..10, b=-10..10, c=0..100, d=0..7, e=0..4]
                      , X, Y, x
                      , strategy=globalsearch
                      , evaluationlimit=30000
                              ),
         maxtime=2000, maxiter=1000);

repeater: new best  3.10971990123465947
repeater: new best  0.627585701270853103e-4
repeater: new best  0.627585700896181428e-4
repeater: new best  0.627585700896051324e-4
repeater: new best  0.627585700895833535e-4
repeater: new best  0.627585700895607885e-4
 [0.0000627585700895608, [a = 2.61748239185387, b = -1.71949328487160, 

   c = 2.30924398692221, d = 1.50333104262348, e = 1.84597270535142], 6502]

I've been trying to work out an algebraic expression for the following summation

S[n,t] = Sum(factorial(k)/factorial(k+t), k = 0 .. n-1), entered as S[n,t]:=sum(f,k=0..n-1); (with f:=k!/(k+t)!;)

I entered the above Maple expression into Maple (13) just so I could check out some small example summations I had. Maple's arithmetic, accuracy and speed is much superior to mine!...

I came across a thing that does not make sense in Maple. If you click on:

http://ichart.finance.yahoo.com/table.csv?s=CSV&a=10&b=15&c=1996&d=03&e=24&f=2012&g=d&ignore=.csv

Then you will get a csv-file.

Now if you download and save that file on your computer then you can open it with:

How would I create an interactive component similar to the Locator functionality provided in Mathematica? For example, the command in Mathematica

Manipulate[
  Graphics[Polygon[pt], PlotRange -> 2],
  {{pt, {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {1, -1}}}, Locator}
]

creates five Locator objects stored in the variable pt. This example can be found in the

Hi there,

I have created an animated plot of a modelled beam under sinusoidal forcing. It shows the beam bending along the x-axis. I was wondering how to plot the animated function with the beam lying along the y-axis instead of the x-axis as happens when i use the following command:

animate(w,x=0..1,t=0..0.1,frames=150,numpoints=100,color=red,thickness=3);

Any idea's?

Dear friends

 

I want to plot a function with these coordinates in x and y directions where:

x=(0,0.0150754,0.0376884,0.0829146,0.0527638,0.120603,0.173367,0.203518,0.241206,0.286432,

0.316583,0.354271,0.39196,0.437186,0.474874,0.550251,0.58794,0.625628,0.678392,0.746231,

0.708543,0.81407,0.949749,1.1005,1.17588,1.33417,1.59045,1.91457,2.25377)

and

y=(1, 1.20603, 1.53769, 1.6, 1.77889, 2.74372, 3.49749, 3.9196, 4.43216,...

Hello!  I am writing a Grassmann multiplication operator:

define('`&*`', 'multilinear', 'flat', 'identity' = 1)

So that it automatically constructs operators like &*(arg1, arg2,arg3 ...)

Now I want to teach Maple how to transforms &* with ARBITRARY number of arguments.

How to create a pattern for that?  (to be added to "define")

Dear guys

To solve a typical integral I have written

int((t^(f-3/2))*(1-t^(2*(f-1)))^(-1/4),t);

but the solution is very complicated and contains "hypergeom". How can I have a simpler solution? I mean an explicit solution.

Thanks.  

Dear All,

I am trying to find (complex) eigenvalues and eigenvectors of a matrix as a function of a variable. Using the following commands lead to the respective errors:

- LinearAlgebra[Eigenvalues](A): Error, (in content/polynom) general case of floats not handled

- LinearAlgebra[Eigenvectors](A): Error, (in LA_Main:-Eigenvectors) cannot determine if this expression is true or false: 0.2480392156e-4*abs...

Can anyone explain these results?  I m trying to check on a more complicated form of this expression, but cannot proceed without understanding what is occurring in this case.

Does anyone know if you can schedual a task in maple ie at 12:00 add a number
to a matrix in a worksheet (Just an simple example to see if it is working)

In windows you can use the "Task Scheduler" to automate stuff that you need to repeat.

Also I dont want the actuall Maple software to actually launch at 12:00, I want everything to happend
in the background.

If you put the maple commands in the "start up code region" of the worksheet I guess it

I wrote my own maple library. Some of its procedures require the LinearAlgebra-library.

Is there a way to automatically load LinearAlgebra when loading my library? (I tried to use 'use' but it didnt help )
Currently i load my library with

read "/home/..../something.lib";

Is there any good refernce to learn how to write maple libraries the right way? the maple help isnt actually very helpful.

First 1586 1587 1588 1589 1590 1591 1592 Last Page 1588 of 2223