how to solve the question

How do I plot f(x) in the following question?

f:=x->sum(h(2^n*x)/(2^n),n = 0 .. 20)

h(x)={ 2x , 0<=x<=1/2
{ 2-2x , 1/2<=x<=1
{ h(x-[x]), others

How do I plot f(x) in the

How do I plot f(x) in the following question?
f:=x->sum(h(2^n*x)/(2^n),n = 0 .. 20)
h(x)={ 2x ,0<=x<=1/2 ; 2-2x,1/2<=x<=1 ; h(x-[x]),others

gulliet's picture

What is h(x)?

The definition of h(x) is missing or incomplete or have been truncated in some way.

Regards,
--
Jean-Marc

Doug Meade's picture

&lt; in text

This looks to be another instance of an < in the text of a post. To be able to see < in the body of a post, you will need to enter it as &lt; (with the semi-colon) or use an HTML tag to force the desired appearance.

---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
Doug Meade's picture

piecewise

It looks as though you are trying to say that h is a piecewise defined function. If so, then you will need to use the piecewise command. For example,

h := x->piecewise( x>0 and x<1/2, 2*x, 0 );

There are other issues with the little snippet of code that I can see in your original post. First, sum should be replaced with add. (While it works with sum, sum is for use with formal sums that you expect will have a closed form or other simplification.)

You can now plot the FUNCTION f as follows:

plot( f, 0..1 );

or the EXPRESSION f(x) as follows:

plot( f(x), x=0..1 );

Since this function is discontinuous, you may want to include the option discont=true in either of the above.

If you want to include the base function, h, in the plot you might want to do something like

plot( [f,h], 0..1, discont=true, style=[line,point] );

If you happen to want to look at the value of f(x), you will see the sum of 21 piecewise functions. We can force Maple to simplify this to a single piecewise-defined function with the following:

f(x);
convert( f(x), piecewise );

Guessing at your ultimate interests, this form might be very enlightening or instructive.

Doug

---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}