Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Joe Riel Newsgroups: comp.soft-sys.math.maple Subject: Re: Numerical definition of variables Date: Tue, 14 Jun 2011 16:24:52 -0700 Organization: A noiseless patient Spider Lines: 76 Message-ID: <87k4covvwb.fsf@san.rr.com> References: <871uyw1jow.fsf@san.rr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="7daQ3AF9ALJlnU9jGWSG5Q"; logging-data="932"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QG3a7YiNaIMP52af+yWO4" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:TeV16GG3mU2ZWtAG8zg63oohTeo= sha1:hWxkHavGsTlMa8hdBuo2yibDEnM= Xref: x330-a1.tempe.blueboxinc.net comp.soft-sys.math.maple:180 Herman Rubin writes: > On 2011-06-14, Joe Riel wrote: >> Herman Rubin writes: > >>> On 2011-06-13, rouben@shady.(none) (Rouben Rostamian) wrote: >>>> In article , >>>> Herman Rubin wrote: > >>>>>As an example, suppose I have two equations r and rr, and >>>>>two variables b and c which occur in them. Now when I enter > >>>>> fsolve({r,rr},{b,c}) > >>>>>it will produce the values of b and c. What I want done is >>>>>to use this, without too much additional syntax, to DEFINE >>>>>the values of b and c for subsequent work. > >>>> Will this do? > >>>> fsolve({r,rr},{b,c}); assign(%); > >>> I tried this, and it gives the error message > >>> Error (in assign) invalid arguments > >> What was returned by fsolve? It works for the simple case > >> (**) eqs := { a + 3*b = 12, b - a = 1 }: >> (**) fsolve(eqs, {a,b}); >> {a = 2.250000000, b = 3.250000000} > >> (**) assign(%); >> (**) a,b; >> 2.250000000, 3.250000000 > > >> My experience is that directly assigning to the solved variables >> is usually not the best way to work, at least not if you are >> want to deal with symbolic expressions. The problem is that it >> then makes expressions that use those variables numeric, which >> frequently prevents further analysis. > >> I'll generally assign the solution to a variable, say > >> fsol := fsolve( ... ); > >> and then, when I need numeric values for expressions, do > >> eval( some_expr, fsol ); > > What if the next thing you want to do is > > fsolve(eq, c); > > where a and b are in eq? Then a, b, and c are used in > some other calculations, including plotting. You could form the union of solutions in another set, which you then use to evaluate as you go along: sols := {}: eqs1 := { a+b=1, a-b=2 }: eqs2 := { a*b^2-c=1, c+d=a }: sols := sols union fsolve(eval(eqs1, sols)); sols := {a = 1.500000000, b = -0.5000000000} sols := sols union fsolve(eval(eqs2, sols)); sols := {a = 1.500000000, b = -0.5000000000 , c = -0.6250000000, d = 2.125000000} -- Joe Riel