[Maxima] triangle wave
fateman at cs.berkeley.edu
Wed Aug 5 09:21:28 CDT 2009
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??
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));
> 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.
More information about the Maxima