Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: what is the general theory of extracting solutions from DSolve (and similar) functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45567] Re: what is the general theory of extracting solutions from DSolve (and similar) functions
  • From: "Peltio" <peltio at twilight.zone>
  • Date: Wed, 14 Jan 2004 01:26:21 -0500 (EST)
  • References: <bu0dma$an4$1@smc.vnet.net>
  • Reply-to: "Peltio" <peltioNOSP at Miname.com.invalid>
  • Sender: owner-wri-mathgroup at wolfram.com

"steve_H" wrote

>I am learning Mathematica (Mathematica 5.0) and I am having hard time
finding
>a general method that works everytime to extract solutions
>from output of DSolve and other Mathematica functions that generates
>solutions in the same format.

Perhaps this is what you are looking for?
I can't test it right now on the output of DSolve, but when I tested it on
Solve's output it did work right (I might be overlooking something
essential, though). I wonder why there is no such a procedure built-in in
Mathematica (well, probably because it's easy to write it, but like Trace it can
help in writing a neater code...)

toValues[li_] := Module[
    {newli, vars, sols},
       sols = First[Dimensions[li]]; vars = Last[Dimensions[li]];
       newli = li /. (_ -> v_) -> v;
       If[vars == 1, newli = Flatten[newli] ];
       If[sols == 1,
             First[newli],
             newli
       ]
    ]

Just apply it to your solutions list in this way:

    solutions //toValues
or
    toValues[solutions]

Let me know if it works as you wished.

Hope this helps,
Peltio
--
Invalid address in reply-to. Crafty demunging required to mail me.


  • Prev by Date: Re: List arguments to functions
  • Next by Date: Re: composing functions
  • Previous by thread: what is the general theory of extracting solutions from DSolve (and similar) functions
  • Next by thread: Re: what is the general theory of extracting solutions from DSolve (and similar) functions