Mac Dude

1531 Reputation

17 Badges

11 years, 38 days

MaplePrimes Activity

These are answers submitted by Mac Dude

Assuming that the example is just that and blonde Katie really looks for a general way how to do similar problems in Maple, here is a possible scheme (and yes, you'd do it similar by hand).

xpr:=n+N-1; # I use an expression, not a function, since it is simpler for this example

x=n/N; # This is an equation, not an assignment (note absence of ":"). It is what Katie has given.

solve((3),N); # express the equation in terms of the variable to be replaced (I could have picked n as well). (3) is the eq. number of the previous equation.

eval(xpr,N=(4)); # eval the original expression at the given replacement for N. (4) is the result of the solve for N.

As others have observed, you cannot get rid of a variable in this case, so the n remains.

There are more compact ways to do this simple example, but I wanted to outline the steps, assuming we are talking to a Maple apprentice here...



Your syntax is wrong:

1. The assuming statement is outside of the solve; in addition you may need to have the option useassumptions in the solve call.

2. assuming does not handle compound logical relations, you need to split these. I.e

solve(F(z),z,useassumptions) assuming -0.5<m, m<0.5, 0<u, u<0.5;

By specifying option explicit in the solve call you get an explicit value for z, but it is too complicated to print here.


In some cases eval maybe what you want:



Mac Dude


You mean this:



Mac Dude


Here is a structure that may do what you want. In words:

You write a procedure that takes the guess, does its calculations and returns the updated value.
You iterate that procedure within a while loop until the process has converged. You wrap that loop in an outer loop to execute once per time slot (e.g. hour).
You have your weather data (which is input to the calculations) in an Array or in an algorithm as function of time. The outer loop picks the appropriate value.
You store the result of the calculation in another Array for later processing.

In high-level pseudo-code:

   calc updated value
end proc;

for time from beginnning to end step one_hour


while abs(newguess-oldguess) > tolerance do
end do;


end do;

You may need to make sure the while loop terminates even if convergence is not obtained. You may wrap the inner loop into another proc for structure. You can put all the procs in a module for better encapsulation.

Mac Dude

You are not saying what kind of data you have, but assuming this is not just a few numbers but things like vectors and matrices I would look at ExportMatrix and ImportMatrix. See the Help on these. They are fairly general.

If these do not do the trick for you you'll have to tell us what kind of data you are trying to shuffle around.

Mac Dude.


It seems you are trying to use Maple as a text processor. That is a bit hard to do.

I suggest you use a decent text editor to fix whatever needs fixing (e.g. you decimal commas to decimal points) using search and replace, and the use ImportMatrix to read it in. ImportMatrix lets you specify the delimiter so you don't need to change that (and by the way; a tab is given as "\t" [with the quotes]). RTFM on how to read a generic delimited file.

I believe ImportMatrix will lump multiple delimiters (e.g. spaces).

Mac Dude.

You can save the package code as a text file with extension .mpl and read it in:

read("/Applications/Math_Calc/Maple 15/Packages/Lattice/Lattice4.mpl");

The first statement in the file is

Lattice:=module() option package;

To use it, follow the read sratement with


and you are good to go.



The principle is to Fourier-transform your data into the frequency domain; multiply the spectrum (which is complex) with a chosen transfer function (which could be a step function that removes unwanted frequencies] and transform the result back. to the time domain. I usually use DiscreteTransforms:-FourierTransform and its inverse  to transform the data. Trickyness comes in because FourierTransform gives both the spectrum and its reflection about the max frequency (plot the abs of the result to see what I mean) so your transfer function has to take that into account. Another potential issue can be the offsets at the beginning and end of your data series; these can lead to artefacts. You will need to experiment.


I pre-pended your sheet with the customary restart; and then I no longer get the :-. You do not need to declare Psi as local.

In general, :- refers to the instance on the global namespace in case you have multiple namespaces. I.e. if you load a package using with(package); then the "exports" of that package (which are package:-variable) mask any normal variables, but you can access the normal variables by writing :-variable.

I hope this is clear anough.


You are printing something using a number format, but that something is not a number. Either change your format or make sure that what you are attempting to print is actually a number.

Do note that for Maple a floating point number and a rational (or an integer) number are not the same thing (and Pi is also not a floating point number). If you think that what you are trying to print has a numerical value, try wrapping evalf() around it, which will make it to be a floating point number if it can.

Hope this helps,



ArrayTools:-Size[2] should give you the size of your matrix in the 2nd dimension. So do something like


while (ArrayTools:-Size(A)[2]>i or A(1,i)=0) do


(I have not actually tried this so you need to experiment and RTFM).

Hope this helps,

Mac Dude


Excerpt from the documentation (solve/details):

 The useassumptions option will not make use of any assumptions that cannot be rewritten as polynomial inequations.  In particular, it does not process assumptions restricting the domain:
solve(x^2+1,{x}, useassumptions) assuming x::real;
Warning, solve may not respect assumed property 'real' on 'x'.
                       {x = I}, {x = -I}
instead one should use RealDomain[solve] or isolve for solutions over the real numbers or over the integers, respectively.

So, the answer appears to be to use RealDomain:-solve. You can restrict to x>0, which also forces x to be real, but that may be too restrictive for some cases.

Or you do what kitonum suggests.


Our library does not appear to give me acces to the article so I cannot check it myself. But normally you would contact the corresponding author of the article (who is nowadays usually identified by an email address) and ask whether the code is available.

I assume you checked Maplesoft's application website...?


The quick answer is that


is what you would think it is (except in cases where sum itself does not do what you might expect).


is the inert form, i.e. Maple does not try to execute it. The visual clue is that the sum symbol is printed in gray in the output. This is often useful e.g. when you want to simplify the argument under the sum or to distribute the sum over the terms or other manipulations, before evaluationg the sum.


means that u(n) does not get evaluated before handed over to the sum function. Thre may be cases where that is useful although I cannot come up with one quickly.

Other than that be aware that sum tries to evaluate symbolically, e.g. to find a closed expression for the sum. If you want to add a certain number of terms, add() is the function to use.

Hope this helps,


5 6 7 8 9 10 11 Last Page 7 of 20