Mathematica Defining a piecewise function in Mathematica

AI Thread Summary
The discussion centers on a user attempting to implement a 2D Shannon interpolation using a custom sinc function, defined as sincC, due to compatibility issues with optimization software. The user encounters an error related to the Piecewise function when constructing the interpolation function, specifically indicating that the first argument is not formatted correctly. A solution is provided, highlighting the need for an additional pair of braces to properly enclose the components of the Piecewise function, which resolves the issue.
confused_engineer
Messages
34
Reaction score
1
TL;DR Summary
I can't define a piecewise function which reads data from a table as #
Hello everyone.

I am trying to do a 2D Shannon interpolation, but I cannot use a sinc because later on this expression goes in an optimization software that doesn't recognize it. I have defined my own version of sinc as:

sincC = Piecewise[{(Sin[Pi* #]/(Pi*(#))), # >= 1}, {1 - (#^2)/6 + (#^4)/120 - (#^6)/5040, # < 1}] & ;

The problem comes when I use the aforementioned sincC to construct the Shannon interpolation function.

shannonIPC[v_, w_] = Total[#3* sincC[(v - #1)/dDelta]*sincC[(w - #2)/dDelta] & @@@interpolatedData]

interpolatedData is a matrix of three columns and dDelta is a constant equal to 10. The error can be seen in the attached image, but it reads as
Piecewise:The first argument {(0.95493 Sin[1.0472 (-1.+v)])/(-1.+v),0.333333 (-1.+v)>=1} of Piecewise is not a list of pairs. and I am clueless about what to do.

Any advice is welcome.
Thanks for reading.
Regards.
 

Attachments

  • physics_forum.png
    physics_forum.png
    16.3 KB · Views: 431
Physics news on Phys.org
You need an extra pair of {...} to enclose all of the pieces of your piecewise function
 
  • Like
Likes confused_engineer
Dale said:
You need an extra pair of {...} to enclose all of the pieces of your piecewise function

Thank you very much. That was it.
 
  • Like
Likes Dale

Similar threads

Replies
1
Views
2K
Replies
13
Views
2K
Replies
1
Views
2K
Replies
4
Views
4K
Replies
3
Views
2K
Replies
19
Views
2K
Replies
4
Views
2K
Replies
1
Views
4K
Replies
1
Views
5K
Back
Top