Venkat Subramanian

386 Reputation

13 Badges

15 years, 247 days

MaplePrimes Activity


These are replies submitted by

@cskoog 

 

Chris, Thanks. It works. I have figured out the issue. Maple 6 used to have method =mgear in dsolve/numeric. This was deprecated. It is sad. 

method=mgear provides for numerical solution based on Gear's method (BDF) with numerical Jacobian. Lsode cannot be made to run in this mode (hope I am not wrong). It will be great if this can be brought back in future versions.

Just changing mgear to other stiff methods was crashing the codes because of RAM issues.

showstat shows that the procedure exists in Maple 7 (not Maple 8), but it is disabled when calling from dsolve/numeric. Perhaps someone more knowledgable (Allan Wittkopf) can comment on how to call mgear method in Maple 7 or by storing the procedure as text file and calling it in later versions.

 

My tests suggest that mgear was one of the best algorithms, (better than Rosenbrock type algorithms) for largescale problems (RAM issues).

 

 

@Christopher2222 

I asked them only on Friday, so perhaps they will get back to me next week. What is clear is that Maplesoft doesn't have downloadable links anymore for Maple 6.

 

@taro and Cskoog,

 

I am able to open the files, but not run the same. It may be possible that some of the commands and procedures might have been deprecated from Maple 7 onwards, not sure.

 

It is a big set of procedures with intentionally ignoring the warnings in multiple places, so hard to debug.

 

 

@John Fredsted 

 

Chinthan is in my group. I think seq command is missing

 

try something like 

restart;with(CodeGeneration):

> f:=[x[1],x[2],x[3]-x[2]^2];
>
> C([seq(g[i] = f[i],i=1..3)]);

f := [x[1], x[2], x[3] - x[2] ^2]

g[0] = x[0];
g[1] = x[1];
g[2] = x[2] - pow(x[1], 0.2e1);

optimization seems to find it. I think trig form may be easier to prove, I will keep trying. The equality constraint is the equation of a circle with radiaus sqrt(2). Right now, the plots make sense.

restart;

eq:=x^(4*y)+y^(4*x);

eq := x^(4*y)+y^(4*x)

(1)

x:=sqrt(2)*cos(theta);y:=sqrt(2)*sin(theta);

x := 2^(1/2)*cos(theta)

y := 2^(1/2)*sin(theta)

(2)

eq;

(2^(1/2)*cos(theta))^(4*2^(1/2)*sin(theta))+(2^(1/2)*sin(theta))^(4*2^(1/2)*cos(theta))

(3)

eq2:=simplify(eq);

eq2 := 4^(2^(1/2)*sin(theta))*cos(theta)^(4*2^(1/2)*sin(theta))+4^(2^(1/2)*cos(theta))*sin(theta)^(4*2^(1/2)*cos(theta))

(4)

Optimization:-Maximize(%);

[2., [theta = .785390443327796]]

(5)

combine(eq2);

4^(2^(1/2)*sin(theta))*cos(theta)^(4*2^(1/2)*sin(theta))+4^(2^(1/2)*cos(theta))*sin(theta)^(4*2^(1/2)*cos(theta))

(6)

plot(eq2,theta=0..Pi/2,axes=boxed,thickness=3,axes=boxed);

 

 


Download Inequalityproof.mws

It may be possible to combine eq2 to a form 2*sin(a*theta+b+..)^c or something like that.

 

 

I gave up on copying and pasting large amount of codes/procedures in mw format. Try mws format, it should be 100x faster for copy/paste/edits.

 

 

@ 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.

 

First 8 9 10 11 12 13 14 Page 10 of 17