Piecewise graphs

Beta releases, announcements and anything else that doesn't fit below. Please read the <B>Welcome</B> topic.

Moderator: DPlotAdmin

Post Reply
DCdenizen
Posts: 21
Joined: Mon Sep 08, 2008 9:11 pm

Piecewise graphs

Post by DCdenizen »

Hi David, any chance there's some way to graph piecewise functions? Ie...y = a + b*(x-L)^4, but only graph where (x-L) >= 0?
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Start at x=L? :D

I'm guessing that's not what you're after, though.

If you want to plot a function that results in an illegal operation for certain ranges of X (say sqrt of a negative number) you can use if(test,if true,if false) (more or less identical to the form used in Excel). Set the "if false" part to some constant well outside the range in Y you're interested in, then use Options>Amplitude limits to set the range outside which points will be ignored.
Visualize Your Data
support@dplot.com
DCdenizen
Posts: 21
Joined: Mon Sep 08, 2008 9:11 pm

Post by DCdenizen »

Haha, your intuition is correct...not exactly what I was after :-)

The equation is actually of the form: y=A+B*(x-L)^m+C*(x)^n

What I'd meant to write is that the b*(x-L)^4 term should be zero for any negative value of (x-L).
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

If F (your m) is a whole number, then this will work:

if(x-K<0,A+C*x^D,A+B*(x-K)^F+C*x^D)

(where K is your L)

If F is not a whole number you'll have to do some manual operations to get this to work. The problem in DPlot is that both the "if true" and "if false" parts are evaluated, whether the test is true or not. Off the top of my head I can't think of a good workaround in this case; you'll have to generate one curve for (x-K)<0 and another for (x-K)>=0, then lump the two together with Edit>Combine Curves.
Visualize Your Data
support@dplot.com
DCdenizen
Posts: 21
Joined: Mon Sep 08, 2008 9:11 pm

Post by DCdenizen »

I did the the logic in VBA for that reason, as the numbers aren't whole. I fed two separate FunctionofXY1Y2 commands the relevant equations, and only allowed them to graph across the valid x-values. Thanks!
Post Reply