Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are answers submitted by Joe Riel

A better approach may be to remove the undefined points immediately after creating the plot structure.  While not the most efficient (and I worry about these huge plots you allude) a generic method is something like

cleanplot := subsindets(testplot, 'list({numeric,undefined})'
                    , L -> if hastype(L,'undefined') then NULL else L end if
                   ):

This won't work with plots that use rtable structures.

While it should not effect what needs to be done, I believe that the original poster wants L*s and C*s, not Ls and Cs.

Do you mean after the radix mark?  For example

x := -23.12345:
digs := abs(op(1, frac(x)));
                digs := 12345
add(k, k = convert(digs,base,10));
                            15

The procedure Percentile is not assigned. Did you mean to use ?Statistics[Percentile].  Is W supposed to  be in terms of the variables w[i]?

In this case it is both easy and tricky to locate the error.  Tricky because the error occurs during the creation of a module.  Simple because we got luck (sort of) .  Just do the following (this only works if you have a version of Maple with the actual error).

> restart;
> with(Statistics):
> i := 1:
> stoperror(traperror):
> RandomVariable(ProbabilityTable([1/2, 1/2]));
Error, summation variable previously assigned, second argument evaluates to %1, 1 = 1 .. 2
SumTools:-Preprocess:
  13       error "summation variable previously assigned, second argument evaluates to %1", ind = rng

DBG> where
TopLevel: Statistics:-RandomVariable(ProbabilityTable([1/2, 1/2]))
        [ProbabilityTable([1/2, 1/2])]
Statistics:-RandomVariable: return procname('_R',args[1])
        [_R, ProbabilityTable([1/2, 1/2])]
Statistics:-RandomVariable: T := Statistics:-Distribution(R)
        [ProbabilityTable([1/2, 1/2])]
Statistics:-Distribution: T := Statistics:-Distributions:-Inventory:-NewInstance(args[1])
        [ProbabilityTable([1/2, 1/2])]
Statistics:-Distributions:-Inventory:-NewInstance: return Statistics:-Distributions:-Inventory:-GetDistributionByName(dn)(op(dp))
        [[1/2, 1/2]]
ModuleApply: MakeDistribution(args)
        [[1/2, 1/2]]
MakeDistribution: module () export Conditions, ParentName, Parameters, CDF, Mean, ProbabilityFunction, RandomSample, RandomVariate; options Distribution, Discrete; Conditions := [plist::('list(realcons)')]; ParentName := ':-ProbabilityTable'; Parameters := [plist]; CDF := t -> sum(plist['k'],('k') = 1 .. min(floor(t),nops(plist))); ProbabilityFunction := t -> piecewise(t < 1,0,t         []
`unknown/6C11C8`: Mean := sum(i*[1/2, 1/2][i],i = 1 .. nops([1/2, 1/2]))
        [1/2, 1 = 1 .. 2]
sum: input := SumTools:-Preprocess(args)
        [1/2, 1 = 1 .. 2]
SumTools:-Preprocess:
  13       error "summation variable previously assigned, second argument evaluates to %1", ind = rng

You can see the error occuring in the arguments to the printed lines.  Look carefully at the module that is created in the call to MakeDistribution.  Note that the Mean export is assigned as

Mean := sum(i*plist[i],i = 1 .. nops(plist));

There's the problem,  i is a global variable.  Another issue is that the sum should be an add. Of course, that would have masked this problem, since an add wouldn't fail here, but could otherwise (say if i were protected).

Could be, I'm also using linux. 

There are two problems.  Because you are using actual underscores (rather than indices) for the names, you cannot use

seq( ... fp_i ... , i = 1..9)

to reference the fp_x variables.  You can fix that by using the catenate operator, ||

col := seq(fn_||i = (1-1/tau)*fp_||i + 1/tau * feq(i), i = 1..9):

The second problem is that while you have 10 equations, you only give solve 7 variables.  You need to specify more variables. For example

eqs := { massconserv, col };
vars := { seq(fp_||i, i=1..9), rho_wall }:
solve(eqs, vars);

I'm having a hard time reading the Maple code, the font displays badly on my machine.  It appears that you wrote

col := seq(fn_i = ... , i = 1..9);

You probably want to change that to

col = seq(fn[i] = ... i=1..9);

Just to confuse the matter, they could be equivalent, since typing underscore in 2D match is equivalent to using square brackets, however, if you had done that I wouldn't expect to *see* the underscore in the text, it would have expanded to a subscript.

To print the list vertically, you could convert to a Vector and do

printf("%{c\n}a\n", <xyz>);       
dx = x*y-1/3*y+1/3*z
dy = -.1e-1*x
dz = 1/10*z

See ?rtable_printf

 

There is nothing wrong with the first result.  The first call to sum computes an indefinite summation, which is analogous to an indefinite integral. As such, it is correct up to a constant. See ?sum,details.

Are you sure v is a function of x and not of p?

I'm not sure what you mean by "index in the name".  Could you give an example?

Change ?sum to ?add and remove the forward-quotes from A.  The sum procedure is intended for indefinite summation. You can also delete the two statements, i::nonnegint; and j::nonnegint.  They have no effect on the operation. For this procedure to work, the LinearAlgebra package must have been "withed".  A better design is to add the statement

uses LinearAlgebra;

at the start of the body of the procedure.  See ?uses. Actually, since you use but one procedure from the LinearAlgebra package, it is easy enough to call ColumnDimension with LinearAlgebra:-ColumnDimension.  An alternative is to use the new command, ?upperbound.  Do

dimA := upperbound(A,2);

What do you mean by a "map"?  If you mean a single directory, then use ?FileTools[ListDirectory], with the 'returnonly' option; for example

files := FileTools:-ListDirectory("mydir", 'returnonly' = "*.jpg");

If you need to recurse into directories, let me know, I have routines for doing that.

solve needs to know the variables to solve for.  A nice way to do this, given that you've already assumed the knowns as constants (which doesn't otherwise do anything useful here) is the following:

vars := remove(hasassumptions, indets(sys));
solve(sys, vars);

First 46 47 48 49 50 51 52 Last Page 48 of 114