MathGroup Archive 2000

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

Search the Archive

how to "dynamically" define such a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25644] how to "dynamically" define such a function
  • From: "Zhu X. P." <xpzhu at red.semi.ac.cn>
  • Date: Wed, 18 Oct 2000 02:52:20 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

hello all,

I want to define a function like this:

F[x]=
        f[x]=f[m][x]                      x>L[m],
        f[x]=f[m-1][x]                    L[m-1]<x<L[m],
        ....                              ...
        f[x]=f[1][x]                      L[1]<x<L[2],
        f[x]=f[0][x]                      x<L[1]

"Dynamically define" means "m" is not a fixed number. When m, as well as
L[i] and f[i][x] (i =,1,...,m), is given,  F[x] is defined.
I define F[x] as below:
F[x_] =
  Module[{n, w},
              w[x_, 0] = f[0][x];
              w[x_, n_] = If[x > L[n], f[n][x], w[x, n - 1]];
              w[x, m]
            ];
I think this method is not very good. Are there some better ways to
define such a function?
ps. I want to integrate this function F[x]:
Integrate[F[x], {x,a,b}]
when a>L[m], no problem. But when a<L[m] Mathematica tell me like this:

In[48]:=Integrate[F[x], {x, .2, 10}]
Out[48]:=\!\(\[Integral]\_0.2`\%21 If[x > 0.9000000000000001`,
\(f[7]\)[x - L[7 - 1]],
        w$52[x, 7 - 1]] \[DifferentialD]x\)

where m=7, 0.9 is the value of L[7]. Who can tell me why this happened?

thank you!

Zhu X. P.


  • Prev by Date: Re: front end graphics display
  • Next by Date: Re: How to Import Numbers with + in the Exponential?
  • Previous by thread: wrong Factor[] result
  • Next by thread: Re: how to "dynamically" define such a function