AmirHosein Sadeghimanesh

110 Reputation

6 Badges

5 years, 181 days

Social Networks and Content at Maplesoft.com

Finished Ph.D. in Applied Algebraic Geometry in Biology and did postdoc in Mathematics of Chemical Reaction Networks, University of Copenhagen. Another postdoc in Nonlinear Dynamics in the Mathematical Models of Cell Biology at University of Szeged. Currently a research fellow at Coventry University. Main interests; Applied and Computational Algebraic Geometry, Mathematical Biology, Coding. I'm also a language lover! I'm also a language lover!

MaplePrimes Activity


These are replies submitted by AmirHosein Sadeghimanesh

@vv Thanks. It works fine. Just one small complain is that when it is used for type declaration of the allowable arguments of a procedure, then in case of giving a wrong type input table to the procedure, the generated error message is not very informative for the user, specifically if the user is not familiar with programming and is just going to use your defined proc. Let's look at the following simple example.

testProc:=proc(inputTable::satisfies(e -> e::'table', e -> [indices(e,nolist)]::list(integer),  e -> [entries(e,nolist)]::list(list(integer))))
return(inputTable):
end proc;

Now trying  testProc(table([1=[12,14],2=[x]]))[2]; gives an error saying the input argument is not of a correct type, but its message is not in a very informative way.

Error, invalid input: testProc expects its 1st argument, inputTable, to be of type satisfies(proc (e) options operator, arrow; e::'table' end proc, proc (e) options operator, arrow; [indices(e, nolist)]::(list(integer)) end proc, proc (e) options operator, arrow; [entries(e, nolist)]::(list(list(integer))) end proc), but received table( [( 1 ) = [12, 14], ( 2 ) = [x] ] )

For example if it would say a simple message that the entries of the input table have to be of the type integer, it would be easier for the user to notice the problem of his inputs, specially if he is not familiar with programming.

But thanks for introducing satisfies. I may put some lines to produce better error message for the user whenever it is necessary.

 

@yangtheary I guess you have some mistyping in your question. An equilateral triangle has all its angles 60 degrees, then how can BAC be 20? (Equilateral triangle - Wikipedia)

@Carl Love Then the question becomes how to remove more than one element from a table efficiently. For removing an entry of a table, there is a command unassign as explained at page 143 of the Maple programming guide 2020. Is there a command to unassign more than one entry at once or I should use a loop?

@dharr Thanks. But I'm already aware of `maplemint` command at Maple and also `code edit region`. But none of them are what I'm looking for because of the following reasons.

1- One can also write a maple code file (let's say an mpl file) at VSCode as well. Now the Maple's `code edit region` is not something inside VSCode (instead, one can use maple extension for vscode).

2- `code edit region` (and also the maple extension for vscode) has some feautures such as some colorings, but it does not edit what you type. One example that I also mentioned at my question is spaces around ":=". So I want to just type my code and not waste time pressing space key many times. I write "a:=5;", and I expect something automatically change it to "a := 5;". For python, there are such tools that can be used at editors such as VSCode or Atom etc. `code edit region` and also `maplemint` do not do any changes on my written code about spaces etc.

3- `maplemint` can be called on a procedure, and it doesn't work on something like `x:=5;`.

@Carl Love Thanks. Recently a colleague showed me that it is better to use __i instead of [i] for indexed variable names. I still like x[i], but try to avoid it at my current project.

Anyway, about using my simple answer with the __ indexing.

Replacing j[i] with j__i will not work, because eventhough we mean the varying index i, Maple count i as a symbol i at j__i. Now to make sure that Maple put the value of i and not the symbol i itself, we can use cat(j,'__',i) instead of j__i ^_^

L:=[0,1,3,4,6,10,11,15]:
ans:=0:
for i in L do
 ans:=ans+i*degree(f,cat(j,'__',i)):
end do:
ans;

Now we get 41 for f:=j__0^4*j__11*j__15^2 as expected.

You're right, even using `implicitplot` and `arctan` makes extra tails.

plots:-implicitplot(arctan(y/x)=0,x=-1..1,y=-1..1,view=[-1..1,-1..1],color=blue);

This should give the x-axis, while it gives the y-axis as well!

@mmcdara Thanks for your detailed explanation and the code ^_^

@nm Thanks. Using tabular inside figure environment in TeX is a good idea.

@mmcdara Thanks for your suggestion. Yes, or for example one can export the whole "mw" file (the worksheet) as a pdf and then crop the region of interest from the pdf. However, using this method sometimes some parts of the tabulate-plot goes out of the initial whole-file-pdf pages or the ratios and scales change etc.

The screenshot is good as it doesn't change the ratios, scale etc. But then the quaility will not be the same as other plots, let's say you want to use your plot as a figure in a paper.

@acer Thanks. Your first suggestion worked.

I also have the same struggle that Maple simplify a math expression that is supposed to stand only for a label of a plot and not to be simplified. For example using 

typeset(log[10](sigma^2))

gives you ln(sigma^2)/ln(10) which is of course not what I want to put on my plot :'( Is there anyway to emphasize to Maple that please don't simplify or do any changes on my input expression for typeset etc?

Szia Csaba. To convert an expression written in 2-D math, just right clicking on it and then from "2-D math" --> convert to --> "1-D math input" works. Or you can select the expression and then menu bar --> format --> convert to --> 1-D math input. If you have any specific example where instead of the expression itself, its result is getting represented in 1-D math input format, then can you provide one.

An alternative method is to use the following post 

https://stackoverflow.com/questions/27477658/save-putty-ouput-to-file-from-command-line/38347463#38347463

After closing Putty, going to the path you will see a log file, then open it with notepad. But it may look a bit ugly. A picture of the result (in my case) is in below.

@Carl Love  @vv @Preben Alsholm

I used heaviside and piecewise just multiplying one more function to the integrand and then they gave me two different results in Maple!

int(abs((k5*x2-k1)*(k5*x1-k2)-k5^2*x1*x2)*piecewise(0 < -k5*x1*x2+k1*x1 < 1, 1, -k5*x1*x2+k1*x1 <= 0 and 1 <= -k5*x1*x2+k1*x1, 0)*piecewise(0 < -k5*x1*x2+k2*x2 < 1, 1, -k5*x1*x2+k2*x2 <= 0 and 1 <= -k5*x1*x2+k2*x2, 0), [k1 = 0 .. 1, k2 = 0 .. 1, k5 = 0 .. 1, x1 = 0 .. 1, x2 = 0 .. 1]);
## infinity
f := piecewise(0 < -k5*x1*x2+k1*x1 < 1, 1, -k5*x1*x2+k1*x1 <= 0 and 1 <= -k5*x1*x2+k1*x1, 0)*piecewise(0 < -k5*x1*x2+k2*x2 < 1, 1, -k5*x1*x2+k2*x2 <= 0 and 1 <= -k5*x1*x2+k2*x2, 0); g := convert(f, Heaviside); int(abs((k5*x2-k1)*(k5*x1-k2)-k5^2*x1*x2)*g, [k1 = 0 .. 1, k2 = 0 .. 1, k5 = 0 .. 1, x1 = 0 .. 1, x2 = 0 .. 1]);
## -29/360

The function I multiplied is positive and bounded on the region of integration and I didn't use numeric option, so I don't get why Maple once gives infinity and the other time gives a negative value.

@vv 

Writing the integral as limit of a Rimannian sum sequence by the following computation it seems you are right and it is divergent to +infinity.

But then it also means that Maple sometimes give wrong answers, yes? Because the second integral in my question should be greater than the first integral and if the first one is divergent to +inifnity, then the second one is as well.

1 2 3 Page 1 of 3