Re: Is there a way to rewrite Roots[#n] result in easier to read form?
- To: mathgroup at smc.vnet.net
- Subject: [mg80351] Re: [mg80315] Is there a way to rewrite Roots[#n] result in easier to read form?
- From: DrMajorBob <drmajorbob at bigfoot.com>
- Date: Sat, 18 Aug 2007 05:38:27 -0400 (EDT)
- References: <17134341.1187333659867.JavaMail.root@m35>
- Reply-to: drmajorbob at bigfoot.com
ToRadicals will (sometimes) eliminate Root objects, but that will generally make things MORE complicated, not less. There are some things you can do instead, however. First I suggest avoiding subscripts (for ease in posting Q&A, if nothing else): Clear[x, y] ode11 = y'[x] == 1/Sqrt[a[4]*x^4 + a[3]*x^3 + a[2]*x^2 + a[1]*x + a[0]] y[x_] = y[x] /. First@DSolve[ode11, y[x], x]; There are 36 instances of Root in the result, but only four are distinct: Cases[y[x], _Root, \[Infinity]]; % // Length roots = %% // Union 36 {Root[a[0] + a[1] #1 + a[2] #1^2 + a[3] #1^3 + a[4] #1^4 &, 1], Root[a[0] + a[1] #1 + a[2] #1^2 + a[3] #1^3 + a[4] #1^4 &, 2], Root[a[0] + a[1] #1 + a[2] #1^2 + a[3] #1^3 + a[4] #1^4 &, 3], Root[a[0] + a[1] #1 + a[2] #1^2 + a[3] #1^3 + a[4] #1^4 &, 4]} Hence we can simplify display of y[x] this way: displayable = y[x] /. Root[_, k_] :> r[k] C[1] - (2 EllipticF[ ArcSin[Sqrt[((x - r[1]) (r[2] - r[4]))/((x - r[2]) (r[1] - r[4]))]], ((r[2] - r[3]) (r[1] - r[4]))/((r[1] - r[3]) (r[2] - r[4]))] (x - r[2])^2 Sqrt[((-r[1] + r[2]) (x - r[3]))/((x - r[2]) (-r[1] + r[3]))] (r[1] - r[4]) Sqrt[((x - r[1]) (r[1] - r[2]) (x - r[4]) (r[2] - r[4]))/((x - r[2])^2 (r[1] - r[4])^2)])/(Sqrt[ a[0] + x (a[1] + x (a[2] + x (a[3] + x a[4])))] (-r[1] + r[2]) (r[2] - r[4])) If, at any time, you still want to display subscripts, it's simple enough to do so: displayable /. {a[k_] :> Subscript[a, k], r[k_] :> Subscript[r, k], C[k_] :> Subscript[c, k]} Subscript[c, 1] - (2 EllipticF[ ArcSin[Sqrt[((x - Subscript[r, 1]) (Subscript[r, 2] - Subscript[ r, 4]))/((x - Subscript[r, 2]) (Subscript[r, 1] - Subscript[ r, 4]))]], ((Subscript[r, 2] - Subscript[r, 3]) (Subscript[r, 1] - Subscript[r, 4]))/((Subscript[r, 1] - Subscript[r, 3]) (Subscript[r, 2] - Subscript[r, 4]))] (x - Subscript[r, 2])^2 Sqrt[((-Subscript[r, 1] + Subscript[r, 2]) (x - Subscript[ r, 3]))/((x - Subscript[r, 2]) (-Subscript[r, 1] + Subscript[r, 3]))] (Subscript[r, 1] - Subscript[r, 4]) Sqrt[((x - Subscript[r, 1]) (Subscript[r, 1] - Subscript[r, 2]) (x - Subscript[r, 4]) (Subscript[r, 2] - Subscript[r, 4]))/((x - Subscript[r, 2])^2 (Subscript[r, 1] - Subscript[r, 4])^2)])/(Sqrt[ Subscript[a, 0] + x (Subscript[a, 1] + x (Subscript[a, 2] + x (Subscript[a, 3] + x Subscript[a, 4])))] (-Subscript[r, 1] + Subscript[r, 2]) (Subscript[r, 2] - Subscript[r, 4])) y[x] is still intact, but you can also retrieve the long-form result as displayable /. Thread[r /@ Range[4] -> roots]; y[x] == % True I hope that helps. Bobby On Fri, 17 Aug 2007 00:52:15 -0500, Nasser Abbasi <nma at 12000.org> wrote: > Hello; > This is Mathematica 6.01 > > Is there a way to make the output of the following DSolve more readable? > It > contains lots of Root[] with #n in it. > > > Remove["Global`*"] > ode11 = Derivative[1][y][x] - > 1/Sqrt[Subscript[a, 4]*x^4 + Subscript[a, 3]*x^3 + > Subscript[a, 2]*x^2 + Subscript[a, 1]*x + Subscript[a, 0]] == > 0; > DSolve[ode11, y[x], x] > > here is a pic of the output: > > http://12000.org/tmp/081507/output.PNG > > I understand what #'s are for, but was wondering if the output can be > written using more 'traditional' form so it will easier to read? i.e > having > the polynomial whose Roots are being called for, to be explicitly written > out or something along those lines?...I tried Simplify[]. > > thanks, > Nasser > > > -- DrMajorBob at bigfoot.com