Hi Jorge,
There is a third party package for defining and working with piecewise
defined functions. It is called pw.mac and it will allow you to define and
plot piecewise functions as well as simplify (transform), integrate and
differentiate them among other things. You can get it here.
http://sourceforge.net/projects/piecewisefunc/
In your case you could define your function in pw.mac in the following way.
load(pw)$
f(t):=''(piecewise([1, t-1, 2, 3-t, 3], t))$
plot2d(f(x), [x, 0, 4])$
Richard Hennessy
(author of pw.mac)
-----Original Message-----
From: Jorge Calvo
Sent: Monday, August 13, 2012 10:36 AM
To: maxima at math.utexas.edu
Subject: Plotting piecewise functions
Hello there:
I am trying to define some simple piecewise-linear functions that I can then
plot. For instance,
(%i01) f(t) := block(
if 1 < t and t <= 2 then
return(t-1)
elseif 2 < t and t < 3 then
return(3-t)
else
return(0))
$
By itself, this evaluates fine, but I cannot get Maxima to graph it. For
instance, I run into trouble when I try:
(%i02) draw2d(explicit(f(t), t, 0, 5));
If graphing is my goal, should I be defining f in a different way?
Thanks!
Jorge
--
Dr. Jorge Alberto Calvo
Associate Professor of Mathematics
Department of Mathematics and Physics
Ave Maria University
Phone: (239) 280-1608
Email: jorge.calvo at avemaria.edu
Web: http://sites.google.com/site/jorgealbertocalvo
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima