tomleslie

13876 Reputation

20 Badges

15 years, 165 days

MaplePrimes Activity


These are answers submitted by tomleslie

  restart;
  diff( (1/2)*sin(2*alpha)+cos(alpha)*sqrt( sin(alpha)^2+1), alpha)=0;

appears to retuurn the answer you desire

as in the code

restart;
g := surd(x, 3):
plot(g, x = -1 .. 1);

which produces the plot

If you read the help page for root, you will find the statement

root(x,n) represents the "principal root", defined by the formula root(x,n) = exp(1/n * ln(x))

The term ln(x) in the above definition causes the probelm for negative x

 

 

 

 

 

is to use listplot() to plot the vector with the tickmarks option to adjust the x-axis display. With a "toy" example, the code

  restart:
#
# A "toy" test case where vector entries are defined
# in terms of a variable which rnages from 0..1 in steps
# of 0.1
#
  v1:= Vector
       ( [ seq
           ( j^2,
             j=0..1, 0.1
           )
         ]
       );
#
# A simple listplot() will plot this vector, but the x-axis
# will be the index of the entry in the vector
#
  plots:-listplot( v1,
                   title="Wrong x-axis tickmarks",
                   titlefont=[times, bold, 20]
                 );
#
# One can change the displayed values on the x-axis by
# using the 'tickmarks' option
#
  plots:-listplot
         ( v1,
           tickmarks=[ [ seq
                         ( j=(j-1)/10,
                           j=1.0..11.0
                         )
                       ],
                       default
                     ],
           title="Desired x-axis tickmarks",
           titlefont=[times, bold, 20]

         );

The final execution group will produce

 

 

the attached code solves numerically and analytically. I make some approximations on timestep, and the fact that infinity=10!!, but I have difficulty seeing the difference in the soltuions. the code

  restart;
#
# Define PDE system
#
  PDE := diff(u(x, t), t) = diff(u(x, t), x, x):
  IBC := {u(0, t) = 1, u(1, t) = 5, u(x, 0) = 2}:
#
# Solve numerically
#
  pds1 := pdsolve(PDE, IBC, numeric, timestep = 1/100):
#
# Solve analytically
#
  pds2:=rhs( subs( infinity = 10, pdsolve([PDE, IBC[]]))):
#
# Plot analytic and numeric solutions for fixed 'x',
# varying 't'
#
  plots:-display(  [ pds1:-plot(x = 0.1, t = 0 .. 1),
                     plot(eval(pds2, x = 0.1), t = 0 .. 1)
                   ],
                   color=[red,blue]
                 );
#
# Plot analytic nd numeric solutions for fixed 't',
# varying 'x'
#
  plots:-display( [ pds1:-plot(t = 0.1, x = 0 .. 1),
                    plot(eval(pds2, t = 0.1), x = 0 .. 1)
                  ],
                   color=[red,blue]
              );

produces the graphs

and

Now if I were really bothered by the discrepancies between these graphs, I might consider (for the numerical solution) decreasing bothe timestep and space step, ans (for the analytic solution) increasing the value of "infinity" from 10

  1. In Maple 2020.2, one cannot numerically solve the heat equation in 2 spatial dimensions because the pdsolve(..,numeric) command is restricted to two independent variables
  2. In Maple 2020.2, one can analytically solve the heat equation in 2 spatial dimensions, at least for "simple" boundary conditions, see the attached.
  3. In Maple 2015, I couldn't obtain an analytic solution (or at least it was still "evaluating" after 5 minutes or so
  4. The textbook Partial Differential Equations and Boundary Value Problems with Maple, by George Articolo, has a whole chapter devoted to solving the heat equation analytically "from first principles", in both 2D,  3D and various coordinate systems

heat.mw

You have been working on a trivial vector calculus problem for " the past couple days".????

If true, you should probably consider another line of work!

See the attached

basicVectorCAlculus.mw

the wrong kind of data for a contour plot. The Excel file you supply is 25*25, with data values ranging from -3600..3600. IF we allow for 32 contours, then the contour spacing will be ~225. However, the vast majority of the points (~541) lie betwee -113 and +113, so will all be the same color. This results in a plot which is pretty much all the same color with a few small "hillocks" dotted around.

This can be achieved with code

plots:-listcontplot( ExcelTools:-Import("C:/Users/TomLeslie/Desktop/XLdat.xlsx"),
                     filledregions=true,
                     levels=16,
                     axis=[ tickmarks=[ seq(j=j/5-2.5, j=0..25,5) ] ]
                  );

(You will have to chnge the filepath in the above to something appropriate for you installation)

The above code will produce the figure below

Like I said - pretty monochrome.

The first thing you have to realise is that when doing 2D-plots, Maple uses an adaptive plotting algorithm to determine appropriate x-values to plot. By default you will get 200, but you might get more. Furthermore you cannot control which x-values will be used. So if you plot several curves in the same figure, each curve is actually plotted separately with its own set of x-values. You can confirm this by using the plottools:getdata() command which will return a structure containing multiple 2D-arrays, one for each curve in your figure. First column is x-values, second column is y-values - but the irst columns of these arrays may/will be somewhat different.

 

As you will appreciate this makes trying to extract data from multiple curves at the same set of x-values a real pain. In you particular case, since the curves you are generatng are reasonably smooth, one way to get around ths problem is to uses the output=Array() option in the dsolve() command. This forces the dsolve() command to output data at exactly the points specified. In the attached I specified z-values from 0..10 in steps of 0.1.

 

This means that one can now get all the data you want at identical x-values. For convenience in the attached I organized the data so that the output of each call to dsolve() appears in a matrix whose first column is 'z', second column is h1(z), thrid column is h2(z), and fourth column is h3(z).

 

It is then relatively simple to extract the values for each of h1() and organise these in a further matrix whose first colum is z-value, and subsequent columns 2..12, correspond to the values of h1 for boundary conditions 0..10, Similarly for h2, h3.

 

It is possible to plot directly from these matrixes, and the attached contains most(?) of the plots in your original worksheet. You probably won't be able to see the difference between these plots and those in your original worksheet.

 

Having the all the data organised in matrixes means that it is relatively trivial to use the ExportMatrix() command to export these. Note that in the attached, I am exporting to my desktop, just for test purposes.You will have to change the filepath "C:/Users/TomLeslie/Desktop/ in the last execution group to something appropriate for your installation

 

I would have used the ExcelTools:-Export() command to export directly to Excel, but there appears to be a bug in this command if the matrix has more than 64 rows. I'll follow this up separately. So I ended up using ExportMatrix() to export to .csv, but I can't upload .csv files to this site, so I opened these files with Excel and saved them as .xlsx, which can be uploaded

 

The following worksheet still generates the plots you want

odeData.mw

but will also generate the following xlsx files (after the csv files originally produced have been run through Excel)

bcs5.xlsx

h1Vals.xlsx

 

The code

restart;
eqn:=1.35150599852371*10^10 = 2.45634141630387*10^7*x + 50.7216626470812*x^4 + 6.20132964743411*10^7*x^2 + 1.26328819483651*10^10 + 112528.172146835*x^3;
solve(eqn);
RealDomain:-solve(eqn);

returns

     3.567890209, -3.990136037, -1017.860744, -1200.259666

     -1200.259666, -1017.860744, -3.990136037, 3.567890209

So (other than the order of the solutions), I don't see an issue.

I suppose this might be a version issue - the above was obtained using Maple 2020.2. What version are you using?

I suggest you specify the Maple version you are using, and use the big green up-arrow in the Mapleprimes toolbar to upload a worksheet which illustrates the problem

are covered in the attached worksheet, in which you will have to change the filepath "C:/Users/TomLeslie/Desktop/" to something appropriate for your installation.

There are things you should consider

  1. When Maple generates a 2D plot, it uses an adaptive routine, so that x-values may not be equally spaced
  2. When Maple genreates a 3-D plot, it does so on a fixed grid (which you can specify), but the plot structure does not store the grid points explicitly, so if you need the x-y values then these have to be calculated explicitly.

For 3D plots, the attached file will put x-values in the first column of the EXCEL spreadsheet, and y-values in the first row, bbut how would you want this data "organised" for export to matlab?

exports.mw

 

the help at ?plottools, for basic "geometric" objects.

 

 

The package 'UtilsIORelation' is not distributed with MAple so I assume that it is something you have written, or someone else has written but you have installed and have access. Since no-one here has access to this package it makes complete debug difficult.

One thig that can cause an issue that can cause an issue with Grid commands is that such user defined packages may not be available one remote nodes. See the following section from the Grid:-Seq help page

In this example, we define two procedures such that Seq will not be able to automatically find all definitions to send to external nodes. The remote operation is not fully defined.  
myfunc1 := x->x^2;
   myfunc1 := proc (x) options operator, arrow; x^2 end proc

myfunc2 := x->myfunc1(x)+x;
myfunc2 := proc (x) options operator, arrow; myfunc1(x)+x end proc

[ Grid:-Seq( myfunc2(i), i=1..3) ];
        [myfunc1(1) + 1, myfunc1(2) + 2, myfunc1(3) + 3]

The myfunc1 procedure was not defined in the external nodes. It needs to be set.
Grid:-Set( myfunc1 );
[ Grid:-Seq( myfunc2(i), i=1..3) ];
                           [2, 6, 12]

You may want to play around with the Grid:-Set() command to see if it makes a difference. Otherwise you are going to have to provide the complete 'UtilsIORelation' package here, so that respondenets have any chance of debugging

and my solution is pretty similar.

Note that as far as I can tell there are only three distinct equations - becuase in you original worksheet

rhs(eq1)=rhs(eq2)
rhs(eq3)=rhs(eq4)
rhs(eq5)=rhs(eq6)

Is this deliberate?? The worksheet

bigodes.mw

will produce the following. Note that although six curves are specified, only three curves can be distinguished

 

shown here

  with(Student[Calculus1]):
  with(plots):
  f(x):=0.5*x:
  g(x):=sqrt(0.81-(x-2)^2):
  h(x):=sqrt(3.57^2-(x-8)^2):
  display( [ SurfaceOfRevolution
             ( f(x),
               x = 0 .. 10,
               output = plot,
               scaling = constrained
             ),
             SurfaceOfRevolution
             ( g(x),
               x = 0 .. 10,
               output = plot,
               scaling = constrained
             ),
             SurfaceOfRevolution
             ( h(x),
               x = 0 .. 10,
               output = plot,
               scaling = constrained
             )
           ],
           color=[red, green ,blue],
           transparency=[0.5, 0.5, 0.5]
         );

produces the following plot

See the attached worksheet

gePlot.mw

 

The following code will return the (correctly-spelt) name of a component, if it exists - and nothing if it doesn't

  restart:
  isComp:= comp->zip( (x,y)-> `if`(y=1, x, NULL),
                      [exports(DocumentTools:-Components)],
                      searchtext~(comp,[exports(DocumentTools:-Components)])
                    )[]:
  
  isComp(ComboBox);
  isComp(Combobox);
  isComp(combobox);
  isComp(CombiBox);

Note that only "mistakes" in capitalisation are handled: so in the above code, the first three trials will all return (the correctly-spelt) ComboBox, while the last one will return nothing.

See also the attached

isComp.mw

 

 

First 54 55 56 57 58 59 60 Last Page 56 of 207