tomleslie

13876 Reputation

20 Badges

15 years, 182 days

MaplePrimes Activity


These are replies submitted by tomleslie

  1. If the second system requires r(x) over a reasonable range of values for 'x', then it will never work - because the first system cannot calculate the required values for r(x).
  2. If the first system can be made to work, then it might be possible to get an answer for the second system also

Not saying you're wrong but:

  1. pdf isn't technically a "graphics" format. It is a "document" format. Note that PDF is not one of the supported formats on the plottools:-exportplot(). Trying to use this command to create a pdf results in a "format not supported" error
  2. Because pdf is a "document" format, it has to contain information which you would expect in other "document" formats, eg MSWord - so options such as PaperSize, Margins, etc are pretty much mandatory. A pdf file without a defined PaperSize, Margins etc wouldn't make much sense
  3. Now we don't seem to have any control over the settings used for creating a pdf. So the thing which irritates me, is that however I create a pdf file, it always comes out as US letter size (ie 8.5'' x 11''). I'm in the UK, and US letter size just isn't a thing. I have everything in Maple set up for A4 (210mm x 297) - but when I create a pdf, I get 8.5'' x 11'' -Grrrrrr :-(
  1. Select everything in your worksheet
  2. Convert everything to 1D input
  3. Read the 1D input and fix the obvious rubbish which is "invisible" when using 2D input
  4. Run the 1D input to confirm that there are no Errors - NB no solution is found, which does not surprise me, but at least no Errors are generated
  5. Select all the (now correct) code and convert iit back to 2D-input
  6. Rerun the code, which now executes with no errors - although still no solution is found

You have to ask yourself two serious questions

  1. If I can fix the "error" in your code in less than10secs, just by reading the 1D input code - how long does it take you to fix this "error" by reading your own 2D-input code?
  2. If you can't fix your 2D input code in less than 10 secs - why are you using code which you can't debug?

So check out my 2D code below

Download twoDCodeFix.mw

 

Attachement got lost somehow, I meant to inculde the following


 

  restart;
#
# The solution process for Laplace's equation
#
# Define the equation - let's just skip the boundary
# conditions for now
#
  pde := (diff(u(x, y), x, x))+diff(u(x, y), y, y) = 0;
#
# Assume that there is a solution of the form u(x(y)=X(x)*Y(y)
# and make the relevant substitution
#
  pde:=eval(subs( u(x,y)=X(x)*Y(y), pde));
#
# Do a basic manipulation of this equation to get it into
# an "interesting" form
#
  pde:=op([1,1],pde)/(Y(y)*X(x))=-op([1,2],pde)/(Y(y)*X(x));
 

diff(diff(u(x, y), x), x)+diff(diff(u(x, y), y), y) = 0

 

(diff(diff(X(x), x), x))*Y(y)+X(x)*(diff(diff(Y(y), y), y)) = 0

 

(diff(diff(X(x), x), x))/X(x) = -(diff(diff(Y(y), y), y))/Y(y)

(1)

#
# Note that the left hand side of this equation depends
# only on 'x', and the right hand side depends only on 'y',
# yet x and y are completely independent! How can this
# be true. Well the conventional assumption is that this
# can only happen if both sides of this expression are
# equal to the same CONSTANT - which I'll call lambda, so
# I can now generate two equations from the above, setting
# each equal to this "new" constant lambda
#
  pdeSys:=[rhs(pde)=lambda, lhs(pde)=lambda];
#
# These two ODEs can be solved separately using a map()
# command, as in
#
  map(dsolve, pdeSys);
#
# Now have separate solutions for X(x) and Y(y), but the
# desired expression is u(x,y)=X(x)*Y(y), so just form
# this product
#
  sol:=u(x,y)=rhs(%[1])*rhs(%[2]);

[-(diff(diff(Y(y), y), y))/Y(y) = lambda, (diff(diff(X(x), x), x))/X(x) = lambda]

 

[Y(y) = _C1*sin(lambda^(1/2)*y)+_C2*cos(lambda^(1/2)*y), X(x) = _C1*exp(lambda^(1/2)*x)+_C2*exp(-lambda^(1/2)*x)]

 

u(x, y) = (_C1*sin(lambda^(1/2)*y)+_C2*cos(lambda^(1/2)*y))*(_C1*exp(lambda^(1/2)*x)+_C2*exp(-lambda^(1/2)*x))

(2)

#
# Now let's consider the boundary condition u(0,y)=0
# by evaluating the above at x=0
#
  eval(sol, x=0);
#
# This has to be 0, for arbitrary values of the variable
# 'y', and a moments though should convince you that this
# can only be guaranteed if _C1 = -_C2, so make the relevant
# substitution in the solution
#
  sol:=subs(_C2=-_C1, sol);

u(0, y) = (_C1*sin(lambda^(1/2)*y)+_C2*cos(lambda^(1/2)*y))*(_C1+_C2)

 

u(x, y) = (_C1*sin(lambda^(1/2)*y)-_C1*cos(lambda^(1/2)*y))*(_C1*exp(lambda^(1/2)*x)-_C1*exp(-lambda^(1/2)*x))

(3)

#
# Now start introducing the boundary conditions - very carefully!!
#


 

Download lapEq.mw

with the solution I presented in eventsProb.mw I can probably fix it.

As you can see from the graphs in the worksheet eventsProb.mw, the first event is triggered at approximately t=2.6, because x(t)=0, and v(t)<0. Now at this point, your original specification required the 'action' [ x(t)=0, v(t)=0 ]. The first of these actions is redundant because the event is triggered by x(t)=0. Absolutely no benefit in defining an 'action' which sets up one of the 'triggers' which caused the 'action' in the first place.

The way I defined this event, and as the graphs in eventsProb.mw show, v(t) is forced to zero at this time: x(t) does not have to be changed, because the trigger has already required that it be x(t)=0

You now appear to be claiming that for the trigger [x(t)=0, v(t)<0] you do not want the action [ x(t)=0, v(t)=0 ], so what 'action' do you want for this 'trigger' If you can tell me, I can arrange it

I have rewritten the events description again based on your explanation of what you are trying to achieve

The attached works for both values of CMAX

eventsProb.mw

I still think my original diagnosis of incorrect events specification was accurate

Maple 2017.3, User Interface: 1262472, Kernel: 1262472, Library: 1262472, Typesetting level = Maple Standard

Maple 2016.2, User Interface: 1194701, Kernel: 1194701, Library: 1194701, Typesetting level = Maple Standard

 

 

Your code is *spaghetti*. Expanding/extending it for other than the hard-wired case you supply is not something I want to get into!

Having said that, I have added (yet another) execution group which includes your (more or less randomly defined) entries in the 'u', 'v', 'w' matrices/arrays and includes these in the final plots.

Becuase you have chosen to use zero-based indexing, and matrixplot() requires 'matrix' arguments, whic have one-based indexing, the x-tickmarks and y-tickmarks in the final plots are off by 1 - ie they are 1..6 rather than 0..5. Deal with it! or rewrite your code to use one-based indexing.

matPlots2.mw

 

plot3d() does not have the option 'size=[]' for determining the size of the plot 'window' - although plot() does. So to change the size of a 3D-plot, just select the plot (ie left-click) and use the 'handles'

Just realised that your question asked for 3-D plots - although the code you supplied will only ever generate 2-D plots. So now I'm not sure exactly what you want, 2-D or 3-D

Anyhow the attached is a minor variation on the worksheet I posted previously, but this time with 3-D plots. Note that the "legend" option is not available for 3-D plots - I have no idea why. If you think some kind of legend is really necessary, then I could probably(?) spoof this somehow

pdeSol2.mw

OP asked for the "square root of the inverse". You have supplied the "inverse of the square root". Not exactly the same and certainly not difficult to fix. But if I have to pedantic, there is a difference between

restart;
M := < a,b;c,d>;
(x->1/sqrt(x))~(M);

and

restart;
M := < a,b;c,d>;
(x->sqrt(1/x))~(M);

 

If you use the  big green up-arrow in the Mapleprimes toolbar to post two files

  1. a Maple worksheet, showing the expression which you are plotting
  2. a Matlab m-file, showing the expression which you are plotting

someone here might be able to help.

On the other hand if you continue to post expressions which are syntactically incorrect in both Maple and Matlab, the chances of anyone here being able to help are pretty small

 

Your original system comprised four equations in four unknowns.

No solution could be found for this system

You have two options

  1. No solution for this system exists
  2. A solution exists, but no known algorithm can find it

Staet clearly which of (1), (2) above you believe to be true - and why

fsolve() and DirectSearch:-SolveEquations() have already tried "iterative" methods, and have come up with no solution. The most likely reason is that no solution exists. At least two possible reasons for this

  1. There is a  typo somewhere in the orignal definition of the equations
  2. When I hacked your code to make it run, I made an error somewhere

I ended up with four (quadratic) equations in four unknowns. What makes you think that a solution has to exist?

Just replace my original with

  restart;
  with(LinearAlgebra):
  with(ExcelTools):
  nRows:=11:
  nCols:=6:
  Cind:= Vector[row]( [ seq
                                       ( j,
                                         j=1..nCols
                                       )
                                    ]
                                  ):
  Rind:= Vector[column]( [ seq
                                             ( j,
                                               j=1..nRows
                                             )
                                          ]
                                       ):
  startInd:= 1:
  for i from 1 by 1 to 4 do
       A:= RandomMatrix(nRows,nCols);
       Export( Cind,
                     "C:/Users/TomLeslie/Desktop/exData.xlsx",
                     "worksheet1",
                      cat("B", startInd)
                  ):
       Export( Rind,
                     "C:/Users/TomLeslie/Desktop/exData.xlsx",
                     "worksheet1",
                     cat("A", startInd+1)
                   ):
       Export( A,
                     "C:/Users/TomLeslie/Desktop/exData.xlsx",
                     "worksheet1",
                      cat("B", startInd+1)
                   ):
       startInd:=startInd+nRows+2:
od:

 

First 108 109 110 111 112 113 114 Last Page 110 of 207