Services & Resources / Wolfram Forums
MathGroup Archive
*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
  • Subject: [mg31099] Re: Can Fit give function coefficients?
  • From: Jens-Peer Kuska <kuska at>
  • Date: Wed, 10 Oct 2001 03:43:10 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <9pu3u0$bc8$>
  • Sender: owner-wri-mathgroup at


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

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] - 

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


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?