Venkat Subramanian

431 Reputation

13 Badges

15 years, 265 days

MaplePrimes Activity


These are replies submitted by

@ Bendesarts

Note that long time solution of oscillatory equations is hard, in particular if it has both stiff and oscillatory parts.

Also, I am a little surprised that MATLAB works for this. Can you indicate which solver you use in MATLAB? As far as I know, MATLAB does not have an inbuilt symplectic integrator, I may be wrong.

Also, thanks for this example and post. One of the things I try to teach students is to come up with simple schemes when standard blackbox solvers fail. This is a good example.

@tomleslie 

Tomlesllie, Maple does not have a direct DAE solver, but Maplesim has. Also, Maplesim can solve DAEs without exact IC for algebraic variables, Maple cannot. Also, according to my testing, Maplesim uses different approach for order reduction and symbolic preprocessing (in particular for DAEs) and I have seen it to be more robust (but more painful to setup compared to classic worksheet Maple).

 

@Carl Love 

Thanks for your solution. I find fsolve unreliable and a pain to work with. Fortunately Roots works.

Disclaimer: My main interest is in the roots from 0 to 1. Gauss, Lobatto and Radau roots have direct links with collocation, implicit runge kutta methods for solving stiff ODEs, DAEs and for optimal control.  Specific formula for weights can be obtained, but are not included here. My main interest is in the roots (in ascending order). Later on, I will write a detailed post on the use of these roots when time permits.


restart:

 s corresponds to the number of roots

s:=25;

s := 25

(1)

 Lobatto points from 0 to 1 are given by the roots of f1 defined below

f:=x^(s-1)*(1-x)^(s-1);

f := x^24*(1-x)^24

(2)

f1:=diff(f,x$(s-2));

f1 := -174500150632293806354702228520960000*x^12*(1-x)^13+174500150632293806354702228520960000*x^13*(1-x)^12-126560548810235068345168649256960000*x^14*(1-x)^11+66293620805361226276040721039360000*x^15*(1-x)^10-24860107802010459853515270389760000*x^16*(1-x)^9+6580616771120415843577571573760000*x^17*(1-x)^8-1204295879682167605360601333760000*x^18*(1-x)^7+147895985224125846272354549760000*x^19*(1-x)^6-11675998833483619442554306560000*x^20*(1-x)^5-14441556998742881190543360000*x^22*(1-x)^3+171243758878374085263360000*x^23*(1-x)^2-620448401733239439360000*x^24*(1-x)-66293620805361226276040721039360000*x^10*(1-x)^15+1204295879682167605360601333760000*x^7*(1-x)^18+14441556998742881190543360000*x^3*(1-x)^22-147895985224125846272354549760000*x^6*(1-x)^19-171243758878374085263360000*x^2*(1-x)^23+126560548810235068345168649256960000*x^11*(1-x)^14+555999944451600925835919360000*x^21*(1-x)^4+24860107802010459853515270389760000*x^9*(1-x)^16+620448401733239439360000*x*(1-x)^24-6580616771120415843577571573760000*x^8*(1-x)^17+11675998833483619442554306560000*x^5*(1-x)^20-555999944451600925835919360000*x^4*(1-x)^21

(3)

 I have to increase the Digits for large values of s

Digits:=90;#

Digits := 90

(4)

P:=Student:-Calculus1:-Roots(evalf(f1));

P := [0., 0.610502753425314536409796456341974092350800318829046123909088085302809401284254756234629611e-2, 0.203679308737327605700774105802383987367485348573615040402581414931732385015341211306345596e-1, 0.425086146326887108384250331315767241765513654365758451154795969652901383375295581500695270e-1, 0.721617670823417112380933699141259519429661919940929549062501672482506454142569079778540383e-1, .108840170379641609800406023885626321260268486963982328469371733855312417750668955256907136, .151941475592432816619817283105311224369685632997407266147835278661330056442468816605472010, .200757926360003365951189501409466921016909810941654501300426024632700045200076967744406068, .254487942590560808690520038715598419467725766219313446622422407006720819123682316608737893, .312249271070386383385642693869640983656841846756140309068138568303408605559884075384429769, .373093467915561709910056559156362235068040400820232908112370629509987823678536320534528685, .436021470258446513645507687452672701552229338159203754455897388243348571715252741442068485, .500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, .563978529741553486354492312547327298447770661840796245544102611756651428284747258557931515, .626906532084438290089943440843637764931959599179767091887629370490012176321463679465471315, .687750728929613616614357306130359016343158153243859690931861431696591394440115924615570231, .745512057409439191309479961284401580532274233780686553377577592993279180876317683391262107, .799242073639996634048810498590533078983090189058345498699573975367299954799923032255593932, .848058524407567183380182716894688775630314367002592733852164721338669943557531183394527990, .891159829620358390199593976114373678739731513036017671530628266144687582249331044743092864, .927838232917658288761906630085874048057033808005907045093749832751749354585743092022145962, .957491385367311289161574966868423275823448634563424154884520403034709861662470441849930473, .979632069126267239429922589419761601263251465142638495959741858506826761498465878869365440, .993894972465746854635902035436580259076491996811709538760909119146971905987157452437653704, 1.]

(5)

nops(P);

25

(6)

s:=25;

s := 25

(7)

Radau points from 0 to 1 are given by the roots of f2 defined below

f:=x^(s-1)*(1-x)^(s);

f := x^24*(1-x)^25

(8)

f2:=diff(f,x$(s-1));

f2 := 8725007531614690317735111426048000000*x^12*(1-x)^13-8053853106105867985601641316352000000*x^13*(1-x)^12+5424023520438645786221513539584000000*x^14*(1-x)^11-2651744832214449051041628841574400000*x^15*(1-x)^10+932254042575392244506822639616000000*x^16*(1-x)^9-232257062510132323890973114368000000*x^17*(1-x)^8+40143195989405586845353377792000000*x^18*(1-x)^7-4670399533393447777021722624000000*x^19*(1-x)^6+350279965004508583276629196800000*x^20*(1-x)^5-15885712698617169309597696000000*x^21*(1-x)^4+393860645420260396105728000000*x^22*(1-x)^3-4467228492479323963392000000*x^23*(1-x)^2+15511210043330985984000000*x^24*(1-x)+3977617248321673576562443262361600000*x^10*(1-x)^15+14789598522412584627235454976000000*x^6*(1-x)^19-2888311399748576238108672000000*x^3*(1-x)^22-6903302662376458273372835414016000000*x^11*(1-x)^14-1657340520134030656901018025984000000*x^9*(1-x)^16-1401119860018034333106516787200000*x^5*(1-x)^20+83399991667740138875387904000000*x^4*(1-x)^21+51373127663512225579008000000*x^2*(1-x)^23-372269041039943663616000000*x*(1-x)^24+493546257834031188268317868032000000*x^8*(1-x)^17-103225361115614366173765828608000000*x^7*(1-x)^18+620448401733239439360000*(1-x)^25

(9)

 

 

P:=Student:-Calculus1:-Roots(evalf(f2));

P := [0.231210761779849156970527667109108955493938400363601018970938831890505145702989218451449409e-2, 0.121423037710748970539161894107291226052275516244601947149938013721604220294834850476248863e-1, 0.296648142140688469429651809241502051764854189590573794305428483666255585319802945970872751e-1, 0.546072632835427812988563452865810999567590785733821281956191007231946426189366729765185738e-1, 0.865767827550265315302788514920136620491530967532293755865061359260821023700663119038016241e-1, .125069312099831381682724703432114737271637281264379389283197442234066056177526477975443013, .169477840837413799212255121088091609172444090019451358355169209952129769556950321177328419, .219102036326996600805250221487002788622814670088420340362696997522436359460083511554781018, .273159303094970498119832634671648263866528687935981686603884108847361051266253211040201011, .330797129734299298946544979763412283935135323945898604301648403868706535950290103139228070, .391106535427185762805802922975940758711796144148846025370240179435355530462799229412397524, .453136405937860923387260256490829647594484622092650074338761470291741972660135743155142729, .515908493620297956850621184422957568936370643672578099208064475340518112990763499216017203, .578432845112938117304099631986994585631373367457690927818969373164522538458233496161470986, .639723413497304357655411772713573699664660011371408100004505991079072163379054655264598203, .698813608712255546201660637714535083446159885003641098292834462420635063228401029970444776, .754771540919097104851148697893764858906118665274492925978165516767230171162535168873246883, .806714716230866207975988323046227121551121428941877569650762614886766153041606367451453230, .853823952547252395010212695047597528663301339810320485160392563364557437354550424798107880, .895356294621761066990373565102059842799496256516124736008235360380729090738786639328504618, .930656720076807326494089734294811354089214798973623949032995418117296552269041493859045969, .959168433395614535919594013314675791092150545744384550593070456682106659507481588141527067, .980441486772077304786199009292962325465456451800767213257664037379876872518362997438665981, .994138700209984797217452949435418644706559011125738594587901255802822091993320854720603670, 1.]

(10)

nops(P);

25

(11)

 


Download LobattoandRadauQuadrature.mws

 

 

@acer 

Is there a way to find Radau and Lobatto nodes and weights similarly?

Thanks

 

@Carl Love 

Dr. Doug Meade at the University of South Carolina developed a package in Maple (release 4 or 5) to solve BVPs using shooting method (for regular BVPs).

For linear problems (as in this case), this works good. For nonlinear or difficult problems, this may not work. Of course using compile=true might help sovler your problem faster. In addition, problems requiring solution for different parameters will benefit from this approach as well if the singularity is removed with possible transformations or taking x= 1e-6 instead of 0.

To be accurate, it is wrong to claim rkf45 to be more robust compared to BVP solvers in Maple. I can post many easy examples. Take a 2D laplace equation =0. Apply finite difference in x (keep ode form in y). Give some boundary conditions (try to guess derivatives). IVP method will fail very fast (as N increases). However, I agree that for a second order BVP with two known conditions at one boundary point, IVP methods are better most of the times.

@Preben Alsholm 

Preben I am assuming that you are doing yours in evalhf mode and are comparing it with Maple's dsolve numeric (without compile=true which runs in hardware floats). If you are using a procedural form to define delay variables, then efficiency will depend a lot on the storage mechanism used for delay variables/history.  If evalhf mode is not used in your code, then setting Digits:=16 in both the codes will enable a fair comparison. Maple may be taking 30,000 steps, not sure.

 

@Markiyan Hirnyk 

Mathematica cannot solve example 2. Please prove me wrong if possible. Mathematica cannot handle state dependent delays. 

 

From Mathematica's website http://reference.wolfram.com/language/tutorial/NDSolveDelayDifferentialEquations.html

Currently, the implementation for DDEs in NDSolve only supports constant delays.

 

I am trying to post the supporting text file, but don't know how. the upload button won't take it.

@acer 

Acer this is great (defining V locally for evalhf mode). Is there a similar escape route for Compiler:-Compile? I ask this because I wrote some codes in which I observe gain in Compiler:-Compile (not inlined, just multiple compiled procedures), compared to evalhf at lower dimensions. When the problem size increases, for some reason, the linearsolver (compiled mode)/one of the compiled procedures bombs out? I am worried that perhaps I am using too many arrays (Externally) in compiled code.

 

@JonMcLoone 

As mentioned before by me Maple does not have a direct DAE solver (it converts DAEs to ODEs and integrates as of Maple 2015). Mathematica has IDA (Backward difference based solver) for index 1 nonlinear DAEs and can solve DAEs Maple cannot solve. 

That was the only reason I tried to use Mathematica as I had to solve DAEs.

 

That said, my attempts to use Mathematica kept pushing me back to Maple (classic worksheet) as I couldn't handle 100s of lines (copy paste multiple procedures) in Mathematica (too slow). I would rank the regular window (mw) comparable to Mathematica in terms of speed and ease of use (copy/paste).

 

In addition, setting higher infolevel helps me see the algorithm behind a particular method or command in Maple (at least for most of it, not true for financial portfolio/newer packages). I don't think one can see the algorithm behind Mathematica. Please correct me if I am wrong. (For me this is very important. In fact I have learned more mathematial methods/algorithms from just browsing through Maple than reading text/papers. So, I have lost interest in Mathematica).

 

Mathematica used to provide access to KNITRO (not sure if it is true anymore) for optimization which got my attention for a while (KNITRO, SNOPT and IPOPT are some of the best approaches for solving large scale optimization problems. TOMLAB is a good start for those who want to see what is out there). The internal and external optimization package called by Maple is not the best and you will hit RAM limitations very fast (my guess is that zeros in Jacobian are stored and that consumes memory, moving to sparse storage would help).

 

When I teach, I am being pushed to use MATLAB by many, but I insist that students learn and program in what they like and I will use Maple for the symbolic stuff (generate equations/models) and use C/FORTRAN for performance.  MATLAB for control/optimization tool box.

 

 

 

@maple2015 

try  using fsolve first. If not, the past link might be useful.

http://www.mapleprimes.com/questions/204206-Towards-A-Compiled-Newton-Raphson

 

 

@Preben Alsholm 

Yes, theoretically fsolve should work. But efficiency of fsolve is pretty bad compared to what I posted. You can check the cpu time. Importantly for difficult problems and large scale problems fsolve may not work.

Also, one can specify abserr=1e-15, relerr=1e-13 to get more accurate solution for the dsolve solution. 

 

in a PDE form with well defined bcs and ics. Population balance models can be very generic and complicated (with moving particle size as opposed to constant particle size), x,y,z and time variables. So, you need to state the equations and then you can expect a Maple solution.

 

Of course there are some very simple models with hyperbolic/parabolic type equations with analytical solutions.

As far as I know, no one claim that they have a code to solve any population balance model with all the complexities (this includes FLUENT/CFD commerical software).

If you want to solve this, then search and try COLDAE (FORTRAN code).

For some problems you can differentiate the algebraic equations and use the equation as bc to solve this. If you want me to try this, post mws code or mws format code (Maple format as opposed math format). Your problem looks simple, so this approach might work

 

@tomleslie 

I checked both maple 18 and maple 2015 (not 2015.1) in 64 bit windows 7, dsolve numeric compile =true works. The 32 bit calls the watcom, but the 64 bit calls something else, I can post a screenshot for both 32 and 64 bit versions if that helps.

Regarding your point on the same compiler version, point well taken. It is trivial to write a compiled procedure (single one, not linking multiple procedures), but sadly dsolve numeric/compile won't recognize this.

 

First 9 10 11 12 13 14 15 Page 11 of 18