Post Reply 
Help with Piecewise function
02-01-2015, 06:09 PM
Post: #13
RE: Help with Piecewise function
(02-01-2015 04:43 PM)salvomic Wrote:  Off topic: there is in Prime a way to check if a function is even or odd? It would be useful for my program Smile

You can do a naive check: g(x)-g(-x) == 0 then g(x) is even; g(x)+g(-x) == 0 then g(x) is odd; may need to use the simplify() command. This is not guaranteed to work because the == operator checks for equality in a much stricter sense. That is, if the left hand side doesn't simplify down to 0, and this is due to the CAS being unable to simplify to 0, it may treat the comparison as false even if both sides are mathematically identical to 0.

You could randomly create, say, 50 different values of x and test the same equalities. If equality holds in all test cases, then there is a high probability your function is even (or odd, or neither, depending on which tests hold true).

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Help with Piecewise function - salvomic - 02-01-2015, 10:46 AM
RE: Help with Piecewise function - Snorre - 02-01-2015, 12:34 PM
RE: Help with Piecewise function - Snorre - 02-01-2015, 02:00 PM
RE: Help with Piecewise function - Snorre - 02-01-2015, 02:47 PM
RE: Help with Piecewise function - parisse - 02-01-2015, 02:55 PM
RE: Help with Piecewise function - parisse - 02-01-2015, 04:10 PM
RE: Help with Piecewise function - Han - 02-01-2015 06:09 PM
RE: Help with Piecewise function - parisse - 02-01-2015, 05:44 PM



User(s) browsing this thread: 1 Guest(s)