## 1072 Reputation

12 years, 71 days

## I See...

@tomleslie  Thank you. The Isee came about because sometimes I want to use one of my routines from inside a package to answer a question here. showstat puts in line numbers and Describe doesnt normally give the whole procedure

Make it easy to copy and paste.

```Isee(CrossingNumber);
proc(A::list, B::list, C::list, E::list)
local s1, s2, s3, s4;
description " Determines if AB crosses CE.   Returns 1 or -1 if cros\
ses, 0 if does not cross or undefined if alined";
s1 := RonanRoutines:-SignedArea(A, B, C);
s2 := RonanRoutines:-SignedArea(A, B, E);
s3 := RonanRoutines:-SignedArea(C, E, B);
s4 := RonanRoutines:-SignedArea(C, E, A);
if s1 = 0 and s2 = 0 and s3 = 0 and s4 = 0 then
'undefined';
elif 0 <= signum(s1) and signum(s2) <= 0 then
if 0 <= signum(s3) and signum(s4) <= 0 then -1; end if;
elif signum(s1) <= 0 and 0 <= signum(s2) then
if signum(s3) <= 0 and 0 <= signum(s4) then 1; end if;
else
0;
end if;
end proc
showstat(CrossingNumber);

RonanRoutines:-CrossingNumber := proc(A::list, B::list, C::list, E::list)
local s1, s2, s3, s4;
1   s1 := RonanRoutines:-SignedArea(A,B,C);
2   s2 := RonanRoutines:-SignedArea(A,B,E);
3   s3 := RonanRoutines:-SignedArea(C,E,B);
4   s4 := RonanRoutines:-SignedArea(C,E,A);
5   if s1 = 0 and s2 = 0 and s3 = 0 and s4 = 0 then
6       'undefined'
elif 0 <= signum(s1) and signum(s2) <= 0 then
7       if 0 <= signum(s3) and signum(s4) <= 0 then
8           -1
end if
elif signum(s1) <= 0 and 0 <= signum(s2) then
9       if signum(s3) <= 0 and 0 <= signum(s4) then
10           1
end if
else
11       0
end if
end proc
```
```Describe(CrossingNumber);

#  Determines if AB crosses CE. Returns 1 or -1 if crosses, 0 if does not cross
# or undefined if alined
s=00000289E0D8ED68, invalid component 8,3 of PROC
```

## Single row Matrix Vs Vector...

@Carl Love @acer  Thank you for your answers. I see the single row matricec can be multiplied as a cross product just the same a vectors and the answer is a vector.  I guess it would be sloppy and bad practice to use single row martices as vectors. Also when using whattype  which I am.  Are there any other obvious dangers?

## There is an extensive answer here...

This is a good thread on your question. It might give you some ideas.

Basins of attraction - MaplePrimes

## Works well now...

@acer Thank you. I willl probably have to break it down into something more inefficient to understand what the the different components do.

## Maple 2022.1...

@Christian Wolinski I have hilighted what I thing look odd to me

## Very efficient....

@Carl Love Thank you.

## I noticed the '' what does it do...

@Christian Wolinski  Thank you.. Idid notice the '' no idea what they do.
I had tried end proc but it is the @dd I don't get either.

## Works! Can you Explain?...

@Christian Wolinski Thank you. That produces the lists nicely. I admit I don't understand the ListTools part of the code. Could you please explain it? I did look in the Help on it but right now don't quite get it.
There is some error  in the last line of the code.  I presume it is intended to maintain the order of the lists under addition.

 Error, invalid proc termination Just my experimentation

## Thank You...

@Carl Love Ok so I see now.  Just tested it this way

`(f, (E, V) -> V)(expand(A), exp(T))  gives  f(A, exp(T)), exp(T)`

## Can you explain......

@Christian Wolinski Very nice solution. I don't quite get the technicality of the (E,V)->V So E=expand(A) and V =exp(T) in this case and somehow (solve,((E,V)->V))(expand(A),exp(T))  includes exp(T) in the answer.   I notice the " " after solve and the enclosing (....) are necessary.  I did check through help but didn't see an explination. Of course maybe I missed that.

Edit:- I see that (E,V)->V))(expand(A),exp(T)   is eqivalent to

f := (E, V) -> V;

f(expand(A), exp(T));

## Solve Index Meaning?...

@Carl Love Can you explain what index means in relation to solve?

## True...

@Carl Love You are correct.  It took me a while to remenber the syntax to use.

Interesting problem.  So I gather there are "s" nested summation loops. I asked a question a few months ago that required with a variable number of summation loops. @Carl Love answered it.

Is it possible to Add/sum by mapping multiple values from a list - MaplePrimes

So just to clarify can t[j] and t[i]  be replaced with T[j] , T[i] to totaly distinguish them from t?

I presume the inputs are M and s.

Edit:-On problems like this a I start with small values for s and M and build the nested summations/products to handle them before trying for the total solution. I attach  document to see if my begining intrepertations are correct.

 (1)

 (2)

 (3)

 (4)

 (5)

 (6)