why solve function does not return answer?

5 次查看(过去 30 天)
syms b
eq1 = 1/tan(b);
sol=solve(eq1)
sol = Empty sym: 0-by-1
the equation above should give answer pi/2 or pi/2+n*pi
but solve doesnt give the answer...
What is the problem with my code?

回答(1 个)

Rushil
Rushil 2025-2-18
Hi there
The solve function is used to find explicit values where a given equation is satisfied. In the problem, we have the following equation:
eq1 = 1/tan(b);
This means that you would require “tan(b)” to take on an infinite value, which is not directly solvable in the typical sense. Since the solver sees the “tan(b)” function, it may realize that “tan(b)==inf” is an asymptote, and may not be able to find the solution.
A workaround is to consider a function that is not asymptotic at the expected solution. The equation can be rewritten using cos or cot functions, which are easier to deal with since they are not asymptotic at pi/2.
syms b
eq1 = cot(b); % or cos(b) since cot(b)=cos(b)/sin(b)
sol = solve(eq1,'ReturnConditions', true)
Changing the definition of “1/tan(b)” to “cot(b)” resolves the problem, even though both are equivalent. This is because the solver must deal with asymptotes in the former and can avoid them in the latter. Below are plots of the tan and cot functions which illustrate asymptotic behaviour.
Hope it clarifies the problem
larush

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by