PatrickT

Dr. Patrick T

2113 Reputation

18 Badges

15 years, 222 days

MaplePrimes Activity


These are replies submitted by PatrickT

@acer 


thanks acer, that's great.

In words, with the plot command you need the 'discont' option set to true, otherwise the discontinuity is ignored, even when the function is defined piecewise, e.g.

Statistics:-PDF(Statistics:-RandomVariable(Uniform(-1,1)),x);
/ 0 x < -1
|
| 1
< - x < 1
| 2
|
\ 0 otherwise

That's a little surprising. It's certainly not as "smart" as you would expect the newly designed "smart" plot to behave. Isn't there a case (rhetorical question) for arguing that, by design, the plot command should assume 'discont' to be true for piecewise-defined functions. And, if there are objections to this, surely there must be an overwhelming case for the DensityPlot command to assume 'discont' to be true for well-known cases like Uniform, if not for all piecewise-defined functions.

In addition to having to specifically remind the plot command about the existence of a discontinuity, you also need to increase the thickness of the plot lines (if you're using the default axes), otherwise the horizontal axis will overwrite it. With the boxed axes, by contrast, there is an offset that means the lines are visible. I didn't realize you could use the box option for that purpose (I only thought of it as an aesthetic choice, but in this instance it's clearly a practical choice as well).

So to get the density plot look roughly like what you would expect you need to use a combination of 'discont' and 'thickness' or 'discont' and 'box'.

And as you've shown, appropriately combining these can make the plot look just right.

I am discovering: 'discont' = [ 'symbolsize' = 15 , 'symbol' = circle]

This is a fantastic addition to my box of tricks!
 

A big thank you.

 

@acer 


thanks acer, that's great.

In words, with the plot command you need the 'discont' option set to true, otherwise the discontinuity is ignored, even when the function is defined piecewise, e.g.

Statistics:-PDF(Statistics:-RandomVariable(Uniform(-1,1)),x);
/ 0 x < -1
|
| 1
< - x < 1
| 2
|
\ 0 otherwise

That's a little surprising. It's certainly not as "smart" as you would expect the newly designed "smart" plot to behave. Isn't there a case (rhetorical question) for arguing that, by design, the plot command should assume 'discont' to be true for piecewise-defined functions. And, if there are objections to this, surely there must be an overwhelming case for the DensityPlot command to assume 'discont' to be true for well-known cases like Uniform, if not for all piecewise-defined functions.

In addition to having to specifically remind the plot command about the existence of a discontinuity, you also need to increase the thickness of the plot lines (if you're using the default axes), otherwise the horizontal axis will overwrite it. With the boxed axes, by contrast, there is an offset that means the lines are visible. I didn't realize you could use the box option for that purpose (I only thought of it as an aesthetic choice, but in this instance it's clearly a practical choice as well).

So to get the density plot look roughly like what you would expect you need to use a combination of 'discont' and 'thickness' or 'discont' and 'box'.

And as you've shown, appropriately combining these can make the plot look just right.

I am discovering: 'discont' = [ 'symbolsize' = 15 , 'symbol' = circle]

This is a fantastic addition to my box of tricks!
 

A big thank you.

 

 

@J4James 

I get the same problem (Maple 16.01,  Standard GUI, Windows7x64).

It seems that the problem originates in the option 'approxsoln'. I haven't used that option before, so I have no experience to share about your problem. To me it looks like a bug. Reading the help files, it clearly states that 'approxsoln' can be set equal to a previous output of dsolve, with the output of the previous output specified as a Matrix (with a capital M) or as listprocedure or procedurelist or operator output. 

EDIT: whether it's a bug or an improper use of the dsolve options, the help page referenced below could be improved: it would be useful to have examples of how to use 'approxsoln' and an explanation of the pros and cons of using 'output'=array versus procedure, listprocedure, etc.. (efficiency, flexibility, whatever)

What Maple complains about is that the 'approxsoln' is not of the required type, namely float[8]. But that seems strange. I looked at it and the data doesn't seem to contain "forbidden" cells like 'error' or 'HFloat()' or whatever, just floats. I ran a whattype question on randomly selected cells of the Array. The only part of the Array that is not float[8] is the first column-headings that define the variables. I tried to apply evalf. I tested that specifying Array instead of array in the 'output' call (you have written "array" with a small a, which is the way the help files suggest it should be written, but then the help files do mention Matrix as the object). It didn't help. 

I haven't tried every possible combination of these, but for instance, this did not help:

d2:=subs(x=0.1,Q=2,G=1,Nt=0.5,Nb = 0.5,M = 1,Gc = 0.2,Pr=0.7,a=0.1,Gt=0.3,[evalf(dee1)]):
de2 := dsolve(d2, 'numeric', 'method' = bvp[midrich], 'output' = Array(evalf([seq(0.1e-1*i, i = 0 .. 100)]),'datatype'=float[8]));
de1 := dsolve(d1, 'numeric', 'method'=bvp[midrich], 'abserr'=0.005, 'approxsoln'=evalf(de2));

 
Error, (in dsolve/numeric/BVPSolve) unable to store 'HFloat(1.005717340914193)*y' when datatype=float[8]

So it would be very helpful here if someone more knowledgeable could step in! Thanks in advance.

my reference:
http://www.maplesoft.com/support/help/Maple/view.aspx?path=dsolve/numeric/BVP

 

 

 

@J4James 

I get the same problem (Maple 16.01,  Standard GUI, Windows7x64).

It seems that the problem originates in the option 'approxsoln'. I haven't used that option before, so I have no experience to share about your problem. To me it looks like a bug. Reading the help files, it clearly states that 'approxsoln' can be set equal to a previous output of dsolve, with the output of the previous output specified as a Matrix (with a capital M) or as listprocedure or procedurelist or operator output. 

EDIT: whether it's a bug or an improper use of the dsolve options, the help page referenced below could be improved: it would be useful to have examples of how to use 'approxsoln' and an explanation of the pros and cons of using 'output'=array versus procedure, listprocedure, etc.. (efficiency, flexibility, whatever)

What Maple complains about is that the 'approxsoln' is not of the required type, namely float[8]. But that seems strange. I looked at it and the data doesn't seem to contain "forbidden" cells like 'error' or 'HFloat()' or whatever, just floats. I ran a whattype question on randomly selected cells of the Array. The only part of the Array that is not float[8] is the first column-headings that define the variables. I tried to apply evalf. I tested that specifying Array instead of array in the 'output' call (you have written "array" with a small a, which is the way the help files suggest it should be written, but then the help files do mention Matrix as the object). It didn't help. 

I haven't tried every possible combination of these, but for instance, this did not help:

d2:=subs(x=0.1,Q=2,G=1,Nt=0.5,Nb = 0.5,M = 1,Gc = 0.2,Pr=0.7,a=0.1,Gt=0.3,[evalf(dee1)]):
de2 := dsolve(d2, 'numeric', 'method' = bvp[midrich], 'output' = Array(evalf([seq(0.1e-1*i, i = 0 .. 100)]),'datatype'=float[8]));
de1 := dsolve(d1, 'numeric', 'method'=bvp[midrich], 'abserr'=0.005, 'approxsoln'=evalf(de2));

 
Error, (in dsolve/numeric/BVPSolve) unable to store 'HFloat(1.005717340914193)*y' when datatype=float[8]

So it would be very helpful here if someone more knowledgeable could step in! Thanks in advance.

my reference:
http://www.maplesoft.com/support/help/Maple/view.aspx?path=dsolve/numeric/BVP

 

 

Since we're on the topic of distributions, I'll append another question here. The following definition of the lognormal distribution defines the pdf on [0,infinity), including 0: is that to be expected? 

I'm not sure what the convention is, but instinct (that strange thing not to be trusted) would suggest excluding 0 from the domain of definition, i.e. (0,infinity). 

Otherwise, the logarithm of 0 is to be taken to be complex, is that what is intended?

PDFLogNormal := Statistics:-PDF(Statistics:-RandomVariable(LogNormal(m,s)),x);

PDFLogNormal := / 0 x < 0
|
| / 2\
| (1/2) | (ln(x) - m) |
| 2 exp|- ------------|
< | 2 |
| \ 2 s /
| -------------------------- otherwise
| (1/2)
| 2 x s Pi
\

 

Basically, I was expecting:

 PDFLogNormal := / 0 x <= 0 
|
| / 2\
| (1/2) | (ln(x) - m) |
| 2 exp|- ------------|
< | 2 |
| \ 2 s /
| -------------------------- otherwise
| (1/2)
| 2 x s Pi
 \  

(Note the equality in x <= 0) 

you're right, 'complex' is not an option when dsolve takes a bvp as input, I hadn't noticed that. Can you convert your system to an ivp? if you have a known endpoint, you could start from there and run time backwards (i.e. t=-10..0). Have you tried variations on your problem? i.e. different parameter values. Do you have problems for this specific formulation or more generically?

you're right, 'complex' is not an option when dsolve takes a bvp as input, I hadn't noticed that. Can you convert your system to an ivp? if you have a known endpoint, you could start from there and run time backwards (i.e. t=-10..0). Have you tried variations on your problem? i.e. different parameter values. Do you have problems for this specific formulation or more generically?

@J4James 

haven't read your question in detail, still if your imaginary numbers are spurious, you could try to set the option 'complex"=false in dsolve or you could use Re(x(t)) to trim the imaginary bits out. The former is presumably a better approach.

http://www.maplesoft.com/support/help/Maple/view.aspx?path=Re

 

@J4James 

haven't read your question in detail, still if your imaginary numbers are spurious, you could try to set the option 'complex"=false in dsolve or you could use Re(x(t)) to trim the imaginary bits out. The former is presumably a better approach.

http://www.maplesoft.com/support/help/Maple/view.aspx?path=Re

 

Yes, you can save the worksheet with the output as a pdf, that way you can view the executed results and the plots. You can do that with "export as" or you can "print" if you have a pdf renderer, e.g. PDFCreator, PDFredirect, PDFlite (the one I use these days), cutePDF, and many others.

If you're interested in keeping only the input commands, save them as mpl, which will give you a text file you can read anywhere, e.g. with notepad++, which is a very popular choice and my favourite. With this approach you can edit the file.

But unless you have a working version of Maple, you won't be able to execute the commands.

Maple does not have the equivalent of Mathematica's viewer (the other day my coauthor sent me a Mathematica file, I tried to read it in the free viewer but couldn't, so that doesn't work great either).

@bernie 

I just sent you a private message, with mapleprimes, so you have my email. I can email you the files I've run.

I have successfully run the code you gave above on 2 different laptops: both on Windows 7 (I am the administrator), Maple 16 x32, with watcom1.3 compiler: are you on something else? 

@bernie 

I just sent you a private message, with mapleprimes, so you have my email. I can email you the files I've run.

I have successfully run the code you gave above on 2 different laptops: both on Windows 7 (I am the administrator), Maple 16 x32, with watcom1.3 compiler: are you on something else? 

mcseq := [0.280946675515709e-1, 0.281134924114755e-1, 0.281319305400785e-1, 0.281499853636882e-1, 0.281676654057859e-1, 0.281849723789141e-1, 0.282019089226987e-1, 0.282184813267839e-1, 0.282346934844568e-1, 0.282505496691009e-1, 0.282660432922057e-1, 0.282811934543223e-1, 0.282959947348064e-1, 0.283104561426562e-1, 0.283245742344417e-1, 0.283383482238212e-1, 0.283518046969793e-1, 0.283649239173817e-1, 0.283777132811362e-1, 0.283901834677775e-1, 0.284023378090057e-1, 0.284141721540885e-1, 0.284256934197022e-1, 0.284369047824176e-1, 0.284478093891781e-1, 0.284584103465638e-1, 0.284687071387944e-1, 0.284787136293512e-1, 0.284884220010391e-1, 0.284978353579793e-1, 0.337797046852194e-1, 0.338064411563618e-1, 0.338325004387734e-1, 0.338578904788269e-1, 0.338826207344268e-1, 0.285483804058122e-1, 0.285558372156399e-1, 0.285630251655843e-1, 0.285699469762968e-1, 0.285766053183732e-1, 0.285830028130297e-1, 0.285891349828242e-1, 0.285950187390988e-1, 0.286006562656826e-1, 0.286060362644044e-1, 0.286111682130616e-1, 0.286160525994484e-1, 0.286206959713074e-1, 0.286251004455787e-1, 0.286292647429611e-1, 0.286331874878307e-1, 0.286368816749273e-1, 0.286403445053406e-1, 0.286435783959056e-1, 0.286465893188247e-1, 0.286493643878252e-1, 0.286519285980838e-1, 0.286542698184795e-1, 0.286563927389960e-1, 0.286583084793172e-1, 0.286599995418335e-1, 0.286614763123951e-1, 0.286627495140143e-1, 0.286638155084207e-1, 0.286646763753708e-1, 0.286653341503061e-1, 0.286657908114193e-1, 0.286660483864144e-1, 0.286661088203722e-1, 0.286659740692921e-1, 0.286656460741854e-1, 0.286651332794726e-1, 0.286644245593305e-1, 0.286635282538466e-1, 0.286624462360861e-1, 0.286611736018804e-1, 0.286597255962766e-1, 0.286580973176767e-1, 0.286562905527233e-1, 0.286543070642854e-1, 0.286521486055637e-1, 0.286498314882801e-1, 0.286473284067397e-1, 0.286446554799178e-1, 0.286417993146377e-1, 0.286387984253253e-1, 0.286356189453957e-1, 0.286322831147480e-1, 0.286287856509083e-1, 0.286251281727583e-1, 0.286213122664838e-1, 0.286173394718637e-1, 0.286132113663337e-1, 0.286089294537504e-1, 0.286044952906261e-1, 0.285999165657919e-1, 0.285951822538811e-1, 0.285903001205233e-1, 0.285852658385038e-1, 0.285800926312905e-1, 0.285747759744243e-1]

 

I can't reproduce your problem.  Could this be a memory problem? Or a file permission problem? I have no idea, sorry. 

mcseq := [0.280946675515709e-1, 0.281134924114755e-1, 0.281319305400785e-1, 0.281499853636882e-1, 0.281676654057859e-1, 0.281849723789141e-1, 0.282019089226987e-1, 0.282184813267839e-1, 0.282346934844568e-1, 0.282505496691009e-1, 0.282660432922057e-1, 0.282811934543223e-1, 0.282959947348064e-1, 0.283104561426562e-1, 0.283245742344417e-1, 0.283383482238212e-1, 0.283518046969793e-1, 0.283649239173817e-1, 0.283777132811362e-1, 0.283901834677775e-1, 0.284023378090057e-1, 0.284141721540885e-1, 0.284256934197022e-1, 0.284369047824176e-1, 0.284478093891781e-1, 0.284584103465638e-1, 0.284687071387944e-1, 0.284787136293512e-1, 0.284884220010391e-1, 0.284978353579793e-1, 0.337797046852194e-1, 0.338064411563618e-1, 0.338325004387734e-1, 0.338578904788269e-1, 0.338826207344268e-1, 0.285483804058122e-1, 0.285558372156399e-1, 0.285630251655843e-1, 0.285699469762968e-1, 0.285766053183732e-1, 0.285830028130297e-1, 0.285891349828242e-1, 0.285950187390988e-1, 0.286006562656826e-1, 0.286060362644044e-1, 0.286111682130616e-1, 0.286160525994484e-1, 0.286206959713074e-1, 0.286251004455787e-1, 0.286292647429611e-1, 0.286331874878307e-1, 0.286368816749273e-1, 0.286403445053406e-1, 0.286435783959056e-1, 0.286465893188247e-1, 0.286493643878252e-1, 0.286519285980838e-1, 0.286542698184795e-1, 0.286563927389960e-1, 0.286583084793172e-1, 0.286599995418335e-1, 0.286614763123951e-1, 0.286627495140143e-1, 0.286638155084207e-1, 0.286646763753708e-1, 0.286653341503061e-1, 0.286657908114193e-1, 0.286660483864144e-1, 0.286661088203722e-1, 0.286659740692921e-1, 0.286656460741854e-1, 0.286651332794726e-1, 0.286644245593305e-1, 0.286635282538466e-1, 0.286624462360861e-1, 0.286611736018804e-1, 0.286597255962766e-1, 0.286580973176767e-1, 0.286562905527233e-1, 0.286543070642854e-1, 0.286521486055637e-1, 0.286498314882801e-1, 0.286473284067397e-1, 0.286446554799178e-1, 0.286417993146377e-1, 0.286387984253253e-1, 0.286356189453957e-1, 0.286322831147480e-1, 0.286287856509083e-1, 0.286251281727583e-1, 0.286213122664838e-1, 0.286173394718637e-1, 0.286132113663337e-1, 0.286089294537504e-1, 0.286044952906261e-1, 0.285999165657919e-1, 0.285951822538811e-1, 0.285903001205233e-1, 0.285852658385038e-1, 0.285800926312905e-1, 0.285747759744243e-1]

 

I can't reproduce your problem.  Could this be a memory problem? Or a file permission problem? I have no idea, sorry. 

@bernie 

Hard to say, can you post a minimal example? (copy paste the commands and the input.txt)

First 10 11 12 13 14 15 16 Last Page 12 of 93