triangle wave



My program pw.mac can define this function in a good and integrable way. 

try this.

load("pw.mac")$
f(x):=''(periodic(abs(x), x, -1, 1);
fp(x):=''(intperiodic(abs(x),x,-1,1);

You can get pw.mac from my site.  It is free and open source and has the same basic license as Maxima.

http://mysite.verizon.net/res11w2yb/id2.html

Rich

PS Hope you find it useful.



----- Original Message ----- 
From: "Richard Fateman" <fateman at cs.berkeley.edu>
To: "wutong feng" <wutong.feng at gmail.com>
Cc: <maxima at math.utexas.edu>
Sent: Wednesday, August 05, 2009 10:21 AM
Subject: Re: [Maxima] triangle wave


There seems to be a common misperception about Maxima and similar 
programs, of which this question is an example.
It is confusing program subroutines  and mathematical expressions.

It may also be misspelling integrate as Integrate ...

integrate is written to deal with mathematical expressions like  sin(x).

If you use the facilities in maxima to define a subroutine that takes 
some numerical argument and does something computationally opaque with 
it, like, say

f(x):= (s:0, for i:1 thru x do (s:random(i)+s),s)

you should not expect to be able to do integrate(f(x),x).

Unfortunately, the computer algebra programs present themselves so as to 
encourage this misperception:

some user-defined (or undefined!) function f(x)  can appear in almost 
any context in which a built-in mathematical function like sin() can appear.
But the user function may be an opaque program, and the system can do 
only very limited kinds of operations on it. Like apply it to arguments.
Other operations like simplification of combinations of such functions, 
or differentiation, integration, ....  generally do not make sense.

(as an extreme, consider   f(x):= evaluate_as_Windows_Vista_Command(x) .)

This, or something like it, can be defined in Maxima.

Now consider  integrate(f(x),x,0,1).
What could that possibly mean??

RJF

ps.  if you want to plot a triangle wave, define your function WITHOUT 
integrate.  Consider using floor, and %pi.


wutong feng wrote:
> how can i get a triangle wave.
>
> i used these commands ,but i does not work.
>
> f(x):= if x < 0 then -1 else 1;
> g(x):= f(sin(x));
> z(x):=Integrate(g(x),x);
> wxplot2d(g,[x,-10,10],[y,-2,2]);
>
> the error message is :
> plot2d: expression evaluates to non-numeric value somewhere in plotting range.
>
> please tell me the correct way.
>
>
> thanks very much!
>
> thanks very much.
>
>
>
>   


_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima