acer

32373 Reputation

29 Badges

19 years, 334 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@student302 Could you upload your actual (full) worksheet that contains this error, into a new Comment in this thread, and mention which Maple version and operating system?

In case this topic is of general interest: Dr. Robert Lopez has written Classroom Tips and Techniques: "Events" and the Numeric Solution of ODEs, which is on the Application Center.

acer

In case this topic is of general interest: Dr. Robert Lopez has written Classroom Tips and Techniques: "Events" and the Numeric Solution of ODEs, which is on the Application Center.

acer

The numeric results computed above seem to agree with the following results from symbolic dsolve.

exact0.mw

acer

The numeric results computed above seem to agree with the following results from symbolic dsolve.

exact0.mw

acer

Apart from reducing Digits (ie. keeping it at the default, 10) there may be another easy way to speed up some of this kind of calculation.

The idea is simple, if the parameter(s) hasn't changed very much -- from the previous iteration to the current one -- then the numerical solver might sometimes be able to converge to a new root quite quickly using the previous iteration's root as the new starting guess.

Usually, fsolve will try and pepper the multivariable solution space with random starting points, and we hope that one will converge. (This is also why it takes long to fail completely, by the way.)

So an ajustment to the methodology could be like this: first try the previous iteration's root as the new starting point. If that fails to converge then call fsolve without specifying a starting point, and let it proceed as usual.

At Digits=10 the old methodology takes 40 seconds to get all those 45 discovered roots for `n1` between -3.99 and 7.01. domain_try1.mw

Using the above methodology it takes about 3 seconds.  domain_try2.mw

Computations run in 64bit Maple 16.01 on Windows 7.

acer

Apart from reducing Digits (ie. keeping it at the default, 10) there may be another easy way to speed up some of this kind of calculation.

The idea is simple, if the parameter(s) hasn't changed very much -- from the previous iteration to the current one -- then the numerical solver might sometimes be able to converge to a new root quite quickly using the previous iteration's root as the new starting guess.

Usually, fsolve will try and pepper the multivariable solution space with random starting points, and we hope that one will converge. (This is also why it takes long to fail completely, by the way.)

So an ajustment to the methodology could be like this: first try the previous iteration's root as the new starting point. If that fails to converge then call fsolve without specifying a starting point, and let it proceed as usual.

At Digits=10 the old methodology takes 40 seconds to get all those 45 discovered roots for `n1` between -3.99 and 7.01. domain_try1.mw

Using the above methodology it takes about 3 seconds.  domain_try2.mw

Computations run in 64bit Maple 16.01 on Windows 7.

acer

@jschulzb Can we suppose that your newer question is your focus for this issue now, and that this earlier thread is not so pressing?

By the way, you can use the "branch" item and the botton of a post/question/answer is you would like to ask some new related question and have mapleprimes automatically put cross-referencing links on both of old and new.

The combination of dsolve events and parameters is very powerful. That, along with a good numeric DAE solver, makes the cornerstone of MapleSim, IMO. But the documentation and examples for events/parameters in Maple are a little thin relative to its power and usefulness.

PatrickT has asked some questions here about `events` and `parameters` in the dsolve numeric solver, which might help shed some light.

Without seeing you full code, I might hazard a guess that you are going for some implicitplot, and just need a little help figuring out the beast that could be plotted (since it will be a procedure that sets the parameters according to the arguments, and then runs until events hit/miss, and then returns some indicative scalar... or something like that).

@jschulzb Can we suppose that your newer question is your focus for this issue now, and that this earlier thread is not so pressing?

By the way, you can use the "branch" item and the botton of a post/question/answer is you would like to ask some new related question and have mapleprimes automatically put cross-referencing links on both of old and new.

The combination of dsolve events and parameters is very powerful. That, along with a good numeric DAE solver, makes the cornerstone of MapleSim, IMO. But the documentation and examples for events/parameters in Maple are a little thin relative to its power and usefulness.

PatrickT has asked some questions here about `events` and `parameters` in the dsolve numeric solver, which might help shed some light.

Without seeing you full code, I might hazard a guess that you are going for some implicitplot, and just need a little help figuring out the beast that could be plotted (since it will be a procedure that sets the parameters according to the arguments, and then runs until events hit/miss, and then returns some indicative scalar... or something like that).

Could you upload the whole working code that you have so far, including the DEs. It makes it so much easier to assist meaningfully and avoid wasting time on the wrong goals.

acer

@jschulzb Yes, it is easy to adjust it to discover points that attain some other value. Simply create a new procedure whose result is adjusted by the target value -- thus becoming a root-finding (zero-finding exercise).

If you are trying to discover where a solution from dsolve/numeric attains some specific value then the fastest way might be to properly use dsolve,events (which were implemented for just this kind of thing). Done right, that should be able to outperform rootfinding "after the fact" via fsolve or whatever else, both in terms of accuracy and speed.

@jschulzb Yes, it is easy to adjust it to discover points that attain some other value. Simply create a new procedure whose result is adjusted by the target value -- thus becoming a root-finding (zero-finding exercise).

If you are trying to discover where a solution from dsolve/numeric attains some specific value then the fastest way might be to properly use dsolve,events (which were implemented for just this kind of thing). Done right, that should be able to outperform rootfinding "after the fact" via fsolve or whatever else, both in terms of accuracy and speed.

@barefoot1980 Are you using Maple 13? If so, then you could try it instead as,

sol := solve({expand(eq1) < 1, expand(eq2) < 1}, {q});

Incidentally, the RootOfs of cubics that may appear for this particular example may be expressed explicitly and exactly,

evalc(allvalues([sol]))[];

@barefoot1980 Are you using Maple 13? If so, then you could try it instead as,

sol := solve({expand(eq1) < 1, expand(eq2) < 1}, {q});

Incidentally, the RootOfs of cubics that may appear for this particular example may be expressed explicitly and exactly,

evalc(allvalues([sol]))[];

@jschulzb Note that DEplot and DEplot3d can do animations too.

That may well be an effective and reasonably efficient way to show evolution in time from a/some initial conditions (ICs).

If, on the other hand, you intend on animating with respect to some other parameter that appears in an IVP's DEs or in its ICs and if you need it quicker than DEplot offers then you might take a glance at this.

First 393 394 395 396 397 398 399 Last Page 395 of 592