mmcdara

3728 Reputation

17 Badges

6 years, 29 days

MaplePrimes Activity


These are replies submitted by mmcdara

@acer 
I understand your position of seeking a loophole for a problem.
Mine is to point out the inconsistency of what is done, by the OP and therefore by you too.
To propose a solution to this problem is not just to circumvent an alleged shortcoming of Maple, it is above all to break the basic rules of dimensions manipulation, which is precisely what Maple is trying to prevent.

@acer 

Thank you acer.
I was really distraught about this problem. I thought I had interpreted the error message correctly and also wrote

objgrad := proc(v, w)
        w[1] := fdiff(obj, [1], [entries(v, nolist)]);
        w[2] := fdiff(obj, [2], [entries(v, nolist)]);
end proc:

but that didn't work either

@acer 

Agree, I edit a warning with a reference to your remark

@one man 
 

1  fsol_order     := map(u -> parse(substring(u, 2..-1)), lhs~([fsol[]]));
2  natural_order  := sort(fsol_order, output=permutation);
3  natural_vars   := lhs~([fsol[]])[natural_order];
4  natural_fsolve := natural_vars =~ eval(natural_vars, fsol);

Line 1
map(u -> f(u), U) applies the "function" f to each member u of U
Here U is list of th left hand sides  of fsol. feol is a set and [ fsol[ ] ]transforms fsol into a list.Another way to do this is convert(fsol, list).
lhs~(A) means "get the left hand side of all the elements of A (A can be a list, a vector, a set, ...) ; another way to do this is to write map(u -> lhs(u), A) or more simply map(lhs, A)
The function f in map(u -> f(u), U) is parse(substring(u, 2..-1)) : substring returns all the characters of u but the first one (-1 means "the last one" and thus 2..-1 means "from the second one to the las one included).
The result, which is a part of a name is sent to parse which converts it into an integer ;
for instance parse(substring(x10, 2..-1)) gives the number 10.
fdol_order then is the list [1, 10, 11, 12, 2, ...]

Line 2
The previous list is sorted in (default) increasing order and output=permutation means "return only the permutations, not the sorted list itself". The result is thus [1, 2, 3, ..., 12]

Line 3
As in Line 1, lhs~([fsol[ ] ]) takes the left hand sides of all the elements of fsol ;
I could habe written, instead [lhs~(fsol)[ ]] or convert(lhs~(fsol), list).
lhs~([fsol[]])[natural_order] then sorts these left hand sides in the order defined  in Line 2

Line 4
does the opposite of what Line 1 does. A command like A =~ B (provided A and B have the same number of elements) does this A[1]=B[1],  A[2]=B[2],   .... 
If A and B are 2 lists with N elements, A =~ B is a short for [ seq(A[n]=B[n], n=A..N) ].
eval(natural_vars, fsol) evalutes the list natural_vars (=[x1, x2, ..., x12]) accordind to the "rules" defined by fsol, that is 
{x1=5, x10=6.26, x11=0.49, ..., x9=-1.03}.
The final result then is [x1=5, x2=7.36, ..., x12=4.92]

This gices the desired result because  natural_vars is a list (whether fsol is a list or a set doesn't matter). But natural_vars must be a list, for if it as a set eval(natural_vars, fsol) will be identical to fsol because of the automatic ordering of the sets.


In your special case where the variables are of the form xn with n=1..12, it's simpler to write 
eval( cat~(x, [$1..12]), fsol), ... :-)

V&V stands for Verification & Validation.
Under this acronym there exists a vast community of people all around the World that develop a huge amount of effort to insure that the codes they are working on are verified and validated.
The difference between the first V and the second... this simple definition wiill help you to understand it:

  • Verification : does the code solve the equations right?
  • Validation : does the code solve the right equations?

In other terms you may have written a (thus verified) code that solves correctly the equations you have coded, but if these equations are not the good ones your code can't be said validated.

Let's go back to your question: I would be temted to say that Maple solves your equations right.
But have you written the right ones?

So if your question means (verification): "Is the answer that Maple gives the right one?" I would say there is about 100% of chance that the response is yes.

But if it means (validation) :"Did I write the correct equations?" , I don't know. You're the only one to be able to say if it is so :-)

More seriously, compare the results of your procedures to those geom3d:-plane gives ; example:

with(geom3d):
A := 'A':  B := 'B':  C:='C':
plane(P, [point(A, 1, 0, 0), point(B, 0, 1, 0), point(C, 0, 0, 1)]);
Equation(P,[x,y,z]);
                               P
                       x - 1 + y + z = 0

plan3p([1, 0, 0], [0, 1, 0], [0, 0, 1]);
                      [x - 1 + y + z = 0]
          [x = lambda + 1, y = -lambda + mu, z = -mu]


 

@tomleslie 

Thanks tom.

@ecterrab 

Hi, 

This reminds me of once asking this question "is it possible to find all the types a variable verifies?".
At the time this question was perceived as odd and received no response other than "I don't see the point".
I guess this is an illustration of a situation where it makes sense: if you don't know that _Cn is of type suffixed(_C, nonnegint) how can you guess it given that whattype(_Cn) only says _Cn is a symbol?

@dharr 

Thank you dharr, good example and nice solution

@vs140580 

First point: Do you know what a rtable is?

?rtable
The rtable(..) function is the low level routine used by Maple to build an Array, a Matrix or a Vector. The user level commands for constructing these objects are Array(..), Matrix(..), and Vector(..), respectively. See their help pages for more information.
So why do you suggest I didn't use a rtable?

Second point: I don't understand what "Each calls ouput should be in the next row based on the order in which i call in the rtable" means; isn't that what I did?

Third point: "I could even have a different procedure with different outputs generated" : So what, you just have to adapt what I did to your own problem or specify it in a more general way. Am I wrong?


Last point: Have you even try to write your procedure in a Maple worksheet to see what it returns?
I believe youd didn't : 

operations := proc(A)
local O1, O2, O3, O4, O5, O6, O7, O8;
O1 := A + 2;
O2 := 2*A;
O3 := A^2;
O4 := A mod 2;
O5 := A + 3;
O6 := 3*A;
O7 := A^3;
O8 := A mod 3;
end proc:
operations(3)
                               0

You should maybe start by doing the work yourself before asking for help

@vv 

Hi, 
As for the initial question your example (n=2001) works with Maple 2015.


For info it worked with Maple 2015
Maple2015.mw

A code regression for it worked with Maple 2015
For_Info.mw

@planetmknzm 

You are welcome

@BenOve 

I believe you have been lured by a precision issue.
Look in the attached file the results obtained for different values of Digits.
Incidentally a workaround (unnecessary) is given.

PrecisionIssue.mw

@acer 

You wrote "Rather, your problematic case ... is rather ... of the form f(g(..))"
Right, I realized it after Kitonum's answer.

Nevertheless, in the example below: can we say that  (`-`(max)) is the composition of the operators `-` and max?

S := [$0..5]:
(`-`(max))(S)   # answer -5


Does this sugest the answer is yes?

f := `-`:
g := `max`:
f(g(S));     # answer =-5
(f@g)(S);    # answer =-5

If it is so, why does the command below return the correct result while replacing f := `-`  by, for instance, f := `exp` doesn't?

(f(g))(S);   # answer =-5

 

First 12 13 14 15 16 17 18 Last Page 14 of 86