13579 Reputation

19 Badges

13 years, 105 days

MaplePrimes Activity

These are replies submitted by tomleslie

Check my original post - why doesn't

ListTools[Search](12, ans)



I'm running Maple19 - don't have access to Maple13

If you define the procedure as

quadsumstats:= proc(n::integer)
                               return [seq(numelems([isolve(x^2+y^2=k)]), k=1..n)]
                        end proc;

then executing


will assign to ans,  a 100-element list of the number of solutions to x^2+y^2=k for k =1..100.

Notice that this simple procedure will return all possible solutions and you may (or may not) regard these as exhibiting some double-counting. For example quadsumstats(4) will return the list [4, 4, 0, 4]. the first entry in this list enumerates the four (x, y) values (1, 0), (0, 1), (-1, 0), (0, -1); the second entry enumerates the four (x, y) values (1, 1), (1, -1), (-1, 1), (-1, -1), and so on. Whether you regard either of these as "double-counting" is up to you!!

I don't really uderstand the second part of your question - so I'm guessing that maybe you want to know the first occurrence of a given number of solutions: for example what is the lowest value which has say 12 solutions. You can find this using

ListTools[Search](12, ans)

which will return 25, where the 12 solutions are (0, 5), (0, -5), (5, 0), (-5, 0), (3, 4), (3, -4), (-3, 4), (-3, -4), (4, 3), (4, -3), (-4, 3), (-4, -3).

Again you may (or may not) regard this as having some element of double counting

I suggest you check the first word in my original response - ie "Assuming" - and then my answer on the basis of that assumption. You do not want to

"weight a serie of values which x1 range go from 280 to 4000 by the factors provided by another serie of values, which x2 values go from 206.6 to 12400."

What you wnat to do is

weight a serie of values which x1 range go from 280 to 4000 by the factors provided by the interpolation of another serie of values, which x2 values go from 206.6 to 12400.

In which case the first thing you have to do is perform interpolation on the weight list. As MacDude has suggested, there are several ways to do this. The starting point is probably the ArrayInterpolation command.

Since you do not not provide either the data list or the weight list, then it is difficult to supply explicit code to achieve what you want. Check out


I suggest using the option

yvalues:= ArrayInterpolation(xydata, xvalues, options)

in which xydata will be the weight list of xydata, ("t" in your example): xvalues will be the xvalues in the "S" list. The output yvalues will then be the required interpolated y-values for the weights. Having obtained the interpolated y-values, you can then use the command in my original response


Well If you take my earlier answer

M:=Array([seq( [seq( i+j, j=1..5)], i=1..5)]);

Put this in a simple text file, called (say) test.mpl. Then at the Maple command prompt, type


to read and execute the command.

The only way I can think of this failing is that if you have a more-or-less default Maple installation, then Maple will only search for files in directories specified in your PATH variable. You can find the directories which will be searched by default using


This might not include the directory where you stored the test.mpl file. In this case, just include the full path name in the read command - which on a Windows system will be something like

read( "C:/A_dir/B_dir/C_dir/../test.mpl")


You are correct - obvious to me now

I guess the reason I missed this is that by defining the range for y in the plot command to be -x..x I was actually fulfilling the condiction that abs(y)<=abs(x). This realisation means that I can simplify the piecewise definition even further: see the revised worksheet attached

Note to self - must try harder!

I've just read the Physics and Physics, Vectors help page and can find no statement of the ordering of angles in the triple. When you say it is in the references - you mean I have to have one of these text books to hand, in order to check the convention they are using?? C'mon

Can you confirm that the zenith angle is the second entry of the triple when using spherical polars in the VectorCalculus package (which as far as I know, is not part of the Physics package)

So what was wrong with plots produced by my last post?
Weren't they what you wanted/expected??

Despite what your original post suggested, you do not want to plot inclined circles in 2D.

You also do not want to plot filled inclined circles in 3D

My understanding of your problem now is that (expressed in cylindrical polars) you wish to plot a single surface corresponding to a function

z=f(r, theta)

for theta from -Pi to Pi, and r from 0 to 50-ish. This is trivial to do in Maple provided that the function f() is known.

Given a single combination for (r, theta), can you compute (on paper, with a calculator, or with Maple) a value for z?? In other words what is the function f() - cos believe me, once you can figure out what the function is, then plotting the corresponding surface for all (r, theta) is trivial.

The function can be a procedure, in fact almost anything which returns a value given a couple of arguments.

Your/my problem is that neither of us can define the function f(r, theta) in an appropriate way

The personal stuff

Always dangerous to make assumptions online.

I did a B.Sc in physics (1975), with a PhD in quantum physics in 1979. Then for my sins, I spent the following 30 years designing high speed silicon for communications hardware.

I retired about 5 years ago and only use Maple to solve Project Euler (look it up) problems - so I'm not a Maple expert either. Just an old fart, trying to postpone inevitable senility by exercising my neurons occasionally.

BTW "The professional post doc" you refer to, is someone you should ignore. He hasn't got a clue about how good stuff is produced in any sphere - academic, industry or anywhere else

i can persuade the code you provided to produce some plots of inclined circles - but I'm pretty sure that it isn't what you want!! It is just an incredibly inefficent way to produce the same type of curves which I produced in my first post using spacecurve option.

For better or worse, code is below


  R := [30, 32.5, 37.5, 42.5, 47.5, 50]:
  incl := [0, .5, 1, -2, 2*evalf(Pi)-1.75, 0]:
  pointplot(R, incl, color = [grey, red, blue, green, black, grey], labels = ["radius", "incl"]):
  NewR := [seq(30+.2*i, i = 0 .. 100)]:
  Newincl := ArrayInterpolation(R, incl, NewR, method = spline):
  pointplot(NewR, Newincl, labels = ["radius", "incl"]):
  phases := [0, (1/12)*evalf(Pi), 3*evalf(Pi)*(1/4), (1/4)*evalf(Pi)+.2, evalf(Pi)/(2.5), 0]:
  pointplot(R, phases, labels = ["radius", "phase"]):
  Newphases := ArrayInterpolation(R, phases, NewR, method = spline):
  pointplot(NewR, Newphases, labels = ["radius", "phase"]):
# f(t) is a list of 100 sublists with each sublist parameterised by t
# Each of these 100 entries can be *persuaded* to generate an inclined
# circle in space
  f(t):= seq( [NewR[i]*cos(t),NewR[i]*sin(t),Newincl[i]*cos(t-Newphases[i])], i=1..100):
# eg the first 10 plots defined are
  seq( printf("%a\n", f(t)[j]), j=1..10);
# Plotting all 100 circles at the same time takes a while and
# manipulation of subsequent plot is painfully slow. Setting
# values of nstart and nstop allows any number of these circles
# to be plotted (nstart=1, nstop=100, will plot all 100)
  nstart:=1: nstop:=100:
  display( seq( plot3d( f(t)[j], t=0..2*Pi, x=-1..1 ),
# Out of idle curiosity the same data can be plotted using the spacecurve
# method as per my original post. This does handle all 100 plots
# simultaneously and shades nicely - but apparently this isn't what the OP
# wants????
  display( seq( spacecurve( f(t)[j], t=0..2*Pi),



Well I have just read your code, and the plot3D statement is so syntactically wrong that I cannot even figure out what you were trying to achieve:-(

I respectfully suggest the following

  1. Start simple
  2. I still think implicitplot3D() is your best bet, and you should try to find out why thsi doesn't work for you.
  3. At the maple prompt, type with(plots); <- note the semicolon. Read the list of available commands. Is implicitplot3d in this list?
  4. If implicitplot3d is in the list then execute the following code, which should produce a filled circle in space

( z=0.1*r*cos(theta-Pi/2),

If you get a filled circle, then go back to my previous post, using implicitplot3d, which should produce 4 filled circles with various radii and inclinations

If implicitplot3d is in the list of available commands provided by with(plots), but the above code does not produce a circle in space, the I suggest you type ?implicitplot3d at the maple prompt and check that the options in the above statement are all valid

If implicitplot3d is not in the list of available commands, then I think our versions of Maple are too different for me to be of much further help

I think you need to define your specific problem much more clearly!

  1. Your original post asked how to plot inclined circles - for which I supplied a simple solution
  2. Your next post stated that you wanted to "fill" these circles - for which I supplied another solution. You say that running this gives an error message. What error message?? I am running Maple 18 and don't hace access to Maple 13, but I might be able to come up with a fix if I knew what the problem was!!
  3. Your last post refers to plotting your data in some obscure way which I don't understand.

Pretty sure I won't be able to help much further unless you can clarify exactly what it is that you want. All I have demonstrated is how to plot inclined, filled, circles - you have to decide what to do with this info!!



Having trouble deciding what you are trying to achieve. My original simple example was intended to demonstrate that axis[1]=[tickmarks=xvals] construction can always be used to determine the tickmarks. All you have to do is come with the appropriate list of values.

Another simple example

# Define xvals and yvals at which to evaluate a function
  xvals:=[seq(j, j=-20..20,2)]:
  yvals:=[seq(j, j=-2.5..2.5,0.5)]:
# Define some random function
# Create the 3D array containing [x, y, f(x,y)] values
  arr:=[seq([seq([i, j, f(i,j)], i in xvals)], j in yvals)]:
# do surface plot with tickmarks at xvals and yvals
  surfdata(arr, axis[1] = [tickmarks = xvals],
                axis[2] = [tickmarks = yvals]
# do surface plot with tickmarks at subsets of xvals, yvals
  surfdata(arr, axis[1] = [tickmarks = [seq(j, j=xvals[1]..xvals[-1],5)]],
                axis[2] = [tickmarks = [seq(j, j=yvals[1]..xvals[-1])]]

Like Acer, I'm having difficulty figuring out exactly what your problem is :-(

Well the following pretty obvious attempt would seem to give more or less the same answers as Mathematica

eq:=1/2 - x + x^2 - y + y^2:
solve( {eq>0, x>0, x<1, y>0, y<1}, {x,y});

or am I missing something???

Sorry, brain fade:
Should have said

if you want to do it in entirely unreasonable time, then try commenting out the option remember statement in the proc definition!!

No problem with previous answer from Kitonum - but it takes painfully long if you want to use it with a sequence of arguments. Better to define the process as a recursive procedure with a remember table

x:= proc(n)
      option remember;
      if n=1
      then return 1:
      else return (1/2)*( x(n-1)+3/x(n-1) ):
    end proc:
# Uncomment this if you want to know the values - but the growth in digits length is pretty spectacular
# seq( x(j), j=1..20);

# this checks that the first 100 values are rational, in reasonable time - if you want to do it in entirely
# unreasonable time, then try uncommenting the option remember statement in the proc definition!!

seq( type(x(j), rational), x=1..100);

First 202 203 204 205 206 Page 204 of 206