Carl Love

Carl Love

27224 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

The answer is ` $`. Note that there is a space before the $. If you try to use this as a parameter, it will be treated as if it were the end-of-parameters marker $. But `$` (no space) can be used as a parameter.

Indeed, when the end-of-parameters marker is used, it is translated upon automatic simplification to ` $` as a parameter. You can see this in the prettyprint of a procedure:

P:= proc(x, $) end proc;

lprint(%);
proc (x, ` $`) end proc

You can also see it if you look at op(1, ...(the parameter sequence) of the procedure:

lprint(op(1, eval(P)));
x, ` $`

Does the general form of the integrand suggest to you that a particular function might occur in the antiderivative (the answer)? Does it suggest a particular technique?

The problem is premature evaluation. The expression test(s) in the plot command is evaluated before s is given a numeric value. The cure is to delay the evaluation.

 

restart:

test:= s-> fsolve(t^3=s, t):

test(0);

0., 0., 0.

You need to include maxsols= 1 to cover the case of multiple roots at s=0. However, that is not the proximate cause of your problem.

test:= s-> fsolve(t^3=s, t, maxsols= 1):

test(0);

0.

This is the proximate cause: Note that you get the same error if you simply invoke test(s).

test(s);

Error, (in fsolve) s is in the equation, and is not solved for

The error is because the argument s is not numeric. There are three ways to correct this:

Method 1: Explicit delaying of evaluation with forward single quotes.

plot('test(s)', s= 0..8):

Method 2: Plot a procedure.

plot(test, 0..8, labels= [s, ``]):

Method 3: Procedure returns unevaluated when passed a symbolic argument.

test:= s-> `if`(

     s::numeric,

     fsolve(t^3=s, t, maxsols= 1),

    'procname(args)'

):

plot(test(s), s= 0..8);

 

To be more robust, you should make t a procedure local and protect the global name keyword maxsols.

test:= proc(s)
local t;
     `if`(

          s::numeric,

          fsolve(t^3=s, t, ':-maxsols'= 1),

          'procname(args)'

     )
end proc:

 

 

Download delay_eval.mw

You have a for loop defining the E equations. That loop begins at 3, so there is no E[2] equation. You need to start that loop at 2.

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

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

AV:= readdata("mytextfile.txt", [integer, string, float]);
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]]);

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

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

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.

(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?

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.

@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;
      GoodPts:= Threads:-Map(Select, L)
;

     
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.

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);

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

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

First 353 354 355 356 357 358 359 Last Page 355 of 389