checking for positive syms

Hello
I have an element which is syms and I want to check if the items are positive integers. I have not found a function like is real.
such that for example :
syms h, assume(0<h<pi),
I want to know if sin(h-pi/4) is positive or not.
Does anyone have a solution?

回答(2 个)

>> feval(symengine,'is', sin(h-PI/4) < 0)
ans =
UNKNOWN
UKNOWN is used both for the case where it cannot compute the answer, and for the case where the answer is computable to be be true for some values and false for other values.
John D'Errico
John D'Errico 2016-8-28

0 个投票

Essentially you are asking to solve for the set of values for which some arbitrary function of a variable is positive.
Even in only one dimension, that set may be a list of disjoint intervals. In the case if sin(h-pi/4), suppose your initial assumption was that h must lie in some larger interval. Then there will be many such disjoint sub-intervals where your goal holds true.
Worse, suppose that your problem was in two dimensions. Now the solution will be some general set of sets, bounded by curved lines, so quite difficult to delineate or describe easily and in general.
The goal of checking if solutions are positive integers is more difficult yet, at least symbolically. While the case you show is a trivial one, since you can easily check all of the positive integers in the open interval (0,pi), in the more general case, finding all positive integer solutions to some arbitrary equation can be quite difficult. This would be called a Diophantine equation, the solution to which often requires a quite specialized method to solve, if any solution exists at all beyond exhaustive enumeration. For example, look at the family of Pell equations.

类别

在 帮助中心 和 File Exchange 中查找有关 Scripts 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by