tomleslie

13876 Reputation

20 Badges

15 years, 181 days

MaplePrimes Activity


These are replies submitted by tomleslie

@asa12 

Maple 12 was released in 2008, so your question is basically "Can anyone here debug ten-year-old software?"

Possibly(?)y, I guess, but my own cut-off date is ~5 years, which means I only keep the last six (or so) major Maple releases running

If you don't get any other answers, then I think you may be stuck with selecting the plot and using the "grab-handles" to resize the plot window:-(

@tomleslie 

The 'size' option for the plot() command was only introduced in Maple 18.

I'm not sure what option (if any) was available in earlier versions

When I supply code here - it works!

The interesting question is -

Why did you take perfectly functional (1D input) code and convert it to something completely different, ie 2D-input code, and expect that it would work???

Whenever someone presents code here, use it as it is written - don't modify it convert it, or anything else - because you obviously have no idea of the possible consequences

Unless you really REALLY know what you are doing, never ever convert 1-D input code to 2-D input code (or vice versa) and expect it to work - the odds are against you

If you are interested in more details about this issue, then contemplate the attached, where I illustrate the errors in the 1D->2D conversion and (eventually) provide 2-D input code for your problem which will work

#
# In the first instance we have perfectly functional
# code written using 1-D input, whihc produces perfectly
# acceptable answers
#
  restart;
#
# Setup/solve the 'toy' example
#
  PDE := diff(u(x,t),t)=-diff(u(x,t),x);
  IBC := {u(x,0)=sin(2*Pi*x),u(0,t)=-sin(2*Pi*t)};
  pds := pdsolve(PDE,IBC,numeric,time=t,range=0..1);
#
# define the desired integral. NB range is
# arbitrary, but it probably ought to be
# "within" the range defined within the
# pdsolve() command
#
  f:= tau->Int
           ( rhs
             ( pds:-value
                    ( t=tau,
                      output=listprocedure
                    )[3]
             )(x),
             x=0.25..0.75
           ):
#
# Compute the integral for a few different 'time' values
#
  evalf(f(0.1));
  evalf(f(0.2));
  evalf(f(0.5));

diff(u(x, t), t) = -(diff(u(x, t), x))

 

{u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}

 

_m724091648

 

HFloat(0.18707013161493055)

 

HFloat(0.30268583123287324)

 

HFloat(-1.2958901818599123e-16)

(1)

restart; PDE := diff(u(x, t), t) = -(diff(u(x, t), x)); IBC := {u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}; pds := pdsolve(PDE, IBC, numeric, time = t, range = 0 .. 1); f := proc (tau) options operator, arrow; Int*(rhs*(pds:-value*(t = tau, output = listprocedure)[3])(x), x = .25 .. .75) end proc; evalf(f(.1)); evalf(f(.2)); evalf(f(.5))

diff(u(x, t), t) = -(diff(u(x, t), x))

 

{u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}

 

_m710918400

 

Error, (in f) invalid subscript selector

 

Error, (in f) invalid subscript selector

 

Error, (in f) invalid subscript selector

 

#
# Now we take the 2-D input code above and copy/paste
# it here, so that we are back to 1-D input code. Note
# that this is not the same as the original 1-D input
# code, and the formatting is crap - but guess what,
# now it doesn't work.
#
# However because the code is in 1-D, we can actually
# see what doesn't work. Problems are
#
#   Why is there a '*' symbol in Int*()  ?
#   Why is there a '*' symbol in rhs*()  ?
#   Why is there a '*' symbol in pds:-value*() ?
#
# These errors are higlighted in the following
#

restart; PDE := diff(u(x, t), t) = -(diff(u(x, t), x)); IBC := {u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}; pds := pdsolve(PDE, IBC, numeric, time = t, range = 0 .. 1); f := proc (tau) options operator, arrow; Int*(rhs*(pds:-value*(t = tau, output = listprocedure)[3])(x), x = .25 .. .75) end proc; evalf(f(.1)); evalf(f(.2)); evalf(f(.5))

diff(u(x, t), t) = -(diff(u(x, t), x))

 

{u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}

 

_m724091648

 

proc (tau) options operator, arrow; Int*(rhs*(pds:-value*(t = tau, output = listprocedure)[3])(x), x = .25 .. .75) end proc

 

Error, (in f) invalid subscript selector

 

Error, (in f) invalid subscript selector

 

Error, (in f) invalid subscript selector

 

#
# If I copy/paste the above and remove the three
# erroneous '*' signs, then lo and behold, everything
# works again
#
  restart; PDE := diff(u(x, t), t) = -(diff(u(x, t), x)); IBC := {u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}; pds := pdsolve(PDE, IBC, numeric, time = t, range = 0 .. 1); f := proc (tau) options operator, arrow; Int(rhs(pds:-value(t = tau, output = listprocedure)[3])(x), x = .25 .. .75) end proc; evalf(f(.1)); evalf(f(.2)); evalf(f(.5))

diff(u(x, t), t) = -(diff(u(x, t), x))

 

{u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}

 

_m724091648

 

proc (tau) options operator, arrow; Int((rhs(pds:-value(t = tau, output = listprocedure)[3]))(x), x = .25 .. .75) end proc

 

HFloat(0.18707013161493055)

 

HFloat(0.30268583123287324)

 

HFloat(-1.2958901818599123e-16)

(2)

restart; PDE := diff(u(x, t), t) = -(diff(u(x, t), x)); IBC := {u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}; pds := pdsolve(PDE, IBC, numeric, time = t, range = 0 .. 1); f := proc (tau) options operator, arrow; Int((rhs(pds:-value(t = tau, output = listprocedure)[3]))(x), x = .25 .. .75) end proc; evalf(f(.1)); evalf(f(.2)); evalf(f(.5))

diff(u(x, t), t) = -(diff(u(x, t), x))

 

{u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}

 

_m703436640

 

proc (tau) options operator, arrow; Int((rhs(pds:-value(t = tau, output = listprocedure)[3]))(x), x = .25 .. .75) end proc

 

HFloat(0.18707013161493055)

 

HFloat(0.30268583123287324)

 

HFloat(-1.2958901818599123e-16)

(3)

 


 

Download 2DcodeAgain.mw

@David1

I have never had to manually move/copy a 'dll' file in order to make the Maple/Matlab link work correctly

Out of idle curiosity, I checked my own machine and this particular file occurs in two(?!) places on my machine, namely

C:\Program Files\Maple 2018\bin.X86_64_WINDOWS\, and

C:\Windows\System32\

But it does not occur anywhere in in my C:\Program Files\MATLAB\ path

Most puzzling!

My current  setup is with Maple 2018.1 linked to Matlab R2018a, so I have to wind back some versions to cover the OP's situation

OP has Matlab 2017a: my Matlab 2017a is currently linked to Maple 2017.3 - nothing special about these version combinations, just a reflection of what versions were around when I created the link. but I have to "upgrade" to achieve the OP's situation

I have just relinked Maple 2018.1 with Matlab R2017a, using the installer, and it works perfectly. Confirmation is provided by the attached screenshot of the Matlab 2017a command window, with output showing both  Maple and Matlab versions

 

This link works for Maple 2018.1 connected to Matlab R2017a.

All you have to do is install it correctly

 

 

@Preben Alsholm 

With a few hacks I could make OP's script run, in the earliest Maple version I have, which happens to be Maple 18 - but I couldn't reproduce OP's problem.

So my remarks on the possible cause being related to the plotting stack, the "white" square, and the set/list issue were essentially "guesses". I simply have no way to test.

Help->Documentation should pop-up a window which looks like

 

Note that in the left-hand pane, the entry "Maple Toolbox" appears under "Supplemental Software"

Since the commands

mapleversion

maple('2*x')

both fail, I think we can assume that you do not have the Maple-Matlab link correctly installed.

Have you tried bullet points 4, 5, and 6 in my previous response?

@shimaa sadk 

If solve() cannot find an answer, it returns NULL, so you just have to check for this case - something like

if       solve(F(X)=0) = NULL
then X:=a:
fi;

Keep one thing in mind - this link does work. I've had this linkage running for several years. The only "maintenance" it takes is that each time I update either Maple or Matlab, then I have to rerun the 'toolbox installer' file mentioned in my earlier response.

########################################################

List of things to check - apologies if I'm stating the obvious

  1. I'm pretty sure that I remember reading somewhere that you couldn't link 64-bit Maple to 32-bit Matlab, or 32-bit Maple to 64-bit Matlab - so for your installation, are both 64-bit?
  2. Don't try to verify the link by running some "complicated script", just do three simple things
    1. Start Matlab, access help. Does 'Maple Toolbox' appear in the left-hand pane, under the Supplemental software? If the 'Maple Toolbox' exists, is the Maple help actually available?
    2. In the Matlab command window, type mapleversion. For me, this returns ans = Maple 2018.1, X86 64 WINDOWS, Jun 8 2018, Build ID 1321769. (Your Maple build ID or release date may be slightly different)
    3. In the Matlab command window, type maple('2*x'). This should return something like ans=     2 x  - maybe  with slight variations depending on whether you have set Matlab output display options in a Matlab.ini file.
  3. If all tests in (2) above are OK, then the Matlab-Maple link is up-and-running, so the problem is with the script you are using for test purposes. If any of these tests fail, then the Maple-Matlab link is not installed correctly. In following steps, I'm assuming that the problem is with the 'link'
  4. Quick check on the contents of your maple toolbox folder. The attached worksheet uses maple to list the contents of my (current) maple toolbox folder, and has been saved with output.  matMaple.mw  Changing the path in the ListDirectory() command to "C:/Program Files/MATLAB/R2017a/toolbox/maple" ought to generate an equivalent list for your installation. You are only looking for "gross" differences, such as wildly different number of files, "empty" files etc
  5. Re-run the file "MapleToolbox2018.0WindowsX64Installer.exe", but make sure you do it with administrator privileges - right click on the file and select "Run as administrator". If it completes with no issues, go back to (2) above and try the checks again
  6. If there are still issues, there *may* be an installation "log" file in the same directory as the MapleToolbox2018.0WindowsX64Installer.exe file. If it exists, and the 'Date Modified' field seems relevant, then load it into your favourie editor, and search for the string "C:\Program Files\MATLAB\R2017a". This ought to tell you if the installer added anything significant to your Matlab installation, and whether it had any problems

 

@trace 

  1. There is a simple syntax error in the definition of eq2. As in, why does this expression contsin two '=' symbols???
  2. There is a more serious problem: eq1 and eq2 are identical, So effectively you now have two equations in four unknowns. Your previous example had three equations in four unknowns. With three equations in four unknowns, it is possible to designate one of the unknowns as the 'independent' variable (I picked T), and then produced graphs of p(T), v(T), w(T). However with only two equations in four unknowns, you have to designate two quantiies as 'independent' variables - say 'T' and 'v', and then produce 3D graphs of the other two, ie p(T,v), and w(T,v). Obviously, other permutations are possible, depending on which variables you choose to designate as 'independent' - so we could have p(T,w) and v(T,w), or w(T,p) and v(T,p). Simply too many combinations to cover exhaustively. Either come up with the three equations in four unknowns, or provide a clear specification of the dependent and and independent variables.

what is yr ?

When using plottools:-line(), the line is defined in terms of two points [x1, y1] and [x2, y2], For a single vertical line, x1=x2. To get appropriate values for y1, y2, one has to programmatically extract the maximum and minimum y-values which occur in the plot of (for my example) t^2*sin(t). 'yr' computes these values as a two-element list

is there an simple example using dualaxisplot 

No idea why you want to use dualaxisplot - all this does is allow you to use two different (ie with different scales) y-axes. You could combine this with either of the examples I have provided - but why?

vertical line is only x=1, x=2, x=3 etc for example around 12 lines 

Then (probably) your best bet is to "turn on " the gridlines option for the x-axis. By convention (in Maple), the x-axis is axis[1], so if you use

axis[1]= [ gridlines=[  [1, 2, 3, 4, 5, 6, 7, 8]
                                  ]
              ],

as an option to the plot() command, then you will get vertical lines at x=1, x=2,,,,x=8. You can, of course, generate the list of x-positions programmatically

It just means that at some point in the numerical solution, a part of the calculation resulted in a complex quantity.

I have looked at your code in more detail, but there is so much stuff which just seems pointless, that I cannot figure out what you are trying to achieve. An example - in your first 'for' loop, you solve the same ODE 100 times -Why?

As a general guide, pdsolve() will solve systems which contain ODEs as well as PDEs. You can even have the boundary/initial condition defined by ODEs. I think this would probably be a better approach than solving all of these separately

@acer 

One can use the option 'series' with the dsolve(...,numeric,..) command in order to obtain polynomial solutions. However such polynomial solutions require that all boundary conditions are given at a specific point - I think because the polynomial solutions are 'expansions of the 'actual' numerical solution about this point.

For reasonably well-behaved ODEs (such as the OP's), even quite low-order polynomials give more-or-less acceptable solutions.

See the attached

  restart;
  with(plots):
  de := sin(1)*(diff(y(x), x$2))+(1+cos(1)*x^2)*y(x) = -1;
  cond := y(-1) = 0, y(1) = 0:
#
# Solve the ODE numerically and plot the solution
#
  sol:=dsolve({de,cond}, numeric):
  p1:= odeplot(sol, [x, y(x)], x=-1..1);

sin(1)*(diff(diff(y(x), x), x))+(1+cos(1)*x^2)*y(x) = -1

 

 

 

 

#
# Generate a sequence of power series solutions.
# NB Maple will only do this if the BCs are given
# at the same point. Use the 'default' numerical
# solution above to produce boundary conditions at
# x=0, and then use these revised boundary
# conditions to compute power series solutions.
#
# Plot these power series solutions
#
  serSol:=NULL:
  for k from 3 by 1 to 10 do
      Order:=k;
      serSol:=serSol, evalf
                      ( rhs
                        ( convert
                          ( dsolve
                            ( { de,
                                y(0)=rhs(sol(0)[2]),
                                D(y)(0)=rhs(sol(0)[3])
                              },
                              y(x),
                              'series'
                            ),
                            polynom
                          )
                        )
                      );
  od:
#
# Show the computed power series solutions
# and their plots
#
  serSol;
  plot( [serSol], x=-1..1);

1.242608471+0.5654176858e-16*x-1.332552465*x^2, 1.242608471+0.5654176858e-16*x-1.332552465*x^2-0.1119899351e-16*x^3, 1.242608471+0.5654176858e-16*x-1.332552465*x^2-0.1119899351e-16*x^3+0.6547742536e-1*x^4, 1.242608471+0.5654176858e-16*x-1.332552465*x^2-0.1119899351e-16*x^3+0.6547742536e-1*x^4-0.1149811150e-17*x^5, 1.242608471+0.5654176858e-16*x-1.332552465*x^2-0.1119899351e-16*x^3+0.6547742536e-1*x^4-0.1149811150e-17*x^5+0.2592696820e-1*x^6, 1.242608471+0.5654176858e-16*x-1.332552465*x^2-0.1119899351e-16*x^3+0.6547742536e-1*x^4-0.1149811150e-17*x^5+0.2592696820e-1*x^6+0.2037433568e-18*x^7, 1.242608471+0.5654176858e-16*x-1.332552465*x^2-0.1119899351e-16*x^3+0.6547742536e-1*x^4-0.1149811150e-17*x^5+0.2592696820e-1*x^6+0.2037433568e-18*x^7-0.1300965241e-2*x^8, 1.242608471+0.5654176858e-16*x-1.332552465*x^2-0.1119899351e-16*x^3+0.6547742536e-1*x^4-0.1149811150e-17*x^5+0.2592696820e-1*x^6+0.2037433568e-18*x^7-0.1300965241e-2*x^8+0.6891078366e-20*x^9

 

 

 

Download odePow.mw

 

@vv 

I think you are answering the wrong question - which (maybe?) the OP isn't making clear.

Don't think about mathematically correct or incorrect - for the purposes of this post, such concepts are simply not relevant!

The important question is in the attached, why are the outputs different?

If both resulted in an 'Error' fine; if both gave equivalent (if incorrect?) answers fine - but the fundamental question is,  why does swapping the variable names around matter at all. Focus on this issue: see that attached (whhc contains relevant OS and Maple version data

kernelopts(version);
Physics:-Version();

`Maple 2018.1, X86 64 WINDOWS, Jun 8 2018, Build ID 1321769`

 

"C:\Users\TomLeslie\maple\toolbox\2018\Physics Updates\lib\Physics Updates.maple", `2018, July 4, 22:47 hours, version in the MapleCloud: 78, version installed in this computer: 75`

(1)

restart;

solve({x<>10, -infinity<x , x<infinity, -infinity<y , y<infinity},{x,y});

Error, (in solver) invalid input: SolveTools:-Inequality:-LinearUnivariateSystem expects its 1st argument, eqns, to be of type ({list, set})({`<`, `<=`, `=`}), but received {x <> -infinity, x < 10}

 

restart;

solve({y<>10, -infinity<y , y<infinity, -infinity<x , x<infinity},{y,x});

{10 < y, x < infinity, y < infinity, -infinity < x}, {y <> -infinity, x < infinity, y < 10, -infinity < x}

(2)

 

Download ineqProb.mw

I repeat: the second solve command is identical to the first, just with the variables 'x' and 'y' swapped around - so why does the first produce an Error, and the second an (incorrect?, but I don't care) answer?

Now you can try what I tried for diagnosis purposes, and I encourage you to do so, because I got precisely nowhere

  1. Something "special" about the names 'x' and 'y'?
  2. Something "special" about the ordering of the inequalities (even although they are in a set)?
  3. Something "special" about the ordering of the solve variables (even althugh they are in a set)?

@mehdibaghaee 

but not solve - dealing with code which cannot be read is tricky.

  1. Use of anames() before and after your read statements tells me that there is lot more going on in the supplied m-files than simple table or equation definition
  2. I suppose that the worksheets which created these m-files no longer exist? If they do, then post them. If we could read what is in the m-files, then your problem would (probably?) be simple to diagnose
  3. If I construct a "toy" example (see the attached), then the situation of having a table in one file, and an equation depending on table entries in another file, executes exactly as I would expect
  4. Conclusion - something in your second file which prevents 'full' evaluation, but since it is unreadable........

As a general rule, you should be careful about use of 'm-files'. This format may change between Maple releases. I think you can always(?) read from the previous Maple release, but reading from earlier versions may not be possible :-(

In order to run the attached 'toy' example, you will have to change the file paths to somethig appropriate for your machine


 

  restart;
#
# OP claims that one file is a table, so
# create a toy example, and save it in a 'm-file'
#
  t:=table([(2)=45,(4)=61]);
  save t, "C:/Users/TomLeslie/Desktop/myTable.m":

table( [( 2 ) = 45, ( 4 ) = 61 ] )

(1)

  restart;
#
# OP claims that second file contains an equation
# which utilises table values. Having restarted
# so that the following equation will not 'evaluate',
# define an equation which references the table entries
# and save it in an m-file
#
  anEq:=1.23*t[2]+4.56*t[4];
  save anEq, "C:/Users/TomLeslie/Desktop/myEq.m":

1.23*t[2]+4.56*t[4]

(2)

  restart;
#
# read the table and check it
#
  read "C:/Users/TomLeslie/Desktop/myTable.m":
  t();
#
# read the 'toy' equation and see if has 'executed'
# by checking the value
#
  read "C:/Users/TomLeslie/Desktop/myEq.m":
  anEq;

(table( [( 2 ) = 45, ( 4 ) = 61 ] ))()

 

333.51

(3)

 


 

Download readProb.mw

First 87 88 89 90 91 92 93 Last Page 89 of 207