## Stopping an evaluation if it takes a long time aut...

Is there any method or a command to use or type so Maple start running something or evaluating and if it took more than a specific amount of time, then itself automatically stops itself without needing me to interrupt the evaluation?

For example let's say I wrote a proc, for some inputs it may compute the output fast but in some it may even don't answer after hours. Now I am writing a for and I don't know for which steps it can answer in less than a minute. So I like to add something so that Maple starts the FOR but in steps that it takes more than a minute, it automatically stops evaluation at that step and jump to the next step.

## Why does applying this rule inside a procedure not...

Hi,

I want to apply a rule to simplify an expression. The applyrule command works, when used directly in the worksheet. When I try to use the command within a procedure, Maple throws an error I cannot decipher:

Here is a full demonstration worksheet:

 > restart:
 > anexp:=abs(x)^2;
 (1)
 > simplify(anexp);
 (2)
 > rmabssq := proc(inexp) description "removes the abs^2 construct in an expression": local ruleabssqared1,ruleabssqared2,outexp:     ruleabssqared1:= abs(''a''::algebraic)^2= ''a''^2:     ruleabssqared2:= abs('expand'(-''a'')::algebraic)^2= ''a'':     outexp:= applyrule([ruleabssqared1,ruleabssqared2],inexp):     return outexp: end proc;
 (3)
 > ## does not work :( rmabssq(anexp);
 > ## works! ruleabssqared1:= abs(''a''::algebraic)^2= ''a''^2: ruleabssqared2:= abs('expand'(-''a'')::algebraic)^2= ''a'': newexp:= applyrule([ruleabssqared1,ruleabssqared2],anexp);
 (4)
 >

## how to find unused local variables in a proc?...

Sometimes when one write a proc(), and later make changes, some of the earlier local variables could no longer used after the new edits.

In a small proc, it is easy to spot visually which ones are no longer needed and to remove them. But for a large proc() with many local variables, it is harder.

Does maple have a tool  to help one find which are the unused local declarations are not used? For example

```foo:=proc(x)
local y,z:
x^2;
end proc;```

I'd like maple to tell me that `y` and `z` are unused when I asked it to. (may be by highlighting or warning)

Mathematica has such a tool (and more) in its workbench editor which is very useful. does one need an external tool in Maple to do this?

## How to integrate a function defined by a condition...

I have a function that is defined by a proc command including some conditional statements (if ... then ...). The conditions are so long so that I can not use a piecewise function instead of using proc. The commands in my code are long and I simplify my question as follows:
f := proc(x) local r; r := sin(x)+x*cos(x); if abs(r) < 1/2 then sin(x) else cos(x) end if; end proc;

plot('f'(x), x = -1 .. 1) works fine but the command int(('f')(x), x = -1 .. 1) gives an error:
Error, (in f) cannot determine if this expression is true or false: abs(sin(x)+x*cos(x)) < 1/2

Is there any way (except rewriting the function as a piecewise function) to get rid of the error?

Any help is appreciated.

## Strange error message using plot3d...

When trying to perform the following:

p1 := proc (x, y) if x^2+y^2 <= 1 then x*y-y^2 else 0 end if end proc;
plot3d(p1, x = -1 .. 1, y = -1 .. 1);
Error, (in plot3d) expected ranges but received x = -1 .. 1 and y = -1 .. 1

I get this strange error message. To the best of my knowledge x and y ARE provided as ranges. What am I missing/not understanding?

If I omit the ranges in plot3d Maple returns a correct plot, but the default range (-10 .. 10) does not display sufficient details

## How to automate an iteration in Maple...

Hello. Two teams A and B (consisting of 2, 3 or even 4 players) compete and the outcome of each game is either a win or a loss. I have a to process the new (gaussian) laws of players given whom beats whom.

Given the initial means and standard deviations of the players, I have a algorithm (RC) which computes the new laws of the players. [the actual algorithm i use is different to the one i am showing here].

By way of example consider two teams with 2 players per side. Each person plays 2 games.

The initial laws of A1,A2,B1,B2 are given.

(A1,B1) --->(A1',B1').......[iteration 1. A1 beats B1, resulting in new laws A1' and B1'(computed by RC)]

(B2, A1') --->(B2', A1").......[ iteration 2. B2 beats A1. using A1' from iteration 1. A1 has played twice and is denoted by A1"]

(B2',A2) --->(B2",A2').......[ iteration 3. B2 beats A2. using B2' from iteration 2.  B2 has finished and is denoted by B2"]

(A2',B1') --->( A2",B1")......[ iteration 4. A2 beats B1. using B1' from iteration 1 and A2' from iteration 3. now all players have played their matches]

new laws A1" ,A2", B1" & B2" should be outputted.

my first code gets the result, but it is tedious to enter the iterations in the right place .especially for teams of 3 or more.

my second with parameters gets errors.

So what i want is to enter who beat who:

eg  [[B1, A1], [B2,A1], [B2, A2], [A2, B1]];
and the final laws are computed automatically.

bb_processing_edit.mw

## Index out of bounds in procedure...

Hi there,
I have a simple task to do with arrays. I have an 8x3000 array, whose columns are sometimes all zeroes (if any element in the column is zero then the entire column is zero). I want to eliminate the zero vectors, so I have this loop (the array is A)

for i from 1 to 3000 do
while A(1,i)=0 do
A:=DeleteColumn(A,i);
end do;
end do:

Setting "A:=DeleteColumn(A,i);" reduces the size of the array, so if all the zero columns have been deleted at "i=200", Maple will keep trying to check the next column, which doesn't exist anymore. This gives an "index out of bounds" error, but also records "A" as the new smaller array, which is fine.

If I run this loop inside a procedure, the error stops the procedure, but it doesn't record the new array, it stays as the older, larger one. Does anyone know of a way around this?

Any help would be much appreciated.

## Problem with procedure...

Dear Community,

I get this message

'EQU' is implicitly declared local to procedure 'Z_DAK_FSOLVE'Problem with procedurefor a procedure, and  cannot go further. How can I avoid it?

Tx for the help in advance,

best regards

Andras

Z_DAK_PROC.mw

## Writing equations in procedure...

 Pile spacing of each pile from a refrence pile: Angle of each pile from a reference pile in radian: Angle of each pile from a reference pile in degrees: The total number of piles in a pile group: The length of each pile in the pile group in (meters):       Diameter of pile (meter): The radius of each pile (meter):

Good Evening Maple Community,

Can anybody please help in the attached file. Highlighted in yellow are the three equations I'm trying to program in Maple procedure, but could not get any output due to an error message. Please Help.

Boyer

## How do I make this procedure recursive?...

Think I've solved my problems, thanks.

## Seq behaves funny within a program...

I am trying to do some algebra with the derivatives of some variables within a program. As a result i need to relable them before i feed them into solve.

To relable them i create vectors and use subs. one of these vectors behaves differently within a proc to how it behaves outside it. This is weird.

TimefullBehavesFunny := proc (nPars, nVars)
local nDiffs, timefull, timeless;
nDiffs := nPars;
timefull := [seq(dx[j, i] = diff(x[i](t), `\$`(t, j)), i = 1 .. nVars)];
timefull := [seq(op(timefull), j = 0 .. nDiffs), seq(x[i] = x[i](t), i = 1 .. nVars)];
timeless := `~`[`=`](`~`[rhs](timefull), `~`[lhs](timefull));
timefull, timeless, nDiffs;
end proc

When i run the above for (3,3) i get a differet result to when i run the following
nVars:=3;
nDiffs := 3;
timefull := [seq(dx[j, i] = diff(x[i](t), `\$`(t, j)), i = 1 .. nVars)];
timefull := [seq(op(timefull), j = 0 .. nDiffs), seq(x[i] = x[i](t), i = 1 .. nVars)];
timeless := `~`[`=`](`~`[rhs](timefull), `~`[lhs](timefull));

and similarly for other numbers.

any ideasas to why?

## Only one result!...

To saving my time i create a function like this:

LTTS:=proc(ff)

local ll,r,r1,r2,r3;

ll:=rhs(ff)-lhs(ff);
solve01(ll):
solve02(ll):
solve03(ll):
solve04(ll):
solve05(ll):
end:

But when i run it, it is only give me the result of solve05(ll). when i run alone from solve01 to solve05 it still give me result.

I also try:

myfunction:solve01(ll):solve02(ll):solve03(ll):solve04(ll):solve05(ll):

It still the same :(

## Odd response to use of local in proc definition...

This one really has me baffled.

What the proc does is not important. This is just about as simple an example as I could write. Maple 2015 is complaining anytime I try to declare a local variable. The second example shows that the local declaration is needed - Maple even introduces it into the procedure that it defines.

`restart;`
`test := proc(  ) local a; a := 3end proc;Error, unexpected `local` declaration in procedure body`
`test := proc(  )# local a; a := 3end proc;Warning, `a` is implicitly declared local to procedure `test`test := proc(x) local a; a := x end proc`

Here's the version information for my current Maple.

`interface( version );Standard Worksheet Interface, Maple 2015.0, Windows 7, February 17 2015 Build ID 1022128`

Can someone explain what is happening, and why I'm just now seeing this?

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## How to find specific solutions?...

A lot of my life is at the moment spent using solve to solve systems of equations, and then trying to weed through the solutions maple gives to find the ones I am interested in. Specifically i'd like to have a program that can weed through the solutions and eliminate those that include equalities of the  form p[i]=-p[j] or p[i]=0  where i and j are integers (or equalities of that form with the letter q replacing p). Specifically i don't want to exclude equalities of the form p[i]=-p[j]*something+something else-another thing.... as they can be useful (or equalities of that form with the letter q replacing p).

Here is a (simple) example of the kind of equations I am likely to be solving and their output from solve:
A := solve([p[1]*p[2]*p[3] = q[1]*q[2]*q[3], p[1]+p[3] = q[1]+q[3], p[2]^2+p[3]^2 = q[2]^2+q[3]^2])

I have some code which gets rid of solutions where one variable is set to 0

with(ArrayTools);
GetRidOfDumbSolutions := proc (sols)
local Nsols, Npars, GoodSol, GoodSols, GoodSolsCounter, i, j;
Nsols := numelems(sols); Npars := numelems(sols[1]);
GoodSols := []; GoodSolsCounter := 0;
for i to Nsols do
GoodSol := 1;
for j to Npars do
if IsZero(rhs(sols[i, j]))
then GoodSol := 0
end if
end do;
if GoodSol = 1 then
GoodSols := Concatenate(1, GoodSols, sols[i])
end if
end do;
GoodSols
end proc

but i can't see how (in maple) to detect an expression of the form p[i]=-p[j] especiall if that is being written in 2-d math. (i don't quite understand the different maths environments or how to convert from one to another or to string)

## Catmull-Rom spline curves...

Hello,

I try to use a Catmull-Rom spline which has to match on several points.

I use a code extracted from the book "Geometry and curves with maple".

Here you can find an extract which is visible from google book :

I have slightly modified the initial procedure crom_2d. I didn't find the error in my procedure. May you help me to find the blocking point of my procedure ?

Here I attached my code:

CalculSplineMatmull-Rom.mw