Carl Love

Carl Love

28025 Reputation

25 Badges

12 years, 307 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Rouben Rostamian  Great Answer, Vote Up, and I even learned a few things from it. I think that there's one more thing that you should state, because I don't think that it's immediately obvious: Your process of finding the vectors is only valid because the right sides of the equations are constant. Of course, it's trivial to rearrange any equation so that that is true.

My opinion is that all algebraic equations eq given as input to any Maple program should be preprocessed with (lhs-rhs)(eq). One of the many advantages of doing that is that it eliminates the concern that I raised in the first paragraph. 

@nm It's not necessary to specify a domain more explicitly. If in the Question above one were to replace the word "between" with "of the region bounded by", then it would be phrased as a standard calculus textbook problem. It's then the job of the student to use geometric intuition and/or plotting to locate the bounded region in the xy-plane and to conceptualize it as an integral or sum of integrals, and to use algebra to determine limits of integration and integrands.

In some simple cases, if one uses that geometric intuition to define the region via inequalities, Maple may be able to procede automatically with both the symbolic algebra and symbolic integration to finish the problem entirely. I suspect that this is not one of those simple cases, but I'm curious to try it.

@Joe Riel Thanks for 0@@0; it's better than _@@0. I think that I'll use 1@@0 until something better turns up. The 1 better conveys the idea of "identity function". Another possibility is `@`(), but it's one more character. All of these evaluate to ()-> args.

 

@Joe Riel My code wasn't intended to handle the multi-argument abs case (which the OP stated doesn't occur in their work anyway). I'm sorry that my phrasing gave you the impression that that was my intention. Replacing abs(n,x) with x is mathematically nonsense.

Here is &inside's definition:

TypeTools:-AddType(`&inside`, (e, `in`::type, out::type)-> e::out and hastype(e, `in`)):

The following code allows for the multi-argument abs case by ignoring it; it only processes the 1-argument case:

evalindets(expr, specfunc(ln), evalindets, 'abs'(algebraic), op);

 

@Ioannis 

Usage of error: When you use the word error on MaplePrimes or on any forum devoted to a computer programming language, you need to specify whether you mean error 

  1. in the technical sense that that term is defined by the language (usually witnessed as the issuance of an error message), 
  2. in the sense that the results are incorrect.

Making that distinction is usually sufficient; although each of those cases has numerous subcases, such as syntax errorsruntime errorslogical errors, and bugs.

Usage of take: In three cases (one in the Question and two in the Reply), you've used the word take where you meant make. Since "t" and "m" are not adjacent on a standard keyboard, I assume that this is not a typo and that you truly don't understand the meaning of these words. I can usually interpret the meaning of the writing of non-native-English speakers, and so I usually wouldn't point out something like this; however, in this case I was truly confused by your usage of take in the Question; it was only while reading the Reply that I realized that you meant make. Since these are fundamental and essential English irregular transitive verbs (such that exchanging them produces syntactically correct meaningful sentences) whose meanings are totally unrelated, I suggest that you look them up and learn them well.

@Art Kalb 

`` is just a symbol, and ``(-1) is just a function, in the specific senses that those words are defined as Maple types (see ?type,symbol, ?name, ?type,function). So, as far as the Maple kernel is concerned, it might as well be f, as in z^f(-1). The reason that `` is effective for this purpose is that the prettyprinted form doesn't show the quotes.

The command expand will remove the quotes. Why wouldn't you be able to compute with these?

Your code runs for me without error in Maple 2020.1. What error did you get?

@ruhamdam I'm sorry that I misunderstood what you meant by "7 derivatives". That was exacerbated by the coincidence that there were exactly 7 derivatives specified in your list a[3], ..., a[9].

Creating an indexed procedure (i.e., a procedure whose name can used with an index which is accessible within the procedure) is simple, but the syntax to do it is far from obvious. You can do as follows. The first (and longest) part is a table of tables, each subtable being one of your derivatives.

MyDerivatives:= table([
    1 = table(sparse, [x= x*y, y= 1, z= z^2]),

    3 = table(
        sparse, 
        [
            a[4]= -2*a[3], a[5]= -4*a[4], a[7]= -2*a[6], 
            a[8]= -4*a[7], a[9]= -6*a[8]
        ]
    )
]):

#And here is the simple-but-nonobvious syntax for making MyD an indexed procedure.
#The keyword expression op(procname) extracts the index (or indices) which were
#used in the procedure's invocation.
MyD:= proc(e)
local DT:= MyDerivatives[op(procname)];
    evalindets(D(e), specfunc(D), d-> DT[op(d)])
end proc:

#Example usage:
MyD[1](x*y^2/2 + 3*y^3*z*b + 3 + a);
              1    3            2          3  2  
              - x y  + x y + 9 y  z b + 3 y  z  b
              2                                  


It's not necessary that the tables be indexed by numbers. Names, strings, or anything else could be used. If numbers are used, it is not necessary that they be consecutive or in order. You can also omit the outer table's indices, in which case they'll be indexed sequentially starting with 1. In that case, you'd might as well use a list rather than a table as the outer container. For example:

MyDerivatives:= table~(
    sparse,
    [
        #1 (as used in original Question):
        [x= x*y, y= 1, z= z^2], 

        #2 (empty placeholder for index 2):
        [],

        #3 (as used as MyD[3] in Reply to Kitonum):
        [
            a[4]= -2*a[3], a[5]= -4*a[4], a[7]= -2*a[6], 
            a[8]= -4*a[7], a[9]= -6*a[8]
        ]
    ]  
);

This requires no change to the procedure MyD.

@ruhamdam I'd hoped that it'd be obvious that you just need to modify the table to do that, like this:

MyDerivatives:= table(
    sparse, 
    [
        a[4]= -2*a[3], a[5]= -4*a[4], a[7]= -2*a[6], a[8]= -4*a[7], 
        a[9]= -6*a[8]
    ]
):
MyD:= e-> evalindets(D(e), specfunc(D), d-> MyDerivatives[op(d)]):

There's no need to include a[3]= 0 or a[6]= 0 because the derivative of any variable not specifically indexed in the table is automatically 0 (that's what the keyword sparse does)..

@Carl Love My Answer above was responding to a version of this Question that claimed that the error stated that it came from matrix. The Question has been edited, changing matrix to Matrix​​​​​. If this is now indeed the correct error message, then this Answer is irrelevant. 

The OP seems to have edited the Question but has not bothered to supply the code that caused the error. No answer can be given without some code.

The OP seems to expect that error messages are documented. That's a reasonable expectation, and it seems possible, but the truth is that the vast majority of them are not documented.

@Danialfreddy The letter e in Maple input does not represent the well-known constant; it's just another variable. You must enter exp(-2*t) instead of e^(-2*t). In Matlab, it's exactly the same way, as your Matlab code above shows. 

The modification time is available via a simple command: FileTools:-ModificationTime. If your hack uses the modification time to store the access time, then that would be the command. The value is returned as a number of seconds, which can be easily converted to a date via

StringTools:-FormatTime(
    timestamp= FileTools:-ModificationTime(
filename
)
)

The commands in FileTools are O/S independent. The package (AFAIK) doesn't have any equivalent for the access time.

If you need to do a shell escape to do it, the command is 

R:= ssystem(string shell command​​​​​​)

Note that that begins ss. (The command system (one s) is asynchronous.) Upon completion, R[1] is the integer error flag and R[2] is the string command result.

I know that you said "toolbox", but let's be sure that we're talking about the same thing here: You do mean specifically the Grid Toolbox (intended for distributed processing on multiple computers) rather than the Grid package (intended for parallel processing without shared memory on a single computer with multiple processors), right?

Does your computation involve complex communication between the multiple processes? Or could the majority of it be expressed as a loop such that the iterations could be performed independently and the final results assembled at the end?

Can you estimate the memory (bytesalloc not bytesused) required per processor and/or the overall memory required? If that amount is large, is that due to memory that is temporarily used for the computation (and then "garbage collected")? Or does your final result itself require a lot of memory? 

Could you make a reduced-size example of your computation such that we could practice with the Grid package before delving into the Grid Toolbox? 

 

@Wilks If I translate the input (not the evaluated output) of your expression w into 1D input, I get this:

w := (g*(-m[1]*delta1 - m[2]*delta2 - m[3]*delta3 - m[4]*delta4 - m[5]*delta5 
- m[6]*delta6 - m[7]*delta7 - m[8]*delta8 - m[9]*delta9 - m[10]*delta10 - 
m[11]*delta11 - m[12]*delta12 + (-F2*delta*F[2] - `δF1`*F[1] - 
`δF3`*F[3] - `δF4`*F[4] - `δF5`*F[5] - `δF6`*F[6])/g)/
(m[1]*delta1^2 + m[2]*delta2^2 + m[3]*delta3^2 + m[4]*delta4^2 + 
m[5]*delta5^2 + m[6]*delta6^2 + m[7]*delta7^2 + m[8]*delta8^2 + m[9]*delta9^2 +
 m[10]*delta*10^2 + m[11]*delta11^2 + m[12]*delta12^2 + (`δF1`^2*F[1] +
 `δF2`^2*F[2] + `δF3`^2*F[3] + `δF4`^2*F[4] + 
`δF5`^2*F[5] + `δF6`^2*F[6])/g))^(1/2);

There are two places in that expression where you've unintentionally entered delta as a separate variable. This can sometimes happen because you unintentionally pressed the space bar. The first place is -F2*delta*F[2] (should be -`δF2`*F[2]); the second is m[10]*delta*10^2 (should be m[10]*delta10^2).

Not only does 2D Input make it very easy to make these errors, it also makes them difficult to find.

I believe (but I'm not sure) that even if numeric values were supplied for all the parameters, stochastic functional optimization such as this (is stochastic calculus of variations a known term?) is well beyond the capability of Maple. However, you may be able to run simulations with the Finance package.

First 138 139 140 141 142 143 144 Last Page 140 of 708