Carl Love

## 26663 Reputation

11 years, 230 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

## simplify the imaginary part...

ex:= (1/6)*(-108+(12*I)*sqrt(1419))^(1/3)+10/(-108+(12*I)*sqrt(1419))^(1/3)+1:
simplify(Im(evalc(ex)));
0

## tickmarks plot option...

I use AV instead of averagedValues just to save space; you can use the latter if you want.

plot(AV[..,[1,3]], tickmarks= [AV[..,1] =~ AV[..,2], default]);

The problem with this is that Maple can only print tickmarks horizontally. So, when you have long tickmarks, you cannot fit very many on the horizontal axis. A workaround would be to interchange the roles of the horizontal and vertical axes:

plot(AV[..,[3,1]], tickmarks= [default, AV[..,1] =~ AV[..,2]]);

## FileTools:-ParentDirectory...

cat(FileTools:-ParentDirectory(currentdir()), "/Code_principal/");

## Don't use [ ] for algebraic grouping...

You can't use square brackets [ ] for algebraic grouping, as another level of parentheses; only actual parentheses () can be used for algebraic grouping. I changed four pairs of [] to () in your worksheet, and it runs to the end without error.

hmm_working.mw

## subsindets([A], list(Not(list)), {op})[]...

Good question. Here's how:

A:= [[a,b]], [[c,d,e]], [[f],[f,h]]:
subsindets([A], list(Not(list)), {op})[];
[{a, b}], [{c, d, e}], [{f}, {f, h}]

Edit: I simplified `{}`@op to {op}. The two forms do the same thing.

## Array / scalar mixup; A[i] vs. A(i)...

(This problem can be seen in the originally posted Question; you don't need to download the worksheet.)

By referring to Flux_softening_point_V3(i) in your loop, you are treating it as if it were an Array. But in the initialization code immediately above the loop, you have Flux_softening_point_V3:= 100.0, which makes it a scalar, not an Array.

Also, you are doing Array indexing as both A[i] and A(i). Maple doesn't care about that, but your usage indicates perhaps that you believe that the two forms are doing something different. Do you believe that?

## local plot...

In Maple 17, put the following in your .ini file:

local plot:= proc({discont::truefalse:= true}) :-plot(args, :-discont= discont) end proc:

(I updated this Answer so that now you can pass discont= false to plot if you want. Essentially, this is changing the default value of discont from false to true.)

If you don't have Maple 17, let me know: Essentially same thing can be done a bit more hackishly in earlier Maple.

## Dividing combinations into manageable ch...

@wkehowski Yes, I see the problem: Using combinat:-nextcomb is inherently sequential (i.e., not parallel) (the "next" in the name pretty much guarantees that!). You have way too many combinations to generate them all, store in memory, and then apply Threads:-Map or Threads:-Seq.

Here's an idea: Find a number of combinations that your memory can comfortably hold---let's say 1 million.

while not
done do
L:= the next million combinations as a list;
;

write GoodPts to a file
end do;

Select:= proc(x ::
a candidate point)
if x
is a point that you want to save then x else NULL end if
end proc;

It would be more efficient to not use nextcomb to generate the L.  I'll make up a fully coded example later this evening, I think.

## combinat:-cartprod...

Kitonum's triple-loop solution is difficult to generalize to an arbitrary number of lists. And building lists (or sets, sequences, etc.) by appending onto the end of an existing list is a bad (inefficient) habit that you would be better off not starting. To handle an arbitrary number of sets, use ?combinat,cartprod . To build a list in a loop, store the items in a ?table temporarily and then use ?convert,list .

The following code builds the list of combinations that you want:

restart:
Iter:= combinat:-cartprod([seq](combinat:-permute(3,k), k= [3,2,1])):
Perms:= table():  k:= 0:
while not Iter[finished] do k:= k+1; Perms[k]:= Iter[nextvalue]() end do:
convert(Perms, list);

## MatrixInverse...

It's MatrixInverse (with capital I), not Matrixinverse.

## numpoints= 10000...

In addition to Kitonum's Answer, numpoints = 10 seems much too low. The system can easily handle 10,000points (100 x 100 grid).

It is much, much easier to just use ?Threads,Map or ?Threads,Seq rather than Task. Let Maple worry about how many pieces to break it into.

## Putting it in simple English: You can't ...

Putting it in simple English: You can't Continue what you didn't Start.

## Don't use loop index as a symbolic...

Your code doesn't work because you are trying to use the variables c, d, and e as both symbolics (variables without an assigned value) and as loop indices (the variables after for). You need to use different variables and then subs one for the other within the loop, like this:

N := [];
for _c in poss_for_v(1) do
for _d in poss_for_v(2) do
for _e in poss_for_v(3) do
N := [op(N), subs([c= _c, d= _d, e= _e, M[6])]
od
od
od:

(The code above is only meant to correct your primary problem and does not represent my opinion as to the best way to perform the operation. For the best way, see ?combinat,cartprod and store the results in a ?table , not a list, and ?convert,list the table to a list when the loop is finished.)

## for i in ... do...

You can avoid the need (and expense) of a conditional evaluation at every loop iteration by using the in form of for. For the example at hand, the code would be

for i in \$1..2, \$4..8 do
print(i)
end do;

 First 348 349 350 351 352 353 354 Last Page 350 of 384
﻿