Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@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.

These are some anomalies that I've spotted in your worksheet. I don't know whether these have anything to do with your excessive-time problem.

  1. Both of your Quantile functions use parameter z, but z does not appear in their bodies.
  2. I have suspicions about the use of and in the piecewise condition. Mathematically it makes sense, but it may cause unnecessary complexity in the computation.
  3. You seem to have used { } instead of ( ) in a few places. This is certainly incorrect, but I don't know whether it has anything to do with the computation taking a long time.

@Mac Dude  Your corrected expression still has juxtaposed subexpressions in two places. Surely this does not express the intended meaning in either 1D or 2D Input.

Here's an example of a procedure that you can use instead of odetest:

restart
:
TypeTools:-AddType(ODEsol, function(name)=algebraic):
TypeTools:-AddType(ODEsols, {ODEsol, set(ODEsol)}):
MySimplifier:= (e::algebraic)-> (s-> `if`(is(s=0), 0, s))(simplify(e))
:
MyOdetest:= proc(
    sol::ODEsols, 
    ode::`=`(algebraic), 
    Simp:= MySimplifier, 
    TL:= 30 #default 30 second timelimit
)
    if sol::set then map(thisproc, [sol[]], args[2..])
    else
        local r:= eval((lhs-rhs)(ode), sol);
        try timelimit(TL, Simp(r)) catch: r end try
    fi
end proc
:
#Example (one you posted a few days ago):
ode:= diff(y(x),x) = 
    (y(x)^3 + 2*x*y(x)^2 + x^2*y(x) + x^3)/(x*(y(x) + x)^2):
sol:= dsolve(ode, y(x)):
MyOdetest({sol}, ode);
                           [0, 0, 0]

The above is intended to handle single ODEs of any order, expressed as an equation, without initial or boundary conditions, with a solution or set of solutions explicitly expressed.

I propose that there be a named type for structures that are necessarily syntactic subunits of any expression in which they occur. I propose molecular, by analogy with atomic.

@acer Do you have enough knowledge of the "rendering" to have an opinion about the possibility of my PDF idea working? Perhaps if the people at MapleSoft are too busy to fix this the MapleNet way, this idea could at least be a quick-and-dirty solution. Even when inlining was working (for most people, but alas not for me), it was quite dirty anyway, as we've both already noted. 

First 139 140 141 142 143 144 145 Last Page 141 of 709