Mac Dude

1546 Reputation

17 Badges

12 years, 46 days

MaplePrimes Activity

These are replies submitted by Mac Dude

Assuming this is a homework problem, show us what you did. Otherwise we just have to conclude that your integration routine has an error.

If you just need the answer, Robert showed you what to do. There are some subtleties with numeric integration; you may need to go through the docs to learn about the actual routines used, accuracy limits, no. of digits used and the like.


@georgepan I had a look at the Maple sheet. I would save the Excel as a csv file (comma-separated values) and read that in with ImportMatrix. The you can substitute the v[i] and xi[i] with the columns of the read-in matrix.   


@Mac Dude Hmm... reading your question again, did I misunderstand it? You state you want to "export" the constants and derived values; do you mean by "export" to save them somewhere (on disk) for use in a later run; or do you want to get at them in the worksheet calling your procedure, so you can use them for later calls, but in the same run? If the latter case you want to wrap the procedure you have in a module and then use the export declaration for those variable you need to get at. This is explained quite well in the Maple Programming Guide.


@acer I certainly agree that my use of x for both the parameter of the function as well as the argument in the call is unclean & I should have used t or whatever else. My example presented the function to answer the specific question of the OP, who asked about plotting a function. I did not go into plotting the values of an expression.

Having said this, what is it you consider bad about your last example? On occasion I will use unapply just to recast an expression into a function when it seems more natural to the task at hand, e.g. to explicitly carry a parameter that has relevance to the problem. I agree that doing this just for plotting is unnecessary, but is it a capital sin?


It appears you use commas as decimal points. I am not familiar enough with Maple's localizations, but when I load your sheet into my (Norh American) copy of Maple the commas create sequences and you do not get what you'd expect.


I don't think the F-D distribution should reach 1.8 @ E=0 unless there is an overall multiplier. The function would make more sence if there were parentheses around exp()+1.


@Voltageist Your definition of H is wrong.

In Maple, you write

H:=(x) -> G(G(x));

Didn't we just go through that a few days ago... maybe it was someone else. But this comes up all the time.

If you write H(x):=... then H(x) is treated like a name; so H(x) works, H(1) does not; H(y) does not either.

If you fix that the diff and eval work. My version of Maple (15 on this particular machine) is struggling with the simplification, though, so you may want to do the simplification in a separate step. Newer Maples and/or new computers may help.


@Joe Riel Joe, you are correct (of course).

However, the OP may want to inspect the logic of what he is trying to do here. In both procedures he is using i,j,k and epsilon without assignment. So the result depends on on which namespace Maple decides these are in. Presumably that can change with Maple versions (even if that may be unlikely). So should these be globals? Then declare them as such. Should these be exports (meaning they are in the namespace of myQuaternions) then declare them as such. In the calling routine any use of the exports will default to myQuaternions:-epsilon etc., which is different from epsilon in the callers namespace (:-epsilon at Maple's command prompt).

Now, once these are protected, then you cannot assign anything to them. It is not entirely clear what the use is in that case.

Mac Dude

@siamak taghavi Next time, please quote the correct problem. In your initial question you coefficients like A1123 etc., which in Maple are names. Carl gave you an efficient way to extract those names from your expression. Then you say it does not solve your problem and restate your problem, with numbers (floats) substituted for the names. That is a different problem requiring a different solution. If you want to become proficient in Maple you will need to adhere to a certain exactness in your thinking. Numbers are different things to Maple than names.

Having said this, your example also shows that sometimes one can make easier progress by delaying substitutions and assignments. I.e., your life may be easier if you do NOT assign the various names in your expression, but rather use subs (like subs(A1123=678.0,T)) after you did whatever extraction of coefficients you want to do (subs also works on lists or sets). T will then remain as is so you can do different things with it in the same sheet.

Mac Dude


@Alejandro Jakubi Exactly. You cannot series-expand by a function. I assume the underlying reason is that in Maple you cannot differentiate by a function either:


Error, invalid input: diff received f(x), which is not valid for its 2nd argument


While this looks rather meaningless here, there are cases (with known functions) where the differential is evaluated and this is actually useful.

Mac Dude


@epostma Hi Erik,

I did wonder about the inflection point business, and since my function is analytic I may be able to find an expression for the inflection points as function of the input parameter for the 2nd stage. I won't know for sure until I have tried, there are several of these points and I assume I need them all. Reading through your 4 posts of 2010 outlining Maple's algorithm (and thanks for that ref, btw, these are very helpful posts) I take it that handing over the points with the 2nd derivative being 0 should already speed things up... or does the algorithm choke if it gets one where the curvature does not actually change sign (i.e. not a true inflection point)? Looking at the algorithm as outlined by you it is however not clear whether the algorithm Maple uses is more efficient than the pedestrian way if the pdf changes for every point generated. It is clearly tuned towards generating many points with a fixed pdf (which probably covers >90% of all applications).

I do wonder, however, why the thing chokes if I hand it a non-normalized pdf. A part of the reason why my simple approach works ok is that I can hand it an unnormalized function. There is nothing I saw in your (Maple's) algorithm that appears dependent on the normalization of the pdf; yet the generator stalls if I hand it an (even slighly) unnormalized pdf.

Be that as it may, what I have works and is good enough for my present purpose, and I thank you for reading my post and commenting as it is good to know I am not too far off what I shold be doing.


PS: There are a number of posts that Maple employees have done highlighting features of Maple (another one is e.g. Darrin Ohashi's posts on parallel programming). I seem to discover these serendipitously. Is there a way to find all of these, and only these?


@Alejandro Jakubi You may be correct. As we know that does not work. I assume if one has a Parallels license and a license for Maple, it will work in the Windows environment.


@nm Actually I disagree fairly strongly with your assessment of Maple's help pages. While quality varies, overall they do a quite decent job, at least for me. Every-so-often they venture into details that can be quite useful. Yes the organization could be clearer. Yes, it did take effort and time to wrestle Maple's help, but then; it took time at least for me to wrestle Maple as a system. Ultimately these are tools, complicated ones, that take effort to use effectively. Once you master them they are incredibly powerful, but they will not spare you effort and the occasional sweat.

As for your example of a "bad" page: This appears to be a conversion of a Maple workbook. I find no fault in that; it shows the reader what to expect in a format he should be familiar with. One might argue about the wisdom of chosing 2-D input format vs the red 1-D, but then, some people think the sky should be yellow...

Get comfortable with Maple's help, and have it open at your side always. Explore it and persist. Over the long run, it'll be your gain.

Mac Dude


@Kitonum Actually, I would argue The OP should use "Round Screen Display" on the same panel. In that way he keeps full precision in the arithmetic and only gets the display rounded.

The same effect can be achieved in code with

interface(displayprecision=(digits));# put the wanted number of digits in


Hi Kreso,

First, as long as you are asking Maple questions please let's stick to Mapleprimes and do not send private emails. In this way everyone profits.

Second; you asked about how to create sequences with fractional values. As it turns out the easiest way is to use a non-integer step size:



What I suggested earlier using a function works like this:


                        fr := x -> 0.5 x
                          [ 0.     0.]
                          [          ]
                          [0.5   0.25]
                          [          ]
                          [1.0   1.00]
                          [          ]
                          [1.5   2.25]
                          [          ]
                          [2.0   4.00]
                          [          ]
                          [2.5   6.25]
                          [          ]
                          [3.0   9.00]
                          [          ]
                          [3.5  12.25]
                          [          ]
                          [4.0  16.00]
(and I don't know why it shows up different here; it's the same as above on the screen).

I am posting the file here so you can play with it. I hope this is helpful

Mac Dude

First 23 24 25 26 27 28 29 Last Page 25 of 42