Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*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 2001

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

Search the Archive

Re: Can Fit give function coefficients?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31099] Re: Can Fit give function coefficients?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 10 Oct 2001 03:43:10 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <9pu3u0$bc8$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

since you have defined f1[x_] with out a
restriction to f1[] it will always evaluated.
But

In[]:=
f1[x_?NumericQ] := 2 x^2
f2[x_?NumericQ] := 3 x^3

data = Table[x^2 - x^3, {x, 0, 1, 1/50}];

Fit[data, {1, f1[x], f2[x]}, x]

Out[]=-0.003999768888798033 + 0.00019422792988261256*f1[x] - 
 2.5244146839178203*^-6*f2[x]

does what you want. Because f1[] and f2[] are left unchanged for
symbolic x.

Regards
  Jens

Brett Patterson wrote:
> 
> I have a set of functions that I wish to fit to some data.
> Is there a way to succinctly get Mathematica to give me
> the coefficients of these functions in the fit.
> 
> For example, say I have
> f1[x_] := 2 x^2
> f2[x_] := 3 x^3
> 
> Normally, if I say: Fit[data, {1, f1[x], f2[x]}, x]
> I get a result in the form: a1 + b1 x^2 + c1 x^3,
> but I want a result of the form: a2 + b2 f1[x] + c2 f1[x].
> In this case, a2 = a1, b2 = b1/2, and c2 = c1/3.
> 
> Is this possible?
> 
> Regards,
> Brett Patterson


  • Prev by Date: Re: Multiple scales for Y axis of plot?
  • Next by Date: Re: AVI-Video with Mathematica V4.2
  • Previous by thread: Re: Can Fit give function coefficients?
  • Next by thread: Re: Can Fit give function coefficients?