why solve function does not return answer?

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?

Risposte (1)

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

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Prodotti

Release

R2021b

Richiesto:

il 6 Nov 2021

Risposto:

il 18 Feb 2025

Community Treasure Hunt

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

Start Hunting!

Translated by