Mac Dude

1506 Reputation

17 Badges

10 years, 247 days

MaplePrimes Activity


These are answers submitted by Mac Dude

You mean this:

f@@3(x);

?

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:

new_guess:=proc(old_guess,weather)
   calc updated value
end proc;

for time from beginnning to end step one_hour

oldguess:=initial_guess(weather(time));

while abs(newguess-oldguess) > tolerance do
    newguess:=f(oldguess,weather(time))
end do;

systemArray(time):=newguess

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

use(Lattice);

and you are good to go.

M.D.

 

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.

M.D.

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.

M.D.

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,

M.D.

 

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.

M.D.

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...?

M.D.

The quick answer is that

sum(u(n),n=0..infinity);

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

Sum(u(n),n=0..infinity);

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.

sum('u(n)',n=0..infinity);

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,

M.D.

Gridlines have been f'd up in Maple at least since Version 15 (try to have gridlines with a log plot when you need to use display to produce a plot: no gridlines, or no log plot. I had it confirmed by Maplesoft tech support, have been promised that it would be fixed, but it never got fixed).

But I digress. In your case I'd suggest using plots[setoptions]:

plots[setoptions](gridlines=true);

which you place right before the call to plot (or plots[display], or whatever). I found that in several cases it produced what I wanted even when including the option in the plots command would not.

I hope this helps,

M.D.

You can try using "fully qualified" names to inspect variables. E.g., inspect ":-a" if you want the value of at the root level. Or inspect foo:-a if you want a at the foo level. This should work as long as you are in a routine called by foo.

Caveat: I have not tried this myself recently.

M.D.

Maple does not have a library with an Ising model. However, a quick Google search reveals this: http://zhugayevych.me/maple/, where there is a link to an Ising model. Note that I have no clue what it is (I did not load it). Check it out.

To convert your Matlab model to Maple, be aware that [ ] in Maple denotes an index into a Vector, an assignment is := rather than =, the loop syntax is "for i from 1 to 12000 do <Maplestatements> end do; and Maple statements are terminated with a semicolon. Should not be too hard, but do read the relevant Help pages. There is also [Matlab]FromMatlab to convert Matlab expressions.

 

HTH,

M.D.

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