## 792 Reputation

9 years, 230 days

## AMAZING...

indets(eq, {name, function(name)})     (Kitonum)
and
indets(eq,function(name))  (Thomas Richard)

work both of them amazing well, all of this in a single instruction !

Who should I plebiscite for the first idea?

## a synchronization problem...

Our mutual responses must have crossed, I will watch your latest messages carefully.

## @Kitonum  @Thomas Richard  @to...

***** Ouups,  I cannot find my reply to tomleslie ... probably an operating error of my own

First, I must thank you all for the time you spent to give me answers or hints.
Some of your answers, if not solving my “more complicated” problem have given me some ideas to deal with it.

Maybe you will be interested by these two examples where my "method" (not at all one hundred percent sure of its robustness !!!) returns the expected answers

Case 1
eq :=  F *diff(x(t), t\$n)  - G

Where n is an integer >=1 and F and G are arbitrary functions of x(t) and its successive derivatives up to order n-1 (at most), it seems that this piece of code returns the desired answer “x(t)”

INDEP  := indets(eq, name):     # should contain t  only
DEP      := convert(indets(eq, function), list):
OpDEP :=  op~(1, DEP):
zip((u,v) -> if member(u, INDEP) then v end if, OpDEP, DEP)

# result is x(t)

----------------------------------------------------------------------------------------------------------------------

Case 2
eq := {
diff(x(t), t) - v(t),
F(t, x(t),  v(t))*diff(v(t), t) - G(t, x(t), v(t))
}

the « generalization » below seems to work well

INDEP  := `union`(op~( indets(eq, name))):
DEP      := convert(`union`(op~(indets(eq, function))), list):
OpDEP :=  op~(1, DEP):
zip((u,v) -> if member(u, INDEP) then v end if, OpDEP, DEP)

# result is { v(t), x(t) }

## Thanks ... but ......

I have just sent a reply to tomleslie from which I reproduce here this element

It is not fair to complicate the question once an answer has been provided (my apologies)
… but how how can I deal with this problem ?
eq := diff(x(t), t) = x(t) - 1 +  sin(x(t))

I cannot generalize your solution to all possible functions of x(t) (here a sine).

I'm very sorry to ask you for this extra help

## It was the loophole I tought to...

Efficient but not completely satisfactory ...

The reason is :
I'm working in a team where several computation codes are developed in different languages. To insure that new versions of them do not “regress” we test them on a bunch of test cases and compare the results to those given by a reference version.

To do this one has developed a global Eclipse-based application that eases code versioning and regression testing. This app uses environment variables, for instance  to inform the code of the  test case to run.
… and I must comply with this framework.

So I would prefer, if it is possible, a solution which suits our requirements

Nevertheless, thank you for your help

## Undesired behaviour of Maple 2015 on Win...

@acer

I think the many difficulties  I encountered came from the version of Maple I used.

Acer, could you please realize this simple test in Maple 2015 and Maple 2016

1. Open a new worksheet (not in document mode)
2. After the “>” prompt write something like
> MyVar := # here a string with more than 80 characters”
3. Export this worksheet in a text file (choose mpl, maple text, or whichever other format you want ; lets us name it  ExportFormat).
Let MyTextFile the name of the text file you have created
4. Now click on Open in the menu bar, choose MyTextFile and (let us call it OpenFormat) one format among the ones Maple proposes.
5. Execute the worksheet.

I did it for all the (ExportFormat, OpenFormat) combinations.
Regardless what it is,  the operation (5) above generates an error when executed with Maple 2015 on a Windows 7 machine.

I did not test all of these combinations in Maple 2016 but, (Mapletext, MapleText), or (mpl, mpl) lead to a no-execution error in stage (5)

The condition “more than 80” characters is important : if the line contains less than 80 characters operation (5) works well in Maple 2015.
If not, operation (4) generates a 2 lines worksheet beginning with a “>” : the first one conatins 79 characters and the second one the rest of the original line. Generally the caesura appears at some place that generates an execution error (for example here between the twos “ right to :=)

## I probably expressed myself poorly...

@acer

I apologized, I probably expressed myself poorly ...

I understood what you have said in your previous answers; but the problem for me is now “how can I generate plain text files from existing mw files in order to deal with them in the future ?”.

(I am not going to develop something from scratch by writing code within an editor, but to convert an existing set of procedures into plain text files this same editor can read)

I had prepare a reply with a more detailed explanation of the issue I face with ... but I have found the way to avoid it.

I need to Export my worksheet with the option "Maple text"  : then if I open the text file after having selected "Maple Text" again I retrieve the content of the original worksheet
(other export & open options generate spurious line breaks and execution errors).

Sorry for the disagreement.

Thank you agai for all the informations you provided me.

## Be careful !...

The command  X := RandomVariable(DiscreteUniform(i-x, i+x)): generates a discrete uniform  random variable with possible values

i-x, ....i-1, i, i+1, .... x+i

Then the probability of each event is not 1/2x but 1/(2x+1).

I hadn't understood it was what you wanted !

If you really want to discard the central element i you can :

1/ build your own mass function (I already did it for continuous random variables but never for discrete ones ; so I am not sure it works correctly)

2/ build X this way  (probably a little bit simple)
Xp :=
RandomVariable(DiscreteUniform(i+1, i+x)):
Xn :=  RandomVariable(DiscreteUniform(i-x, i-1)):
C := RandomVariable(Benoulli(0.5)):
X := Xn*(1-C) + Xp*C

Now the random variable X  seems to fit your requirements

## correction...

@acer

The  "export as a text file" (whichever the format is) followed by an "open the text file" with an ad hoc format generates an execution arror as soon as the body of the procedure contained in the mw file exceeds 80 characters.
Each 80 characters a "\n" is generated and is interpreted as a block-break when the text file is read.

So the example given in my previous mail works perfectly, but it is no longer true if you replace a:=1:  by
a:[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1.]:

(this will return something like
> a:[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
> 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
> 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
and an error message such that “misplaced comma …)

I typed a long enough procedure directly from the ECLIPSE's editor (just an example) and tried to read this file from a Maple session: I encountered no problem at all.
But the same procedure typed in a worksheet (same syntax), imported as a mpl or a text file, which is finally open with a suitable format, produces execution error

## I need you to give me a little extra hel...

1. In my own words I would say there are two ways to approach the versioning issue :
1. (the one I thought to initially) my “reference” code is a worksheet and I need to translate it in some text file to run the version control process (in this case I have to use File > Export … or WorksheetToMapleText).
2. (the one you use if I am not mistaken) the “reference” is a text file build with some editor and directly usable in a version control process, and its testing needs a translation into Maple input style.

I have decided to use your approach and thus to translate into text files all my mw files.

1. WorksheetToMapleText looked to be the clever tool to use.
But it works fine if the mw file contains a few commands or simple Maple objects, and fails as soon as it contains procedures with embedded references to other (user) procedures (in case you would be interested in that I could develop the issue and send you the error message).
Do you thing that it worth to invest further this solution ?

I then came back to the manual “File > Export as” operation.
There are many proposals (mpl, plain text, …) to generate a text file and 3 “open” possibilities to load it in a worksheet file.
Unfortunately I was not able to do the things correctly in this simple case :

> F := proc()   # here is a “shift+enter”
local a:         #   idem
a := 1;          #   idem
end proc:     # here is a simple “enter”
> F()
>

Amongst the many export and open format combinations, even those that seem to produce a “correct” worksheet lead to an execution error
This is due to the fact that the “shift+enter” keys combination is transformed into an “enter” section breaking command.

So the body of the procedure F is broken after the first line and I get an error message indicating that “local” is misplaced

> F := proc()   # here is a “shift+enter”
>  local a:         #   idem
>  a := 1;          #   idem
> end proc:     # here is a simple “enter”
> F()
>

How can I fix this ?

PS 1 : the worksheet

> a := [   # here is a “shift+enter”
1,         #   idem
2]:        #   here is a simple “enter”
becomes after back and forth translation  > a := [1, 2]:   giving no break in the list structure.

PS 2 : I am working with Maple 2015 & 2016 on Windows 7

## @Carl Love   Hi Carl, You write ...

@Carl Love

Hi Carl,

You write “ I like one file per module.“ : me too, but I have no good argument for that except that I do the same thing in Fortran (for example).
Nevertheless I understand acer and his “a procedure = a file” stance  ; but it seems to require a strong discipline I am not sure to possess.

So if I understand your answer correctly, you use text files for versioning purposes, just as acer does too ?
In this case (I could have ask the same question to acer), let us say you “code” in vi or emacs or whichever editor and next you load your text file within a worksheet to test it ?
Is this not to wieldy?

## @acer Hi acer, Several points : The...

@acer

Hi acer,

Several points :

• The TestTools package :  I did not know it, I am going to see how it might be helpful

• You write “.mw is completely at odds with decent, workable revision control…” : this is also what it seemed to me (maybe there is this Maple IDE which could help ?)

• The text file approach was the one I was looking at ; but I thought it had a main drawback (in my opinion) : I like to develop “my reference” code within the worksheet/text mode, which means that exporting it as plain text or mpl format is a manual operation I cannot vouch for (how can I be sure that this text file is the image of the worksheet  ?)

• About the Maplets : Why did  I use them ?
(1) The data the user has to provide are naturally structured in “groups”  which should  be described sequentially  :  using Maplets  is a way to force the user to do the job  in the desired  order (seemed less simple with embedded components).
(2) I knew a little about Maplets when I began working on the interface but nothing about embedded components (beyond their names) … ok, it’s probably a loose argument

I am aware that Maplets are fell into disrepair today and that embedded components are often promoted instead : for this reason I had in mind to “migrate” one day to embedded components

## Wowwww !...

My “application” has two components :

• first is a graphical maplet-based  interface made of about 50 procedures (not all contain maplets) ; all the stuff is contained in a single worksheet with 52 sections : one per procedure ; one for the module definition  (in which  use 50 commands such as proc1 := eval(:-proc1) in the export directive) and the last one for creating the mla.
• Second is the “computational code” itself, made of a “main” worksheet, plus a lots of modules written as the previous one.

From your answer I realize that the way I used to build the code is not at all adapted for code versioning, for I have to split all my modules in individual text files.
(I guess the .mv to .mpl translation has to be done manualy from the “export as” menu ?).
Of course it will take some time but nothing complicated.

I’m not familiar with the \$include directive in modules (not am I with \$define) : I need to take a look in these.

By the way, on your answer, does it means that you make the developments directly in a text file, or that you do them in a  worksheet and then export it as a text file ?

Thanks again,  all that remains for me to do is to roll up my sleeves

PS : I intend to us GIT to do the versioning : does it exist a plugin to do syntactic colouring ? (for example tomments in one color, MAPLE keywords in another ...)

## yes, but not this site you give...

@ThU

from Google with keywords "eclipse plugin maple" I came upon http://fr.maplesoft.com/products/toolboxes/IDE/index.aspx

and found this info

Looking for Maple IDE?
Maplesoft is no longer acting as a reseller for this product from DigiArea Inc.
Maple includes many features to support application development, including a Code Editor. Learn more

that made me think to Maple IDE as an abandoned product  (Eclipse claims the plugin is no longer operational since 2012)

I'll be taken a look on the site you give,