## 6219 Reputation

7 years, 317 days

## @acer Is there somereason why yiy d...

I was a about to post an answer when I saw yours.
So just a question: Is there some reason why you didn't simply write the procedure this way?

```DVplot:=proc(DV,RV1,RV2)
local opl_1,opl_2,opl,lijnelement;
opl_1 := dsolve({DV, RV1}, y(x));
opl_2 := dsolve({DV, RV2}, y(x));
opl := plot({rhs(opl_1), rhs(opl_2)}, x = 0 .. 5, y = -10 .. 10, 'thickness' = 3);
lijnelement := DEtools:-dfieldplot(DV, y(x), x = 0 .. 5, y = -10 .. 10,
'title' = "lijnelementveld met intergaalkromme door (1,1)(1,-1)");
plots:-display({opl, lijnelement}, _rest);
end proc:```

## @Carl Love @acer Thank you both fo...

@Carl Love @acer

Thank you both for your feedback.
I'm juggling between Maple 2021 at the office and 2015 at home and I was hoping to save a bit of time by doing some of the work at home.
So I have a way out

Thanks again.

## What figures?...

I think you should provide examples

## I feel...

@brian bovril

this second problem could be most relevant to optiomasion or operational research?

Of course if you give all player a "health" equal to its rank (1, 2, ..., 16) than all the teams [A, P], [B, O] and so on will have the same mean "health" of 17/2.

But you could also think of unranked players, where player A has "health" hA, player B has "health" hB, and so on, where each "health" is any positive number.
In this case you could think to minimize, for instance, the sum of all the (hpair-H^2 for pair=1..8 and H equal to one eight of the sum of the health.

Here is an extremely naive algorithm (I think that greedy algorithms should be quite efficient on this problem):

 > restart
 > with(combinat):
 > # Holder alph := parse~([\$"A".."P"]); # Number of players NC   := 16: game := alph[1..NC]:
 (1)
 > # Health health := table([ seq(alph[n] = rand(1..30)(), n=1..NC) ]); mean_health := add(entries(health, nolist))/NC;
 (2)
 > # A naive algorithm to get balanced pairs best_balance := +infinity: balance := 0: count   := 1: while count <= 100000 do   pairs       := convert(Matrix(NC/2, 2, randperm(game)), listlist);   pair_health := map(p -> health[p[1]]+health[p[2]], pairs);   balance     := evalf(add((pair_health-~mean_health)^~2));   if balance < best_balance then     best_balance := balance:     best_pairs   := pairs:   end if:   count := count+1: end do:
 > best_balance; best_pairs; pair_health := map(p -> health[p[1]]+health[p[2]], best_pairs); 'mean_health' = evalf[3](mean_health); mean_pair_health := evalf[3](add~(pair_health)/~2)
 (3)
 >

## Could you provide an illustrative exampl...

@brian bovril

For instance in the 16 players case.
Do you mean that all the players are rankedn fir instance A > B > ... > P and that in order to balance the tems A and P are temmates, B and O are teammates and so on?
Or do you have something else in mind?

@Carl Love

## @Prakash J  I've just seen you...

@Prakash J

I edited my answer accordingly and checked I was able to download my own code from it.

Sorry for the inconvenience.

• Is it possible to solve this set of equations using solve?
NO, the equations are far too complex.

• So how can we?
One solution is to use fsolve instead.
Another one is to minimize some functional of the equations.

• How can I use fsolve?
In solve you declared 12 unknowns
`unk := {a1, a2, a3, a4, n1, n2, n3, n4, s1, s2, s3, s4}`
But your system of equations contains 16 names. To use fsolve you will need to give numerical values to the 4 remaining names b, q, r, theta:
```unk := {a1, a2, a3, a4, n1, n2, n3, n4, s1, s2, s3, s4};
{a1, a2, a3, a4, b, n1, n2, n3, n4, q, r, s1, s2, s3, s4, theta}
ind := indets(eqn, name);
{a1, a2, a3, a4, n1, n2, n3, n4, s1, s2, s3, s4}
par := convert(ind minus unk, list);
[b, q, r, theta]
```
For instance:
```ru   := rand(0. .. 1.):
rpar := [seq(p = ru(), p in par)];
[b = 0.8953600369, q = 0.2617341097, r = 0.7780122500, theta = 0.06587642124]
reqn := eval(eqn, rpar):
```
Then use fsolve(reqn) to get, if possible, a unique solution for the choice rpar of the parameters.

• So I'm off the hook?
NO, because you then have 12 unknowns but only 11 reqn equations.
Note that this problem also existed with solve.

Conclusions:

• Using solve is a dead end.

• Using fsolve (or the minimization of some functional) requires defining correctly the problem:
• What are the equations?
• What are the unknowns (whose number must equal to that of the equations)?
• What are the possible values the remaining parameters can take?

By the way; I'm still fascinated by people who ask questions containing (kind of) hand-written equations of extreme complexity. When I see this, I can't help thinking that if we knew the starting point of these equations, we might have some idea of an efficient way to simplify their expressions or to re-parameterize them judiciously, and thus hope to be able to solve them more simply.

## @sija  What doesn't work for y...

@sija

What doesn't work for you?

 > restart;
 > build:= proc(j)
 > local k;
 > global L;
 > L:=[]:
 >
 > for k from 2 to j do
 > L:= [op(L), v[k]];
 > end do;
 >
 > RETURN(L);
 > end proc:
 > N := 6:
 > L:=[]: for j from 2 to N-1 do
 > for i from 2 to j do
 > if nops(L) = 0
 > then
 > print('j' = j, 'i' = i, 'nops(L)' = nops(L)); # Debug only
 > # I need this here, but how to do ?
 > # nops(L);
 > end if;
 >
 > build(i);
 >
 > if nops(L) > 0
 > then
 > for s from 1 to nops(L) do
 > print('j' = j, 'i' = i, 's' = s, 'nops(L)' = nops(L), 'L(s)' = L[s]); # Debug only
 > # I need this here, but how to do ?
 > # L[s];
 > end do;
 > end if;
 > end do;
 > end do;
 >
 (1)
 > L
 (2)
 > # Your code seems a little bit too complex to do this: L := [seq(v[k], k=2..N-1)]
 (3)
 >

## A suggestion...

@Kitonum

As I use Maple 2015 at home I cannot confirm what I'm going to say.
If I'm not mistaken Maple 2021 (and likely newer versions) "has" a 3D earth globe (see MathApps > WorldMapProjections, Projection=Globe) that you might use (maybe not ?) instead of your sphere to be closer to what the OP asked.

## A comment...

The OP got

`A__inf_wo_assumptions = signum(sigma__d^3*sigma__e^2*sigma__v^4*(-sigma__d*sigma__e^2+sqrt(sigma__d^2*sigma__e^4))/(sigma__e^4+2*sigma__e^2*sigma__v^2+sigma__v^4))*infinity`

As you pointed out the "problem" comes from the sign of sigma__d*sigma__e^2.

Nevertheless I feel that an output of the form below would be less disturbing (a kind of what the option parametricleads to in solve):

`piecewise(sigma__d*sigma__e^2 >= 0, 0, +/- infinity)`

(
Note that sigma__e^2being positive the condition in piecewise could even be sigma__d > 0.
Nevertheless Maple seems to have a condition about sigma__e, which could be simply sigma__e::real:

```A__inf_with_assumptions := limit(A, gamma = infinity) assuming 0 < sigma__d, sigma__e::real;
0
```

)

Whatever, which is really boring with the generic Maple solution is that it does not provide the correct result (Maple 2015) when you evaluate the output of limit with the ad hoc assumptions:

```hyp := 0 < sigma__e, 0 < sigma__v, 0 < sigma__d;
0 < sigma__e, 0 < sigma__v, 0 < sigma__d
A__inf_with_assumptions := limit(A, gamma = infinity) assuming hyp;
0
A__inf_wo_assumptions := limit(A, gamma = infinity):
eval(%) assuming hyp;
undefined
# this last result is logic as it A__inf_wo_assumptions is then the undeterminate form 0*(+infinity)
```

So I understand the OP's perplexity.

I use maple 2015 and this does not appear: No_problem_MaPal_Maple2015.mw
(Note that there is absolutlly no reason for the expressions to contain fractions.)

The fact you get some can come from the way simplify proceeds with your own Maple version.
But as I have only Maple 2015 I can't help you more on this point (look to the simplify help page).

## Yes of course...

As you seem surprised by the capability of Maple to get these results that simply, let me tell you there is no magic behind and this and that you can get them by hand in a very simple way.

The only difficulty is that the process is very tedious and require a lot of attention in writting the successive equations.

To illustrate this look to the attached file where I simulated with Maple what we would do to compute Cov(A, B) without having any computer algebra system at our disposal Example.mw

You will see that the equations are extremely complex but that the process to get to the solution is indeed extremely simple.
Note that at no moment I use the Statistics not the Student:-statistics packages.