tomleslie

5338 Reputation

15 Badges

9 years, 274 days

MaplePrimes Activity


These are replies submitted by tomleslie

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

read("test.mpl");

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

getenv(PATH)

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!

asinfunc.mw

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

 

restart;
  with(plots):
  with(CurveFitting):
  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 ),
                j=nstart..nstop
              )
         );
#
# 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),
                j=nstart..nstop
              )
         );

 

 

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

with(plots);
implicitplot3d
( z=0.1*r*cos(theta-Pi/2),
  r=0..1,
  theta=-Pi..Pi,
  z=-1..1,
  coords=cylindrical,
  numpoints=10000,
  style=surface,
  color=red
);

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
#
  f:=(x,y)->x^2+x*y+y^2:
#
# 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

restart;
x:= proc(n)
      option remember;
      if n=1
      then return 1:
      else return (1/2)*( x(n-1)+3/x(n-1) ):
      fi:
    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);

Might help if you could explain why the info on the latex help page doesn't work.

BTW Can't access your example file, so can't try it

rgds

Tom

@Carl Love 

Or if you you don't need the extra iinfo provided by planePlot you could try

with(plots):
xRange:=[-10, 10]:
yRange:=[-10, 10]:
zRange:=[-10, 10]:
p1:= implicitplot3d(  -3*x + 2*y + 3*z = 0,
                               x=xRange[1]..xRange[2],
                               y=yRange[1]..yRange[2],
                               z=zRange[1]..zRange[2],
                               color=blue):
p2:= implicitplot3d( 2*y+3*z =0,
                              x=xRange[1]..xRange[2],
                              y=yRange[1]..yRange[2],
                              z=zRange[1]..zRange[2],
                             color=red
                           ):
display([p1,p2]);

As posed I can't tel whether you want

  1. a sequence, which would be 1,1,1,2,2,2,3,3,3
  2. an integer, whihc would be 111222333
  3. or a set containing a single integer which would be {111222333} as written in your original post.

The following code is quick, dirty and covers most of these possibilities

 with(LinearAlgebra):
  M:=Matrix(3,[[1,1,1],[2,2,2],[3,3,3]]):
  outp:=NULL:
  for j from 1 by 1 to RowDimension(M) do
      outp:= outp, convert(M[j,...], list)[];
  od:
#
# So as a sequence
#
  outp;
#
# or as a symbol
#
  p:=cat(outp);
#
# or as an integer
#
  pp:=parse(p);
#
# or as a set containing an integer
#
  ppp:= {parse(p)};

First 145 146 147 148 Page 147 of 148