Items tagged with programming

So below is a calculation im trying to create, but it just tells me there is an unexpected IF error, and returns me to the third For line. I have tried it straight and as a procedure but i just cant seem to get it to work. Any ideas or tweaks to make this work would be much appreciated. All of the other variables I've named work in their respective lines of code, which I have left out as it is long as it is!


ComlexAlgorithm:= proc(L)
local N, j, kf, o, DeltaMag, DeltaBond;
global NConfig, Configz1, Col, Row, OldConfig, NewConfig, NewTable;

# Set Delta values to zero.
DeltaMag:=0:
DeltaBond:=0:

# Creates loops to loop through the correct changes in values i.e. Add -1, then 1 to first point, move across each point one by one, repeat from the beginning for each configuration then repeat whole process for the amount of rows.
printlevel:=4:
for N from -1 to 1 by 2 do
   for j from 1 to Col do
      for w from 0 to NConfig-1 do   
         for o from 1 to Row do

# Calculate DeltaMag.
if N=-1 then DeltaMag:=DeltaMag+1 else DeltaMag:=DeltaMag-1
end if:

# Calculate all relevant bonds i.e. 3 values for DeltaMag, except at "corner" lattice points where there is only 2 bonds.
if N= Configz1[w](o, j) then DeltaBond:= DeltaBond-1 else DeltaBond:= DeltaBond+1
end if:

if j-1>1 then
   if N <> Configz1[w](o, j+1) then DeltaBond:= DeltaBond+1
      if N = Configz1[w](o, j+1) then DeltaBond:= DeltaBond-1
else DeltaBond:= DeltaBond
end if:
end if:
end if:

if j+1<Col then
   if N <> Configz1[w](o, j+1) then DeltaBond:= DeltaBond+1
      if N = Configz1[w](o, j+1) then DeltaBond:= DeltaBond-1
else DeltaBond:= DeltaBond
end if:
end if:
end if:

# Calculate if, and by what degree, conifguration number changes using 2^(j-1) which is the arithmetric series for binary. Changes only occur when "incoming" spin is different.
if N= -1 then
   if Configz1[w](o, j) <> N then NewConfig[w]:= OldConfig[w-(2^(j-1))] 
else NewConfig[w]:= OldConfig[w]
end if:
end if:

if N= 1 then
   if Configz1[kf](o, j) <> N then NewConfig[w]:= OldConfig[w+(2^(j-1))] 
else NewConfig[kf]:= OldConfig[w]
end if:
end if:

NewTable[kf]:= [NewConfig[w], BondEnergy(w)+DeltaBond, MagEnergy(w)+DeltaMag];

# Set Delta values to zero to finsh.
DeltaMag:=0:
DeltaBond:=0:

end do:
end do:
end do:
end do:
end proc:

On some platforms, my editor of choice has become the aptly named Sublime Text. Unfortunately, it does not seem to have built in syntax highlighting for the Maple programming language and so I set out to write some.  In the end, I wrote enough highlighting to keep me sane when looking at Maple source, but it could use a lot more work.  So in case anyone is interested I've put what I have in a Github repository: SublimeTextMaple

If you use Sublime Text, please download it and add your own enhacements and share in turn.

I Could Not Write An If Then Or Ifelse Statement. Please Help Me.

f := unapply(x^2-2, x); a := 1; b := 2; n := 10; Digits := 10;
      2    
x -> x  - 2
                               1
                               2
                               10
                               10
c := evalf(eval((a*f(b)-b*f(a))/(f(b)-f(a))));
                          1.333333333
if  f(c)*f(a)<0 then ;
          "      k:=evalf(eval(|(f(c))/(b-c)|)) and "

                          /(1 + k) a f(b) - b f(a)\
             x[i] := evalf|-----------------------|
                          \  (1 + k) f(b) - f(a)  /
            "     elif f(x[i])*f(a)<0 then b:=x[i]"
                 "     else b:=c and a:=x[i] "
                  "     if f(c)*f(a)>0 then "
                 "      k:=|(f(c))/(b-c)|and "

                          /a f(b) - b f(a) (1 + k)\
             x[i] := evalf|-----------------------|
                          \  f(b) - f(a) (1 + k)  /
            "     elif f(x[i])*f(a)>0 then a:=x[i]"
              "     else a:=c and b:=x[i] end if"

Error, unterminated 'if' statement
     Typesetting:-mambiguous(Typesetting:-mambiguous(

       if fApplyFunction(c)sdotfApplyFunction(a)lt0 then , 

       Typesetting:-merror("unterminated 'if' statement")))

I am trying to implement Subresultant p.r.s. algorithm for calculating greatest common divisor. The algorithm decribed in the book:

My code return the correct GCD, however the sub-resultant terms are different from the result of the built-in function. The last term a[i-1] is huge and involves fractions. I think my implementation is same as the algorithm described in the textbook.

I have attached the file. Could anybody spot anything wrong in the code? Why do fractions still appear? In my code, "lsr" is last subresultant term returned from the built-in function, the second one is my result.

with(RegularChains);

[Chain, ChangeOfOrder, Construct, Cut, DahanSchostTransform, Dimension, Empty, EqualSaturatedIdeals, EquiprojectableDecomposition, Extend, ExtendedNormalizedGcd, IsAlgebraic, IsEmptyChain, IsInRadical, IsInSaturate, IsIncluded, IsPrimitive, IsStronglyNormalized, IsZeroDimensional, IteratedResultant, LastSubresultant, Lift, ListConstruct, NormalizeRegularChain, NumberOfSolutions, Polynomial, Regularize, RemoveRedundantComponents, SeparateSolutions, Squarefree, SquarefreeFactorization, SubresultantChain, SubresultantOfIndex, Under, Upper]

(1)

A42vlastsub := proc (f, g) local i, a, dt, bt, om; i := 1; if degree(f) < degree(g) then a[0] := primpart(g, x); a[1] := primpart(f, x) else a[0] := primpart(f, x); a[1] := primpart(g, x) end if; dt[0] := degree(a[0])-degree(a[1]); bt[2] := (-1)^(dt[0]+1); om[2] := -1; while a[i] <> 0 do a[i+1] := normal(prem(a[i-1], a[i], x)/bt[i+1]); dt[i] := degree(a[i])-degree(a[i+1]); i := i+1; om[i+1] := (-lcoeff(a[i-1]))^dt[i-2]*om[i]^(1-dt[i-2]); bt[i+1] := -lcoeff(a[i-1])*om[i+1]^dt[i-1] end do; return a[i-1] end proc;

 

(2)

f := (y^2-1)*((y+1)*x^4+(y^2-1)*x^3+(y^3-1)*x^2+(y^4-1)*x+y^5-1);

(y-1)*x^5+(y^2-1)*x^4+(y^3-1)*x^3+(y^4-1)*x^2+(y^5-1)*x+y^6-1

(3)

R := RegularChains:-PolynomialRing([y, x]);

subresultant_chain

(4)

lsr := LastSubresultant(src, R);

y^25+y^24+2*y^23+4*y^22+8*y^21+16*y^20+46*y^19+160*y^18+402*y^17+808*y^16+1384*y^15+2080*y^14+2932*y^13+3762*y^12+4406*y^11+4740*y^10+4720*y^9+4400*y^8+3810*y^7+2968*y^6+2102*y^5+1360*y^4+800*y^3+400*y^2+139*y+21

(5)

``

mylastsr := A42vlastsub(primpart(f, x), primpart(g, x));

-(35867/3794275180128377091639574036764685364535950857523710002444946112771297432041422848)*y^9-(10309/7588550360256754183279148073529370729071901715047420004889892225542594864082845696)*y^8-(2889061/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^10-(94304133/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^13-(35600337/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^12-(11265153/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^11-(4325932673/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^21-(3534515779/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^20-(2703789263/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^19-(1929251163/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^18-(1277273509/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^17-(778538921/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^16-(432069123/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^15-(215109057/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^14-(5255652033/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^25-(5374732281/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^23-(5474736805/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^24-(4971065401/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^22-(475/3794275180128377091639574036764685364535950857523710002444946112771297432041422848)*y^7-(21/3794275180128377091639574036764685364535950857523710002444946112771297432041422848)*y^6-(332387607/30354201441027016733116592294117482916287606860189680019559568902170379456331382784)*y^32-(1/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^49-(23/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^48-(251/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^47-(1735/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^46-(8571/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^45-(32463/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^44-(99205/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^43-(255999/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^42-(586005/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^41-(1263605/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^40-(2747253/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^39-(6322305/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^38-(15325169/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^37-(37286331/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^36-(86630947/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^35-(186556683/60708402882054033466233184588234965832575213720379360039119137804340758912662765568)*y^34-(92016457/15177100720513508366558296147058741458143803430094840009779784451085189728165691392)*y^33-(275974877/15177100720513508366558296147058741458143803430094840009779784451085189728165691392)*y^31-(847698927/30354201441027016733116592294117482916287606860189680019559568902170379456331382784)*y^30-(1210953247/30354201441027016733116592294117482916287606860189680019559568902170379456331382784)*y^29-(1616246617/30354201441027016733116592294117482916287606860189680019559568902170379456331382784)*y^28-(505494959/7588550360256754183279148073529370729071901715047420004889892225542594864082845696)*y^27-(2376326883/30354201441027016733116592294117482916287606860189680019559568902170379456331382784)*y^26

(6)

``


 

Download subresultant.mw

How can I ask Maple to wake me up after running the code?

It takes a long time to finish the job. So it would be helpful to play a beep or something to inform me the answer is ready.

Thank you in advance for your help.

hi i have this code that doesnt work and I cant find the problem. I cant make the matrix include more than 2 rows. i want this to give me the whole nxn matrix, and then the solution to the wronskian. 

can you pls help?:) thanks! 

with*linalg;
funcs := [x, 3*x, x^2, 5*x];
n := nops(funcs);
print*n;
printlevel := n;
count := 1;
listM[count] := funcs;
for i from 2 to n do listN := diff(funcs, `$`(x, i-1));
count := count+1;
listM[count] := listN end do;
M := convert(listM, matrix);
det(M)

Hello:

I want to make a package or module. Not sure. I cant get my head around what to do. I have loads of formulas I would like to be able to use without going back through work sheets. At present just want to keep it simple.

Have loaded a sample work sheet to use

Intend to place package in Maple2016 library folder.

 

restart

Library Folder

C:\Program Files\Maple 2016\lib

``

``

with(LinearAlgebra):

``

``

Points

Point2 := proc (x1, y1) options operator, arrow; [x1, y1] end proc

proc (x1, y1) options operator, arrow; [x1, y1] end proc

(1)

Point3 := proc (x1, y1, z1) options operator, arrow; [x1, y1, z1] end proc

proc (x1, y1, z1) options operator, arrow; [x1, y1, z1] end proc

(2)

a1 := Point3(x1, y1, z1)

[x1, y1, z1]

(3)

a2 := Point3(x2, y2, z2)

[x2, y2, z2]

(4)

a3 := Point3(x3, y3, z3)

[x3, y3, z3]

(5)

Line through 2 points

LinePts := proc (p1, p2) options operator, arrow; (p2[2]-p1[2])*x+(p1[1]-p2[1])*y-p2[2]*p1[1]+p1[2]*p2[1] end proc

proc (p1, p2) options operator, arrow; (p2[2]-p1[2])*x+(p1[1]-p2[1])*y-p2[2]*p1[1]+p1[2]*p2[1] end proc

(6)

``

Line

Line := proc (a, b, c) options operator, arrow; a*x+b*y+c end proc

proc (a, b, c) options operator, arrow; a*x+b*y+c end proc

(7)

Lines s

LnPrll := proc (l1, l2) options operator, arrow; is(coeff(l1, x)*coeff(l2, y)-coeff(l2, x)*coeff(l1, y) = 0) end proc

proc (l1, l2) options operator, arrow; is(coeff(l1, x)*coeff(l2, y)-coeff(l2, x)*coeff(l1, y) = 0) end proc

(8)

Lines t

LnPrpnd := proc (l1, l2) options operator, arrow; is(coeff(l1, x)*coeff(l2, x)+coeff(l1, y)*coeff(l2, y) = 0) end proc

proc (l1, l2) options operator, arrow; is(coeff(l1, x)*coeff(l2, x)+coeff(l1, y)*coeff(l2, y) = 0) end proc

(9)

``

``

Quadrance between 2 points (2D)

Quadrance := proc (a1, a2) options operator, arrow; (a1[1]-a2[1])^2+(a1[2]-a2[2])^2 end proc

proc (a1, a2) options operator, arrow; (a1[1]-a2[1])^2+(a1[2]-a2[2])^2 end proc

(10)

``

Quadrance between 2 points (3D)

Qd3 := proc (a1, a2) options operator, arrow; (a1[1]-a2[1])^2+(a1[2]-a2[2])^2+(a1[3]-a2[3])^2 end proc

proc (a1, a2) options operator, arrow; (a1[1]-a2[1])^2+(a1[2]-a2[2])^2+(a1[3]-a2[3])^2 end proc

(11)

Triple Quad Formula (3 colinear points)

TQF := proc (Q1, Q2, Q3) options operator, arrow; (Q1+Q2+Q3)^2 = 2*Q1^2+2*Q2^2+2*Q3^2 end proc

proc (Q1, Q2, Q3) options operator, arrow; (Q1+Q2+Q3)^2 = 2*Q1^2+2*Q2^2+2*Q3^2 end proc

(12)

Spread*PolynomialsNULL

SpreadPoly := proc (n, s, rn) with(orthopoly); s-factor(1/2-(1/2)*T(n, 1-2*rn)) end proc

proc (n, s, rn) with(orthopoly); s-factor(1/2-(1/2)*T(n, 1-2*rn)) end proc

(13)

SpreadPoly(3, s, r)

s-r*(4*r-3)^2

(14)

``

 

Download Testpackage.mw

Very new to using Maple or coding in general. Ran into a problem that I couldn't figure it out.

Any help would be greatly appreciated.

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((&sum;)f[z](eta),eta):
Theta(eta):=collect((&sum;)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.

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