Items tagged with programming programming Tagged Items Feed

I'd like to find out what number Maple can still calculate the isprime for, and what number will make it go "No thanks, this is madness - ERROR".

I tried isprime (10100,000,000 + 2), and it can still calculate the result. No prime of course, that's the whole point of the +2.

I tried isprime(1010ˆ9 + 2) and it crashed.

But what is the tipping number?

I decided I should write a loop, and let maple write away the last number till it crashes. Is this possible? I think I'll need something like

> for n from 5 to ??? do isprime (10ˆn + 2) and ??? end do

This isn't suitable at all, but I cant figure out how to program "to error" or "write away this number"...

 

I hope the question is clear and look forward to ideas on how to make this work.

 

Ok i have used a diverse range of programming IDE now, but i am of course alot more comfortable the maple interface simply because of the amount of time i have spent on it, also it was my first "real" introduction to programming, but i was keen to trial and review of all the major CAS out on the market, but for a common purposed package within them they provide, for example the number theory package.

 

So the question is quite broad, im looking for suggestions for the most unbias way to go about this.

it would need to be a coauthored review with a representative writer for the seasoned user for each one right?

Dear Community,

I would like to calculate a rather sophisticated function (see it in the attachmenet) Once I try to evaluate it at certain values I get the error message:

"Error (in pD) illegal use of an object as a name" 

What object Maple means? I guess its a minor mistake, yet I'm lost here, and the online help says "There is no help page available for this error"

Tx for the kind help in advance,

Andras

 

Bessel_plot.mw 

Walking into the big blue Maplesoft office on August 3rd was a bit nerve wracking. I had no idea who anyone was, what to expect, or even what I would be doing. As I sat in the front hall waiting for someone to receive me, I remember thinking, “What have I gotten myself into?”. Despite my worries on that first day, interning at Maplesoft has been a great experience! I never knew that I would be able to learn so much about programming and working in a company in such a short amount of time. Although Maple was a programming language that was foreign to me a couple weeks ago, I feel like I’m relatively well versed in it now. Trying to learn a new language in this short timespan hasn’t been easy, but I think that I picked it up quickly, even if I’ve had my fair share of frustrations.

Chaos Game example on Rosetta Code

At Maplesoft, I’ve been contributing to the Rosetta Code project by writing short programs using Maple. The Rosetta Code project is dedicated to creating programming examples for many different tasks in different programming languages. My summer project has been to create solutions using Maple for as many tasks as possible and to post these to Rosetta Code; the goal being to have the list of tasks without Maple implementation shrink with each passing day. It’s nice to feel like I’m leaving a mark in this world, even if it is in such a small corner of the internet.

Flipping Bits example on Rosetta Code/MapleCloud

This internship, of course, came with its share of challenges. During my work on the Rosetta Code project, I posted solutions for a total of 38 tasks. Some of them were easy, but some of them took days to complete. On some days, I felt like I was on top of the world. Everything I made turned out great and I knew exactly how to tackle each problem. Other days were slower. I’ve spent ages just staring at a computer monitor trying to figure out just how on earth I was going to make this machine do what I wanted it to do! The 24 Game task was particularly hard, but also very educational. Through this task, I learned about modules, a concept previously unknown to me. I’m fairly sure that the 24 Game also took me the longest, whereas the Increment a numerical string task took me no time at all. Despite it being easy, the Increment a numerical string task wasn’t particularly fun; a bit of a challenge is required for something to be entertaining, after all. My personal favourite was the Fibonacci n-step number sequences task. It was the first really challenging task I encountered, and for after which the feeling of finally completing a task that I spent so long on, of finally overcoming that mountain, was extremely satisfying. Not all challenges end in satisfaction, however. I often found myself accidentally doing something that made the window freeze. I would close the program, then cry a bit on the inside when I realized I just lost the past half an hour’s worth of unsaved work. Nevertheless, I’m glad I got to face all these obstacles because they have made me more resilient and a better programmer.

The following is the code for the Fibonacci n-step number sequences task

numSequence := proc(initValues :: Array)
	local n, i, values;
n := numelems(initValues);
values := copy(initValues);
for i from (n+1) to 15 do
values(i) := add(values[i-n..i-1]);
end do;
return values;
end proc:
 
initValues := Array([1]):
for i from 2 to 10 do
initValues(i) := add(initValues):
printf ("nacci(%d): %a\n", i, convert(numSequence(initValues), list));
end do:
printf ("lucas: %a\n", convert(numSequence(Array([2, 1])), list));

Maple was a great software to program with and a fairly straightforward language to learn. Having previously programmed in Java, I found Maple similar enough that transitioning wasn’t too difficult. In fact, every once in a while when I didn`t know what to do for a task, I would take a look at the Java example in Rosetta Code and it would point me in a direction or give me some hints. While the two languages are similar, there are still many differences. For example, I liked the fact that in Maple, lists started at an index of 1 rather than 0 and arrays could an arbitrary starting index. Although it was different from what I was used to, I found that it made many things much less confusing. Another thing I liked was that the for loop syntax was very simple. I never once had to run through in my head how many times something would loop for. There were such a wide variety of commands in Maple. There was a command for practically anything, and if you knew that it existed and how to use it, then so much power could be at your fingertips. This is where the help system came in extremely handy. With a single search you might find that the solution to the exact problem you were trying to solve already existed as a Maple command. I always had a help window open when I was using Maple.

Multiplication Tables example on Rosetta Code

Spending my summer coding at Maplesoft has been fun, sometimes challenging, but an overall rewarding experience. Through contributing to the Rosetta Code project, I’ve learned so much about computer programming, and it certainly made the 45 minute drive out to Waterloo worth it!

Yili Xu,
Maplesoft SHAD Intern

pls help review this code, its doesnt return a solution

 

 

restart;
Digits := 16;
M := .5; lambda := .5; Pr := .72; beta := 1; L[w] := 0; m := 1; R := 1; Ec := 1;
N := 7;
for j from 0 to N do J[j] := sum(f[k](t)*(diff(f[j-k](t), `$`(t, 2))), k = 0 .. j) end do;
for i from 0 to N do K[i] := sum((diff(f[k](t), t))*(diff(f[i-k](t), t)), k = 0 .. i) end do;
for j from 0 to N do G[j] := sum(f[k](t)*(diff(theta[j-k](t), t)), k = 0 .. j) end do;
for j from 0 to N do H[j] := sum((diff(f[k](t), t))*theta[j-k](t), k = 0 .. j) end do;
for i from 0 to N do P[i] := sum((diff(f[k](t), t, t))*(diff(f[i-k](t), t)), k = 0 .. i) end do;
epsilon := 1; delta := 0;
f[0] := proc (t) options operator, arrow; L[w]+epsilon+delta*A*t+(1/2)*A*t^2 end proc;
1 2
t -> L[w] + epsilon + delta A t + - A t
2
theta[0] := proc (t) options operator, arrow; 1+B*t end proc;
t -> 1 + B t
NULL;
;
NULL;
NULL;
NULL;
NULL;

for i to N do f[i] := simplify(-((m+1)*(1/2))*(int(int(int(J[i-1], t = 0 .. eta), t = 0 .. eta), t = 0 .. eta))+m*(int(int(int(1-K[i-1], t = 0 .. eta), t = 0 .. eta), t = 0 .. eta))-M*(int(int(int(diff(f[i-1](t), t)-1, t = 0 .. eta), t = 0 .. eta), t = 0 .. eta))-lambda*(int(int(int(theta[i-1](t), t = 0 .. eta), t = 0 .. eta), t = 0 .. eta))); f[i] := unapply(f[i], eta); theta[i] := simplify(-3*Pr*R*(((m+1)*(1/2))*(int(int(G[i-1], t = 0 .. eta), t = 0 .. eta))-(2*m-1)*(int(int(H[i-1], t = 0 .. eta), t = 0 .. eta))+Ec*(int(int(P[i-1], t = 0 .. eta), t = 0 .. eta)))/(4+3*R)); theta[i] := unapply(theta[i], eta) end do;

NULL;
F(eta):=collect((∑)f[z](eta),eta):
Theta(eta):=collect((∑)theta[z](eta),eta):
with(numapprox);
for k from 2 to 5 do W[k] := pade(diff(F(eta), eta), eta, [k, k]); Q[k] := pade(Theta(eta), eta, [k, k]); SOLL1[k] := expand(coeff(numer(W[k]), eta^k)) = 1; SOLL2[k] := expand(coeff(numer(Q[k]), eta^k)) = 0; SOL[k] := solve({SOLL1[k], SOLL2[k]}, {A, B}); print([k] = SOL[k]) end do;
Warning, computation interrupted

 

 

 

 

 

 

hy 
need help 
i made this code but i can not get the answer ,help me to find out where i did wrong.

thanx in advance




restart;
f:=x->(x^3+3*x^2-1);
n:=30;
tol:=1e-9;
a[0]:=0;
b[0]:=10;
Digits :=15;

 

printf("No root F(x) abs(x[i+1]-x[i])\n");

for i from 1 to n do
t[i-1] :=evalf( (b[i-1]-a[i-1])/(f(b[i-1])-f(a[i-1])));
c[i-1] := evalf((a[i-1]*f(b[i-1])-b[i-1]*f(a[i-1]))/(f(b[i-1])-f(a[i-1])));
x[i] :=evalf( x[i-1]-t[i-1]*f(x[i-1])^2/(f(x[i-1])-f(c[i-1])));

printf("%d %10.15f %10.15f %10.15e \n",i,x[i],f(x[i]),abs(x[i]-x[i-1]));
if f(a[i-1])*f(c[i-1])<0 then
a[i]:=a[i-1];
b[i]:=c[i-1];
else
a[i]:=c[i-1];
b[i]:=b[i-1];
if abs(f(x[i]))<tol then
print("approximate solution"= x[i]);
print("No of iterations"= i);
break;
end if;
end if;
end do:

I want to define a function f in Maple such that $f(x[1,2]^{-1/3})=\{1,2\}, f(x[1,2])=\{1,2\}, f(x[1])=\{1\}, f(x[1]^{1/3}) =\{1\}$, f(x)=empty set. How could I do this in Maple? Thank you very much.

cannot find the error in loop

 

 

> restart; u[0] := (4/3)*c^2*cos((1/4)*x)^2; alpha := 2;
 
> iteration := 3;
> for k from 0 while k <= Iteration do u[s] := eval(u[k], t = xi); u[k+1] := simplify(u[k]-(int(diff(u[s], [`$`(xi, alpha)])+diff(u[s]*u[s], x)+diff(u[s]*u[s], x, x, x), xi = 0 .. t))) end do;

Hi everyone,

For my first question, I am looking for some help about the following. I have the opportunity to run a worksheet in parallel on a cluster of sixteen workstations, each one endowed with twelve CPUs, through the GRID Computing Toolbox. However, I have troubles concerning how to do that.

I join the worksheet at issue: abmm_ma_1.mw The aim is to run large-scale numerical simulations of a dynamic system, depending on the values given to the initial conditions and to the parameters. The worksheet is organized in four execution groups:

  1. The required packages (combinat and LinearAlgebra).
  2. Calibration of the parameters and initial conditions.
  3. The system, which is embedded into a procedure called SIM.
  4. The activation of SIM, whose outputs are nine .mla files, each one being made of a real-number matrix.

The truth is, I do not clearly see how to modify the worksheet with some elements of the GRID package. Besides, the cluster operates under HTCondor so that running the worksheet requires beforehand the creation of a .sub file. This should be done in consistency with the aforesaid modification.

Any help is welcome, thanks a lot.

Recently, entered a engineering graduate program and will be taking a graduate engineering class in my retirement.  In our Into classes we reviewed engineering math through ODE. In the second class, we performed some numerical methods using MatLab with a small introduction.  My formal Math wass in the 1980s, but now have to fire it up for a Engineering Analysis using Michael Greenberg's Advanced Engineering Mathematics, 2nd which has Maple imbedded code and directions.

 

What would be my assignment for getting up to speed with using Maple to solve algebraic-symbol-programming problems? For instance, which tutorials in what order, or webinars? i think I once had Fortran 77 and remember zip.

 

Appreciate any good advice.

MathMan2

Hello guys, i would like to do parallel computation in my code written in the Maple18. The question that can help me is:

Given a procedure that compute an function g, where g = f1+f2+f3+f4+f5+f6+f7+f8, i would like to compute all fi at same time.
Now, i´m using " grid:-seq('f[i]',[i=1,2,3,4,5,6,7,8])" and it works very well. However, i think that for my case an better solution should be;
Calculate the f1 in core 1, f2 in core 2, f3 in core 3 ... f8 in core 8 at same time, and after this, to sum all results(f1+f2+f3+..+f8). How i can do this?

Att,

Griffith.

I need some help fix my mathematics maple code problem , I define everything my Procedures,and procedures run is ok, but when I using call functions for another procedures  I can not operator my program . For sure procedures is work and correct. if somebody can help me , I really appreciate you help.

Greetings to all. I am writing to present a Maple computation that is somewhat of a programming challenge. A recent Post at Math.Stackexchange.Com asked to compute the number of inequivalent colorings of the vertices and edges of a regular hexagon with two colors available for the vertices and three colors for the edges (vertex colors different from edge colors) under the simultaneous action of the dihedral group D6 on the vertices and edges. This is a standard application of Burnside's Lemma and can be computed very straightforwardly using a negligible amount of computing resources. Important: this is the accepted method, it is documented at the MSE link and it works quite well. The answer is that there are 4183 unique configurations.

My purpose in this message is to propose the following task: write a program in your favorite programming language to verify this number by enumerating all possible configurations, computing the orbits of each, and tracking the orbits to eventually arrive at, we hope, the answer, 4183 as stated. This being MaplePrimes the programming language in question is Maple, of course. I implemented the enumeration method and it can be found in the attachments to this message. The algorithm takes about two minutes on the machine that I used and peak memory allocation is about 70 MB. This made for a frustrating debug cycle as it needed a two minute wait to see the result of the changes made to the source code. I therefore decided to use Perl instead of Maple. Imagine my surprise when the very same algorithm (consult attachment) implemented in Perl had a running time on the same machine of about three seconds, used a hash table of about 1.6MB and had resident memory footprint of 6MB. (In fact the hash table can be reduced to half size by simplifying the keys which makes them a bit more difficult to read during debugging.) Let me state it like this: Perl vs. Maple resulted in a speed gain of a factor of forty and a memory savings of 90 percent.

Now how to profit from this experience. A question naturally appears at this point: can we optimize the Maple code so as to bring it into the range of the parameters of the Perl? Here we permit all sorts of optimizations that may occur to the Maple coder other than using Burnside where the motivation is that for many of us including myself there always remain additional Maple programming techniques to learn and acquire. I hope this makes for an enjoyable exercise and I am looking forward to seeing a Maple implementation that can compete with the Perl. This is not code golf but conciseness is a plus.

hex-maple.txt

hex-pl.txt

Happy computing!

Best regards, Marko Riedel

PS: I suspect working with hash tables rather than sets may be a start.

I have two sets 

f:={1,2,3,4};

h:={1,2,4,5}

L=seq(i,i=1..4):

I want to program , if it is true that f[i] = h[i], then it prints f[i]. So the output should be {1,2}.

for i in L do
if evalb(f[i]=h[i]) then
print(f[i]);
end if;
end do;

I get no output. https://i.imgur.com/qA5hU3i.png

I tried changing the set f to list, f:= [1,2,3,4], still no output.

hi.please help me for remove error'' 

Error, illegal use of an object as a name''

 

thanks

PLATE.mw

   

Parse:-ConvertTo1D, "first argument to _Inert_ASSIGN must be assignable"

Error, illegal use of an object as a name

"restart:Digits :=15: beta:=10:alpha:=100: xi:=.5: upsilon:=0.2841945289:n:=3: aa:=1:b:=1:N_x:=0.4:N_y:=0.4:N_xy:=0: hl2:=1:mu:=65.8e9:E:=169e9: delta0:=1:delta1:=1: mus:=3:D1:=2;h:=1: lambda:=0.1: D2:=5:A1:=-2:A2:=-2:A3:=-6:A4:=7:A5:=7:A6:=7:A7:=7:A8:=8:A9:=7:A10:=7:A11:=1: A12:=1:tau:=4.730040745:t:=0: g2:=sin(theta):g3:=cos(theta):g1:=cos(theta):a:=0.0:with(Student[Calculus1]): a1:=evalf((A1*ApproximateInt(g3^2,theta=a..1,method=simpson)  ) ) : a2:= evalf(A2*ApproximateInt(g3*((&DifferentialD;)^2)/((&DifferentialD;theta)^2)g3,theta=a..1,method=simpson)): a3:=evalf(A3*ApproximateInt(g3*g3,theta=a..1,method=simpson)) : a4:=evalf(A4*ApproximateInt(g3*g3,theta=a..1,method=simpson)) :a5:=evalf(A5*ApproximateInt(g3^2,theta=a..1,method=simpson)) : a6:=evalf(A6*ApproximateInt(((&DifferentialD;)^2)/((&DifferentialD;theta)^2)g3*g3,theta=a..1,method=simpson)) :a7:=evalf(A7*ApproximateInt(g3*g3,theta=a..1,method=simpson)): a8:=evalf(A8*ApproximateInt(g3^2,theta=a..1,method=simpson)):a9:=evalf(ApproximateInt(A9*(g3*g3 )     ,theta=a..1,method=simpson)) :a10:=evalf(A10*ApproximateInt(g3*g3,theta=a..1,method=simpson)):a11:=evalf(ApproximateInt(1,theta=a..1,method=simpson)):a12:=evalf(ApproximateInt(1*(1-1/2 (1)),theta=a..1,method=simpson)):dsys3 := { f3(x)*(a1)+ f3(x)*(a2)  +((&DifferentialD;)^2)/((&DifferentialD;x)^2) f3(x)*(a3) +f3(x)*a4+ f3(x)*(a5) +((&DifferentialD;)^2)/((&DifferentialD;x)^2) f3(x)*(a6) +f3(x)*a7= ((&DifferentialD;)^2)/((&DifferentialD;x)^2) f3(x) *(a8)   + a9*(&DifferentialD;)/(&DifferentialD;x) f3(x) +f3(x)*a10+ a11+a12  , f3(1) =0,f3(0) =0 , D^(1)(f3)(1) = 0, D^(1)(f3)(0)=0,D^(3)(f3)(1) = 0, D^(3)(f3)(0)=0}    :dsol5 := dsolve(dsys3, 'maxmesh'=2024, numeric,abserr=.0001, range=0..1, output=listprocedure):fy3:= eval(f3(x),dsol5):with(CurveFitting):fy33:=PolynomialInterpolation([[0,fy3(0)],[.1,fy3(0.1)],[.2,fy3(0.2)],[0.3,fy3(0.3)],[.4,fy3(0.4)],[.5,fy3(0.5)],[0.6,fy3(0.6)],[0.7,fy3(0.7)],[0.8,fy3(0.8)],[0.9,fy3(0.9)],[1,fy3(1)]],x): d1:=A1*ApproximateInt(((&DifferentialD;)^6)/((&DifferentialD;x)^6)fy33*fy33,x=a..1,method=simpson)   :d2:= A2*ApproximateInt(((&DifferentialD;)^4)/((&DifferentialD;x)^4)fy33*fy33 ,x=a..1,method=simpson)   :d3:=A3*ApproximateInt(((&DifferentialD;)^2)/((&DifferentialD;x)^2)fy33*fy33,x=a..1,method=simpson): d4:= A4*ApproximateInt(fy33*fy33,x=a..1,method=simpson):d5:=A5*ApproximateInt(((&DifferentialD;)^4)/((&DifferentialD;x)^4)fy33*fy33,x=a..1,method=simpson)  : d6:=A6*ApproximateInt(((&DifferentialD;)^2)/((&DifferentialD;x)^2)fy33*fy33,x=a..1,method=simpson)    :d7:=A7*ApproximateInt(fy33*fy33,x=a..1,method=simpson)  :d8:=A8*ApproximateInt(((&DifferentialD;)^2)/((&DifferentialD;x)^2)fy33*fy33,x=a..1,method=simpson)      :d9:=ApproximateInt(A9*(((&DifferentialD;)^1)/((&DifferentialD;x)^1)fy33*fy33 )   ,x=a..1,method=simpson) :d10:=A10*ApproximateInt(fy33*fy33,x=a..1,method=simpson)    :d11:=evalf(ApproximateInt(1,theta=a..1,method=simpson)):d12:=evalf(ApproximateInt(1*(1-1/2 (1)),theta=a..1,method=simpson))  : d sys4 := { h3(theta)*(d1)+((&DifferentialD;)^2)/((&DifferentialD;theta)^2) h3(theta)*(d2)+((&DifferentialD;)^4)/((&DifferentialD;theta)^4) h3(theta)*(d3)+ ((&DifferentialD;)^6)/((&DifferentialD;theta)^6) h3(theta)*(d4)+h3(theta) *(d5)+ h3(theta) *(d6) +((&DifferentialD;)^4)/((&DifferentialD;theta)^4) h3(theta)*(d7)= h3(theta)*(d8)  +d9*(&DifferentialD;)/(&DifferentialD;theta) h3(theta)  +((&DifferentialD;)^2)/((&DifferentialD;theta)^2) h3(theta)*(d10)  +d11+d12   ,h3(1) = 0,h3(0) = 0 , D^(1)(h3)(1) = 0, D^(1)(h3)(0)=0,D^(3)(h3)(1) = 0, D^(3)(h3)(0)=0}  :dsol6 := dsolve(dsys4, 'maxmesh'=2024, abserr=.0001, range=0..1, numeric, output=listprocedure):g33:= eval(h3(theta),dsol6):with(CurveFitting):g3:=PolynomialInterpolation([[0,g33(0)],[.1,g33(0.1)],[.2,g33(0.2)],[0.3,g33(0.3)],[.4,g33(0.4)],[.5,g33(0.5)],[0.6,g33(0.6)],[0.7,g33(0.7)],[0.8,g33(0.8)],[0.9,g33(0.9)],[1,g33(1)]],theta):"

 

 

``

 

Download PLATE.mw

1 2 3 4 5 6 7 Last Page 1 of 10