Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2013

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

Search the Archive

Re: keep special functions unexpanded

  • To: mathgroup at
  • Subject: [mg131419] Re: keep special functions unexpanded
  • From: "djmpark" <djmpark at>
  • Date: Sun, 21 Jul 2013 04:24:57 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <10826547.44768.1374314590525.JavaMail.root@m06>

You could try something like this:

MakeBoxes[HoldForm[ChebyshevT[n_, x_]], 
  form : StandardForm | TraditionalForm] := 
 InterpretationBox[#1, #2] & @@    {RowBox[{SubscriptBox["T", 
      MakeBoxes[n, form]], "[", MakeBoxes[x, form], "]"}], 
   ChebyshevT[n, x]} 

Then with regular Mathematica:

fitFunctions = Table[HoldForm[ChebyshevT[ii, x]] /. ii -> i, {i, 0, 2}]
% // ReleaseHold 

{Subscript[T, 0][x], Subscript[T, 1][x], Subscript[T, 2][x]}
{1, x, -1 + 2 x^2}

Or with Presentations you could use:

fitFunctions = 
 Table[ChebyshevT[i, x], {i, 0, 2}] // HoldOp[ChebyshevT]

with the same output.

Then with Fit you might use:

data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}}; 
Fit[data, fitFunctions // ReleaseHold, x]
Cases[%, Alternatives @@ 
    Flatten[{a_Real, a_ Rest@ReleaseHold[fitFunctions]}] -> 

0.773869 - 0.266332 x + 0.0954774 (-1 + 2 x^2) 
0.773869 Subscript[T, 0][x] - 0.266332 Subscript[T, 1][x] + 0.0954774
Subscript[T, 2][x]

David Park
djmpark at 

From: metrologuy [mailto:takacs at] 

I am trying to create a list of ChebyshevT[n,x] polynomials of different
orders to use as basis functions in a fitting routine. I want to keep the
list in the form that explicitly shows the order number. For example, I want
the list for order n=2 to look like this:
If I use Table to generate the list, I get each function expanded into a
polynomial in x:

In[1]:= Table[ChebyshevT[i,x],{i,0,2}]

Out[1]= {1,x,-1+2 x^2}

How can I prevent the function from displaying the expanded form for each
value of n? If I use the unexpanded form in the Fit[] function, it works
just fine. But I lose the visual connection to the explicit order number in
the input form of the function. Any suggestions how to keep the "n" visible?

  • Prev by Date: Re: constructing a continuous region from 2D data using
  • Next by Date: Re: inconsistent refinement behavior
  • Previous by thread: Re: keep special functions unexpanded
  • Next by thread: Re: keep special functions unexpanded