Lee Worden
unread,Jun 21, 2015, 12:23:48 AM6/21/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage-s...@googlegroups.com
I find myself generating equations that include parameters as well as
the unknowns to be solved. solve() can solve them, but it gives me
solutions involving very large integers:
sage: xeqns
[0 == Xhat_16_0*(0.998269453158672*u_14_0 + 0.979122127166416*u_16_0 +
0.108186256568936) + Xhat_15_0*(0.911956549462578*u_14_0 -
0.590657494738595*u_15_0 - 0.204870943548919) +
Xhat_18_0*(-0.321614246160173*u_14_0 + 0.327627707091522*u_18_0 +
0.0446287749591415) + Xhat_17_0*(-0.990024436399567*u_14_0 +
0.720791652399857*u_17_0 + 1.91503976806778) - Xhat_14_0 + 1,
0 == Xhat_14_0*(-0.806922377871086*u_14_0 - 0.410286792246970*u_15_0 +
0.0703130815363731) + Xhat_18_0*(0.996339733796336*u_15_0 -
0.581711582792800*u_18_0 + 0.0813040469351425) +
Xhat_17_0*(0.525537953050958*u_15_0 + 0.401845474748703*u_17_0 -
1.14778153829983) + Xhat_16_0*(-0.146374502945015*u_15_0 +
0.963385811219748*u_16_0 + 0.976820867457244) - Xhat_15_0 + 1,
0 == Xhat_14_0*(-0.203272871020981*u_14_0 + 0.0588056025416353*u_16_0 +
0.123573227511746) + Xhat_15_0*(0.268118963783743*u_15_0 -
0.989229247893328*u_16_0 - 0.471091591754257) +
Xhat_17_0*(0.998721536662396*u_16_0 - 0.995856859070149*u_17_0 -
0.337051483572615) + Xhat_18_0*(-0.935660774020976*u_16_0 -
0.695511874037527*u_18_0 + 0.107069275555778) - Xhat_16_0 + 1,
0 == Xhat_14_0*(-0.693151782678718*u_14_0 + 0.140895760517200*u_17_0 -
0.354893156513737) + Xhat_15_0*(0.915707493921498*u_15_0 -
0.850770156918429*u_17_0 + 0.748484181251348) +
Xhat_16_0*(-0.0909346811889611*u_16_0 + 0.0505498981868667*u_17_0 -
1.14787557345853) + Xhat_18_0*(0.261790797142044*u_17_0 -
0.909453704721272*u_18_0 + 0.395863031622192) - Xhat_17_0 + 1,
0 == Xhat_14_0*(0.944806903841177*u_14_0 - 0.946870781398826*u_18_0 +
0.949247262577664) + Xhat_15_0*(0.813395128117138*u_15_0 -
0.0854817808579427*u_18_0 + 0.0744376062782887) +
Xhat_16_0*(-0.718514601850795*u_16_0 + 0.352900716857402*u_18_0 -
0.424756827570030) + Xhat_17_0*(0.415805193532685*u_17_0 -
0.965124644039169*u_18_0 - 0.417952982328260) - Xhat_18_0 + 1]
sage: xsol = solve( xeqns, [ Xhat_14_0, Xhat_15_0, Xhat_16_0, Xhat_17_0,
Xhat_18_0 ], solution_dict=True )
sage: str(xsol[0][Xhat_14_0])[:1000] + '...'
'-1778974251816734312245175211924787585288691331051677911263371996999102511728636760*(469111571006474915724094365743743075436229472017030083584611379539800574117024101916927422258054369875194745584087285796332968857050194496156008471949029583134385030285370894336612138169795232077183775*(76682914143778765874545151020325453648405792439573181871447590559380568101423991514177067855728740041504383010284716452586401696650*u_14_0
+
26711776113116191182825999050478462500301370934372854067032341895513539032970089074577335291904047106089037604224390289323479754111)*u_15_0^2
-
57216349703430620734263259037808035478924662307044649808970563197371466785397308803869126683574383070720550651210097344023485160062475256997747071565528033009712*((320906691122244797364987948730277936224515463120757118608603548739929374872348833251939773805004359526620325669288217107840279588975497523517907312103485894038184756858250*u_14_0
-
2502953691409002987599371027668266270751645059832720781205072777600454960819839032...'
(truncated because it's very long).
I think these large integers are the reason why desolve_system_rk4 fails
when I try to use this solution to construct the RHS of an ODE (in the u
variables).
I guess this is because it's made the decimal numbers in the input
equations into rational numbers before solving? Can I convince it to
leave them in floating point form? I considered writing a converter to
traverse those equations as SR expressions and convert the numbers, but
I'd rather not. Likewise, I'm sure I could do the ODE by constructing a
matrix inversion routine and using it on the fly, but I'd really just
like to solve the equation using floating point. Any suggestions?
Thanks!
Lee Worden