Clear Filters
Clear Filters

Bisection method for finding angle

1 view (last 30 days)
Angelina Encinias
Angelina Encinias on 30 Aug 2022
Answered: Sam Chak on 31 Aug 2022
Help with code
  3 Comments
Angelina Encinias
Angelina Encinias on 30 Aug 2022
How would I find this angle?
Steven Lord
Steven Lord on 30 Aug 2022
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

Sign in to comment.

Answers (1)

Sam Chak
Sam Chak on 31 Aug 2022
This should help you to visualize how to approach the problem. Since the solution space is between 0° and 90°, we can plot out the two functions over the range 0 to . and see where the intersection lies at.
x = linspace(0, pi/2, 1801);
yL = tan(x); % LHS function
yR = 1./(1 + exp(-x)); % RHS function
plot(x, yL, x, yR), grid, ylim([-0.5 1.5]), xlabel('x'), ylabel('y')
legend('LHS fcn', 'RHS fcn')
You can also transform the problem into a polynomial root-finding problem by applying Taylor series on the tangent and exponential functions:
Simplifying both sides and rearranging it yields a 7th-degree polynomial equation:
p7 = @(x) 4369/80640*x.^7 + 21/160*x.^5 + 17/48*x.^3 + 3/4*x - 1/2; % 7th-degree polynomial
fplot(p7, [0 pi/2])
grid, ylim([-0.5 0.5]), xlabel('x'), ylabel('y')
legend('p_7', 'location', 'east')
x0 = 0.6; % from 1st plot, we guess the initial point that is very close to the root
x = fzero(p7, x0) % finding the real root
x = 0.5683
This solution is merely an approximation, but a good one. Now, try applying the bisection method.

Categories

Find more on Mathematics in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!