Message Boards Message Boards

Convert a piecewise integer function into usable form such as a List?

Posted 4 years ago

The function InverseFourierSequenceTransform returns a Piecewise function. The display of the values is nice but the values are buried in the representation. I got along by descending the expression tree for the values, but today the expression 10<n<17 showed up - enough duplication of effort. I hope there is a Ma function that converts any Piecewise function into usable form. For a work-around I use pl=DiscretePlot which happily displays the data. In the display object the data points and values are at pl[[1, 1, 1, 1, 2, 1, 1, 2, -1, 1]] from which a SparseArray and then a Normal list are created.

enter image description here

POSTED BY: Douglas Kubler
4 Replies
Posted 4 years ago

Thank you. Your code worked (amazed that ReplaceAll interpreted 10<n<17). But ReplaceAll put each value one position too low in the list. The n's refer to absolute list positions. A simple fix was to change the range to Range[1,30]

enter image description here

POSTED BY: Douglas Kubler
Posted 4 years ago

Isn't that just a simple modification to my previous answer?

# -> ifst /. {n -> #} & /@ Range[2, 30]

Would be helpful if you could post the InputForm of your piecewise function.

POSTED BY: Rohit Namjoshi
Posted 4 years ago

No, I want to construct rules from the structure and then a list - n is the index in the list, the first column are the values. Note that 10<n<17 is shorthand for 6 rules - 11 thru 16. It's doable but why duplicate what has already been done in DiscretePlot? These are the steps I took when extracting the convenient data from DiscretePlot as points. enter image description here

POSTED BY: Douglas Kubler
Posted 4 years ago

Is this what you are looking for?

ifst /. {n -> #} & /@ Range[2, 30]
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract