Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15208 > unrolled thread
| Started by | metrologuy <takacs@bnl.gov> |
|---|---|
| First post | 2013-07-20 09:56 +0000 |
| Last post | 2013-07-27 09:33 +0000 |
| Articles | 6 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
keep special functions unexpanded metrologuy <takacs@bnl.gov> - 2013-07-20 09:56 +0000
Re: keep special functions unexpanded David Bailey <dave@removedbailey.co.uk> - 2013-07-21 08:15 +0000
Re: keep special functions unexpanded Bob Hanlon <hanlonr357@gmail.com> - 2013-07-22 01:34 +0000
Re: keep special functions unexpanded David Bailey <dave@removedbailey.co.uk> - 2013-07-23 21:15 +0000
Re: keep special functions unexpanded Bob Hanlon <hanlonr357@gmail.com> - 2013-07-25 01:59 +0000
Re: keep special functions unexpanded metrologuy <takacs@bnl.gov> - 2013-07-27 09:33 +0000
| From | metrologuy <takacs@bnl.gov> |
|---|---|
| Date | 2013-07-20 09:56 +0000 |
| Subject | keep special functions unexpanded |
| Message-ID | <ksdmsm$50s$1@smc.vnet.net> |
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:
basislist={ChebyshevT[0,x],ChebyshevT[1,x],ChebyshevT[2,x]}.
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?
[toc] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2013-07-21 08:15 +0000 |
| Message-ID | <ksg5bo$c05$1@smc.vnet.net> |
| In reply to | #15208 |
On 20/07/2013 10:56, metrologuy wrote:
> 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:
> basislist={ChebyshevT[0,x],ChebyshevT[1,x],ChebyshevT[2,x]}.
> 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?
>
The best way to do this, is to use your own private notation for the
function in question:
basislist = {ChebT[0, x], ChebT[1, x], ChebT[2, x]}
Replace the notation when you need to evaluate it:
basislist /. ChebT -> ChebyshevT
{1, x, -1 + 2 x^2}
If you work with a lot of functions that you don't want to expand
immediately, you can keep the list of transformations in a variable to
simplify your work:
functionActivations={ ChebT -> ChebyshevT, ChebU -> ChebyshevU};
basislist /.functionActivations
{1, x, -1 + 2 x^2}
This technique also has the advantage that often your private functions
can be much neater in algebraic expressions - for example you can use
\[Gamma] to represent Gamma.
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2013-07-22 01:34 +0000 |
| Message-ID | <ksi27j$hvi$1@smc.vnet.net> |
| In reply to | #15208 |
Re: "This technique also has the advantage that often your private
functions can be much neater in algebraic expressions - for example you can
use =CE=B3 to represent Gamma."
You can just set your output format to TraditionalForm or manually invoke
TraditionalForm
{Gamma[Pi], ChebyshevT[i, x], LaguerreL[n, a, x]} // TraditionalForm
Bob Hanlon
On Sun, Jul 21, 2013 at 4:24 AM, David Bailey <dave@removedbailey.co.uk>wrote:
> On 20/07/2013 10:56, metrologuy wrote:
> > 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:
> > basislist={ChebyshevT[0,x],ChebyshevT[1,x],ChebyshevT[2,x]}.
> > 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?
> >
> The best way to do this, is to use your own private notation for the
> function in question:
>
> basislist = {ChebT[0, x], ChebT[1, x], ChebT[2, x]}
>
> Replace the notation when you need to evaluate it:
>
> basislist /. ChebT -> ChebyshevT
>
> {1, x, -1 + 2 x^2}
>
> If you work with a lot of functions that you don't want to expand
> immediately, you can keep the list of transformations in a variable to
> simplify your work:
>
> functionActivations={ ChebT -> ChebyshevT, ChebU -> ChebyshevU};
>
> basislist /.functionActivations
>
>
> {1, x, -1 + 2 x^2}
>
> This technique also has the advantage that often your private functions
> can be much neater in algebraic expressions - for example you can use
> \[Gamma] to represent Gamma.
>
> David Bailey
> http://www.dbaileyconsultancy.co.uk
>
>
>
>
>
.
[toc] | [prev] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2013-07-23 21:15 +0000 |
| Message-ID | <ksmrov$54$1@smc.vnet.net> |
| In reply to | #15230 |
On 22/07/2013 02:34, Bob Hanlon wrote: > Re: "This technique also has the advantage that often your private > functions can be much neater in algebraic expressions - for example you can > use =CE=B3 to represent Gamma." > > > You can just set your output format to TraditionalForm or manually invoke > TraditionalForm > Yes you can, but TraditionalForm is best for expressions that are not going to be pasted into other expressions and maybe edited. I prefer to stick with StandardForm if I am manipulating algebra in Mathematica. David Bailey http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2013-07-25 01:59 +0000 |
| Message-ID | <ksq0qg$8ne$1@smc.vnet.net> |
| In reply to | #15208 |
You can do both, just don't include the TraditionalForm in the expression's definition. For example with the default set to StandardForm: (expr = LaguerreL[n, a, x]) // TraditionalForm expr Bob Hanlon On Tue, Jul 23, 2013 at 5:21 PM, David Bailey <dave@removedbailey.co.uk>wrote: > On 22/07/2013 02:34, Bob Hanlon wrote: > > Re: "This technique also has the advantage that often your private > > functions can be much neater in algebraic expressions - for example you > can > > use =CE=B3 to represent Gamma." > > > > > > You can just set your output format to TraditionalForm or manually invoke > > TraditionalForm > > > > Yes you can, but TraditionalForm is best for expressions that are not > going to be pasted into other expressions and maybe edited. > > I prefer to stick with StandardForm if I am manipulating algebra in > Mathematica. > > David Bailey > http://www.dbaileyconsultancy.co.uk > > > >
[toc] | [prev] | [next] | [standalone]
| From | metrologuy <takacs@bnl.gov> |
|---|---|
| Date | 2013-07-27 09:33 +0000 |
| Message-ID | <kt044n$p4i$1@smc.vnet.net> |
| In reply to | #15208 |
Thank you all for your suggestions. David Park's elegant solution anticipated the second part of my problem, which I did not post, which was to be able to display the returned fit coefficients with the unexpanded form of the basis functions. This allows me to easily associate the most significant fit coefficient values with the appropriate basis order. Now I will extend this to a 2D basis set to fit the data to a surface. Thanks again.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web