PatrickT

Dr. Patrick T

2108 Reputation

18 Badges

16 years, 302 days

MaplePrimes Activity


These are replies submitted by PatrickT

Another reason:

In my experience the list of "unanswered" questions is not very helpful because the questions are often actually answered within comments.

I mean the list here: http://www.mapleprimes.com/questions/unanswered

@Joe Riel 

Thanks Joe, that's great. I will make this into a procedure.

I didn't think it would be so contrived to get the data out, given that it's already been computed. I thought the solution would involve properly querying the procedure. So now I'm not so embarrassed to report my earlier attempts.

My first attempt was to create a list of times selected at fixed intervals using seq and then removing repetitions. It can be made to work here, but it may not work so well in cases where the event is triggered in rapid succession.


Sol :=
  dsolve( [ diff(y(t),t) = -y(t), y(0) = 1, p(0) = 1, s(0) = 0 ]
    , 'type' = numeric
    , 'discrete_variables' = [ p(t), s(t) ]
    , 'events' = [ [ y(t) = 10^(-p(t)), [ p(t) = p(t)+1, s(t) = t ] ] ]
    , 'output' = listprocedure
  ) ;
tSol := subs(Sol, s(t));
tList0 := [ seq( tSol(t), t = 0..25, 0.1) ]:
tList := ListTools:-MakeUnique(tList0)[2..-1];



My second attempt involved using plottools:-getdata. As it turns out, I had even bigger problems getting it to work. As in my earlier attempt, I also had to remove multiple entries. But for some reason, the list I get differs. Some roundoff error or something like that interfering perhaps.

tSol := subs(Sol, s(t)):
tSolPlot := plot(tSol, 0..25):
tSolData := plottools:-getdata(tSolPlot);
tList0 := convert(tSolData[3][1..-1,2..2], list):
tList := ListTools:-MakeUnique(tList0)[2..-1];

In a word, thanks a lot Joe, thanks a lot Erik for saving my (Maple) life!

@Joe Riel 

Thanks Joe, that's great. I will make this into a procedure.

I didn't think it would be so contrived to get the data out, given that it's already been computed. I thought the solution would involve properly querying the procedure. So now I'm not so embarrassed to report my earlier attempts.

My first attempt was to create a list of times selected at fixed intervals using seq and then removing repetitions. It can be made to work here, but it may not work so well in cases where the event is triggered in rapid succession.


Sol :=
  dsolve( [ diff(y(t),t) = -y(t), y(0) = 1, p(0) = 1, s(0) = 0 ]
    , 'type' = numeric
    , 'discrete_variables' = [ p(t), s(t) ]
    , 'events' = [ [ y(t) = 10^(-p(t)), [ p(t) = p(t)+1, s(t) = t ] ] ]
    , 'output' = listprocedure
  ) ;
tSol := subs(Sol, s(t));
tList0 := [ seq( tSol(t), t = 0..25, 0.1) ]:
tList := ListTools:-MakeUnique(tList0)[2..-1];



My second attempt involved using plottools:-getdata. As it turns out, I had even bigger problems getting it to work. As in my earlier attempt, I also had to remove multiple entries. But for some reason, the list I get differs. Some roundoff error or something like that interfering perhaps.

tSol := subs(Sol, s(t)):
tSolPlot := plot(tSol, 0..25):
tSolData := plottools:-getdata(tSolPlot);
tList0 := convert(tSolData[3][1..-1,2..2], list):
tList := ListTools:-MakeUnique(tList0)[2..-1];

In a word, thanks a lot Joe, thanks a lot Erik for saving my (Maple) life!

@Joe Riel 

Thanks for the explanation. I had noticed this NULL in some other posts of yours. Actually I try to indent the way you do, having learned from previous posts of yours on mapleprimes, as it is indeed very convenient this way to comment lines out.

I've been thinking about using an external editor too, so I'll give emacs a try (as I have it already set up).

I remember Alejandro discussed external editors a few months / years back, and I don't think it was emacs, but I can't seem to retrieve that discussion on mapleprimes. So if you're reading this Alejandro, would you remind me of the name of the editor(s) you would recommend/suggest. Thanks.

@Joe Riel 

Thanks for the explanation. I had noticed this NULL in some other posts of yours. Actually I try to indent the way you do, having learned from previous posts of yours on mapleprimes, as it is indeed very convenient this way to comment lines out.

I've been thinking about using an external editor too, so I'll give emacs a try (as I have it already set up).

I remember Alejandro discussed external editors a few months / years back, and I don't think it was emacs, but I can't seem to retrieve that discussion on mapleprimes. So if you're reading this Alejandro, would you remind me of the name of the editor(s) you would recommend/suggest. Thanks.

Oh and I also wanted to ask,

what is the purpose of having NULL in the definition of the ODE system?

thanks.

Oh and I also wanted to ask,

what is the purpose of having NULL in the definition of the ODE system?

thanks.

Thanks Joe, Thanks Erik,

your suggestion Joe has helped me a great deal in understanding how to use discrete variables. I was getting ready to post a follow-up question just as Erik posted his suggestion. Seeing Erik's suggestion I'm pleased to see that I was on the right track. But I got stuck at the point of trying to make a list of the dates. And having spent an hour (at least) on this without success, I turn to you again for advice.

I had adapted Joe's code like this:

Sol :=
  dsolve( [ diff(y(t),t) = -y(t), y(0) = 1, p(0) = 1, s(0) = 0 ]
    , 'type' = numeric
    , 'discrete_variables' = [ p(t), s(t) ]
    , 'events' = [ [ y(t) = 10^(-p(t)), [ p(t) = p(t)+1, s(t) = t ] ] ]
    , 'output' = listprocedure
  ) ;

in order to extract time like this:

tSol := subs(Sol, s(t));
plot(tSol, 0..10);

I didn't use odeplot because I'm primarily interested in extracting the data in a list. Using listprocedure is the method that I'm aware of.

It's also very helpful to see Erik's different way of setting up the p(t). 

But here I got stuck. The values of time I want to extract are in the procedure named tSol. I tried strange things like trying to solve tSol=t, but didn't manage to get it to work. I would like to have a list of the dates at which p(t) changes.

thanks a lot,

Patrick.

Thanks Joe, Thanks Erik,

your suggestion Joe has helped me a great deal in understanding how to use discrete variables. I was getting ready to post a follow-up question just as Erik posted his suggestion. Seeing Erik's suggestion I'm pleased to see that I was on the right track. But I got stuck at the point of trying to make a list of the dates. And having spent an hour (at least) on this without success, I turn to you again for advice.

I had adapted Joe's code like this:

Sol :=
  dsolve( [ diff(y(t),t) = -y(t), y(0) = 1, p(0) = 1, s(0) = 0 ]
    , 'type' = numeric
    , 'discrete_variables' = [ p(t), s(t) ]
    , 'events' = [ [ y(t) = 10^(-p(t)), [ p(t) = p(t)+1, s(t) = t ] ] ]
    , 'output' = listprocedure
  ) ;

in order to extract time like this:

tSol := subs(Sol, s(t));
plot(tSol, 0..10);

I didn't use odeplot because I'm primarily interested in extracting the data in a list. Using listprocedure is the method that I'm aware of.

It's also very helpful to see Erik's different way of setting up the p(t). 

But here I got stuck. The values of time I want to extract are in the procedure named tSol. I tried strange things like trying to solve tSol=t, but didn't manage to get it to work. I would like to have a list of the dates at which p(t) changes.

thanks a lot,

Patrick.

Can your code be adapted to create slices with other kinds of plot, such as DEplot3d ?

for instance,

DEtools[DEplot3d]( {diff(x(t), t) = y(t), diff(y(t), t) = -sin(x(t))}, [x(t), y(t)], t = 0 .. 10, [[x(0) = 0, y(0) = .5], [x(0) = 0, y(0) = 1], [x(0) = 0, y(0) = 1.8], [x(0) = -2*Pi, y(0) = 1], [x(0) = 2*Pi, y(0) = .5], [x(0) = -2*Pi, y(0) = 2.1], [x(0) = 2*Pi, y(0) = -2.1]], stepsize = .2, linecolor = sin(t)-t);

excellent!

reminds me of the printer of the future, the 3D printer:

http://en.wikipedia.org/wiki/3D_printing

@Alejandro Jakubi 

I second your suggestion Alejandro, that indeed would be a great thing to have, bridging the gap between 1D and 2D.

@Alejandro Jakubi 

I second your suggestion Alejandro, that indeed would be a great thing to have, bridging the gap between 1D and 2D.

First 39 40 41 42 43 44 45 Last Page 41 of 93