Piecewise functions in Maxima or GNUplot

In summary, the conversation is about the struggle of a person with no prior knowledge of CAS software or programming to draw piecewise defined functions using Maxima or the GNUplot command line window. They have tried using two functions together but want to limit their domains, which is not mentioned in the help files. The suggestion given is to use a function with an if struct.
  • #1
GregA
210
0
I managed to lay my grubby mitts on Maxima about a month ago (fantastic program), but having no prior knowledge of CAS software or programming I am stuggling trying to figure out how to draw piecewise defined functions either through maxima itself or the GNUplot command line window (I prefer the latter for graphing)...I know that I can just graph two functions together and make a mental note of where one stops and the other starts, but what I want to do is just limit their domains, and nowhere in the help files I have can I find even a vague mention of this. can anyone help?
 
Physics news on Phys.org
  • #2
a function with an if struct will do it.

http://gnuplot.info/docs/gnuplot.html#if
 
Last edited by a moderator:
  • #3


Piecewise functions are a commonly used mathematical concept in many fields of science, and it's great that you are exploring ways to graph them using Maxima or GNUplot. These software programs are powerful tools for scientific analysis and visualization, and it's important to have a good understanding of their capabilities in order to make the most of them.

To address your specific question, both Maxima and GNUplot have the ability to graph piecewise functions. In Maxima, you can use the "plot2d" function and specify the piecewise function as an argument. For example, if you have a piecewise function defined as f(x) = x for x < 0, and f(x) = x^2 for x >= 0, you can graph it using the command "plot2d(f(x), [x,-5,5])". This will plot the function for x values ranging from -5 to 5.

Similarly, in GNUplot, you can use the "plot" command and specify a piecewise function using the "if" and "else" statements. For example, if you have the same piecewise function as above, you can graph it using the command "plot if(x < 0, x, x^2)". This will plot the function for x values less than 0 and for x values greater than or equal to 0.

I understand that you may not have prior knowledge of CAS software or programming, but there are many resources available online to help you learn more about these programs and how to use them for specific tasks. I would suggest looking for tutorials or guides on graphing piecewise functions in Maxima or GNUplot, or even reaching out to online communities or forums for assistance.

In conclusion, both Maxima and GNUplot have the capability to graph piecewise functions, and with a little bit of practice and research, you should be able to successfully graph your desired functions. Keep exploring and learning, and I'm sure you will become more comfortable with these tools in no time. Best of luck!
 

Related to Piecewise functions in Maxima or GNUplot

1. What is a piecewise function?

A piecewise function is a mathematical function that is defined by different equations or expressions for different intervals of the input. This means that the function may have different rules or formulas depending on the value of the input.

2. How do I create a piecewise function in Maxima or GNUplot?

In Maxima, you can create a piecewise function using the piecewise command. For example, piecewise(x<5, 2*x, x>=5, x+10) defines a piecewise function with one rule for x<5 and a different rule for x>=5. In GNUplot, you can use the if and else statements to define different equations for different intervals.

3. How do I plot a piecewise function in Maxima or GNUplot?

In Maxima, you can use the plot2d command to plot a piecewise function. For example, plot2d(piecewise(x<5, 2*x, x>=5, x+10), [x,0,10]) will plot the piecewise function with the given rules for x values from 0 to 10. In GNUplot, you can use the plot command and specify different equations for different intervals using the if and else statements.

4. Can I use piecewise functions in equations and calculations?

Yes, you can use piecewise functions in equations and calculations just like any other mathematical function. However, it is important to note that the rules or formulas for the piecewise function must be defined correctly and in the correct order for accurate results.

5. How do I edit or modify a piecewise function in Maxima or GNUplot?

In Maxima, you can use the subst command to substitute new expressions or rules for the existing piecewise function. For example, subst(x+5, x>=5, piecewise(x<5, 2*x, x>=5, x+10)) will replace the rule for x>=5 with x+5. In GNUplot, you can simply edit the equations or expressions within the if and else statements to modify the piecewise function.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Programming and Computer Science
Replies
2
Views
4K
  • Programming and Computer Science
Replies
17
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • Special and General Relativity
Replies
6
Views
5K
  • Programming and Computer Science
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
Back
Top