Solving for Variables contained an interval
Mostrar comentarios más antiguos
How do I solve the equation y = (sin(x) * (2* cos(x) - 1)) / (1 + 2 * cos(x)) only for x in the intervall [0 1], because if solved for all x there are infinte solutions. Thank you all for your help!
Respuesta aceptada
Más respuestas (2)
fun = @(x) (sin(x) .* (2.* cos(x) - 1)) ./ (1 + 2 .* cos(x)); % function
x0 = [0.1 2]; % initial interval
x = fzero(fun,x0)
t = linspace(0,2);
y = fun(t);
plot(t,y)
grid on
The function has value zero at x = 0, and the next one is at 1.0472. Therefore in the interval between 0 and 1 there is only a solution at 0.
4 comentarios
Joe
el 11 de Mzo. de 2023
syms x y real
eqn = y == sin(x)*(2*cos(x) - 1) / ((1 + 2*cos(x)) * (1 - cos(x)))
sol = solve(eqn, x, 'returnconditions', true)
sx = simplify(sol.x, 'steps', 20)
sol.conditions
b1L = solve(sx(1) == 0, sol.conditions(1), 'returnconditions', true)
b1U = solve(sx(1) == 1, sol.conditions(1), 'returnconditions', true)
sk = simplify(b1U.k, 'steps', 20)
sy = simplify(b1U.y, 'steps', 20)
vpa(sy)
b2L = solve(sx(2) == 0, sol.conditions(2), 'returnconditions', true)
b2U = solve(sx(2) == 1, sol.conditions(2), 'returnconditions', true)
b3L = solve(sx(3) == 0, sol.conditions(3), 'returnconditions', true)
b3U = solve(sx(3) == 1, sol.conditions(3), 'returnconditions', true)
So out of the three analytic branches for the equation, only one of them can be probed for boundaries. The first of them has no y boundary at x == 0 because the equation goes to infinity. It does have a y boundary at x == 1 of roughly 0.0709
John D'Errico
el 11 de Mzo. de 2023
Editada: John D'Errico
el 11 de Mzo. de 2023
syms x
y = (sin(x) * (2* cos(x) - 1)) / (1 + 2 * cos(x));
xsol = solve(y == 0)
There are only three primary solutions.
xsol = solve(y == 0,'returnconditions',true)
As you can see, now solve treturns a more complete result.
xsol.x
xsol.conditions
So, for integer k, the set of all solutions is one of those given in xsol.x, parameterized by the integer value of k.
That first positive solution is at pi/3, whhich falls just slightly outside of the interval [0,1]. So the only solution in that interval is 0 itself.
pi/3
Categorías
Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!










