KCPower

20 Reputation

3 Badges

8 years, 231 days

MaplePrimes Activity


These are replies submitted by KCPower

@Carl Love I have the s dependence because the input function f can depend on s. I realised that my use of Map was incorrect. In an attempt to do that I I tried to create list [Seq(errorterm(k), k=i..i+3]. However through much experimentation with simple examples it seems that Grid:-Seq cannot process anything other than a range expressed in numbers within the command. I.e it does not seem possible to index over variables defined elsewhere like is possible with the normal seq command. As an example I tried

with(Grid):

t:=1;
A:= n-> add(i^2,i=1..n);
Seq(A(k),k:=t..t+4)

This gives the error

"Error, (in Grid:-Seq) unable to execute seq
Error, (in Grid:-Seq) unable to execute seq
Error, (in Grid:-Seq) unable to execute seq
Error, (in Grid:-Seq) unable to execute seq
Error, (in Grid:-Seq) unable to execute seq
Error, (in Grid:-Seq) invalid input: op expects 1 or 2 arguments, but received 0"

However if I replace Seq with seq the code works perfectly. Do you happen to know a workaround for this?

@tomleslie Once again thanks for your suggestions. In my edit I've included my call. As I explained in the edit I did get the code working normally before trying to speed things up. The value "n" is just the argument of my functions "ma" and "errorterm". I want to be able to evaluate the function errorterm at different upper limits of the sums.

@tomleslie Thank you for pointing out my mistakes, I'm new to this forum so am not sure about the correct way of posting. I've edited the above post to include the call for HeatPC. The function "a" should read "fcoef". I changed it in my code but forgot to change it in the question.

@Carl Love I studied physics in undergrad so I've been exposed to bits and pieces of Maple and Matlab a few years back, so unfortunately cannot claim any exceptional learning ability :p

I am beginning to see that "symbolic vs. numeric" greatly affects computation times, but I know nothing of what these terms mean besides the shallow dictionary definition. You seem to be very knowledgeable about Maple, so would you perhaps know of any references offhand that explain the differences well? If not I can always resort to Google, but I find that having a guided search from people in the know really speeds up the learning process. If such a request is not appropriate for this forum I apologise, As this is my first post I am unaware of the rules.  

Thanks again for the help.

 

HeatP := proc (f, g, n, lambda, N, T)
 local k, u, L;
 u := proc (x, t) options operator, arrow; sum(sqrt(2)*(int(sin(k*lambda*x)*g, x = 0 .. 1, numeric))*exp(-k*lambda*t)*sin(k*lambda*x), k = 1 .. n)
 end proc; 
L := [Grid[Seq](plot(u(x, (i*T-T)/N), x = 0 .. 1), i = 1 .. N)]; 
return display(L) 
end proc

@Joe Riel Thank you for the helpful tip. I'm a pure mathematics student so only rarely delve into coding, so such advice is very useful. I have fixed up my serial code and used the Grid package to better use my core i7. Please see if there any other inefficienies I can improve on, (I plan to use the f later when I incorporate a non-homogeneous component.)

@Carl Love Thank you for the answer. So basically there's no ideal way to achieve what I'm trying to within Maple, but my best chance  of speeding things up would be to use Grid?

Page 1 of 1