MathGroup Archive 2004

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

Search the Archive

Re: Solve or LinearSolve or ...?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46378] Re: [mg46347] Solve or LinearSolve or ...?
  • From: Oleksandr Pavlyk <pavlyk at phys.psu.edu>
  • Date: Mon, 16 Feb 2004 23:42:04 -0500 (EST)
  • Organization: Penn State University; Department of Physics
  • References: <200402161359.IAA20483@smc.vnet.net>
  • Reply-to: pavlyk at phys.psu.edu
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Scott,

 From what you described I think this should do it


FindCoefficients[basis_List, point_] := Module[{CustomDer},
   CustomDer[expr_, (a_) + (b_)] := (1/2)*CustomDer[expr, a] +
                                    (1/2)*CustomDer[expr, b];
   CustomDer[expr_, (a_)?NumericQ*(b_)] :=
       (1/a)*CustomDer[expr, b];
   CustomDer[expr_, a_] := D[expr, a];
   (CustomDer[point, #1] & ) /@ basis
];

The solution is done defining customary derivatives which
is Mathematica's D function complemented with two additional
rules. It should be fast enough, I did not perform Timing though.

Best,
Sasha

Scott Morrison wrote:

> Hi,
> 
> I'm trying to write a function to calculate coefficients in a basis;
> for example
> 
> FindCoefficients[{f[a,a],f[a,b],f[b,a],f[b,b]}, f[a,a]+(1/2)f[b,a],
> _f]
> 
> should produce {1,0,1/2,0}. The third argument there means `assuming
> all objects matching _f are linearly independent'. More difficult, it
> should produce
> 
> FindCoefficients[{f[a]+f[b],f[a]-f[b]},f[a], _f] == {1/2,1/2}.
> 
> And finally, it should work with rational functions as coefficients,
> not just numbers, and it should run fast enough to be useful with
> bases with thousands of elements. :-)
> 
> I've spent quite some time trying to write something like this, and
> I'm finding it really difficult! I can't seem to use LinearSolve in
> any way -- it seems to trip up when I use rational functions as
> coefficients. I've been trying to work around Solve, but the only
> things that work are glacial in pace!
> 
> Any ideas or suggestions? I'd be happy to post some of my attempts if
> they'd be helpful in explaining what I'm trying to do, but mostly I'm
> too embarrassed by them :-)
> 
> Scott Morrison


  • Prev by Date: Re: Solve or LinearSolve or ...?
  • Next by Date: Re: Streaming input (with Linux)
  • Previous by thread: Solve or LinearSolve or ...?
  • Next by thread: Help Browser issue in 5.0.1 on Mac OS X