1) Solve the system of equations y = x * sin(x); y = 1 - x ^ 2 Check the accuracy of your Provide a graphical
interpretation of the solution.
% Define the function f(x) = x*sin(x) + x^2 - 1
f = @(x) x.*sin(x) + x.^2 - 1;
% Find positive root using fzero
x0 = 0.7; % initial guess
root_pos = fzero(f, x0);
root_neg = -root_pos;
% Display roots
fprintf('Root 1: x = %.6f\n', root_pos);
Root 1: x = 0.722588
fprintf('Root 2: x = %.6f\n', root_neg);
Root 2: x = -0.722588
% Compute y values
y1 = root_pos * sin(root_pos);
y2 = root_neg * sin(root_neg); % same as y1 since even function
fprintf('Corresponding y = %.6f\n', y1);
Corresponding y = 0.477867
% Visualization
x = linspace(-2, 2, 1000);
y_curve1 = x .* sin(x);
y_curve2 = 1 - x.^2;
figure;
plot(x, y_curve1, 'b', 'LineWidth', 1.5); hold on;
plot(x, y_curve2, 'r', 'LineWidth', 1.5);
plot(root_pos, y1, 'ko', 'MarkerSize', 8, 'MarkerFaceColor', 'g');
plot(root_neg, y2, 'ko', 'MarkerSize', 8, 'MarkerFaceColor', 'g');
grid on;
xlabel('x');
ylabel('y');
legend('y = x sin(x)', 'y = 1 - x^2', 'Solutions', 'Location', 'best');
title('Intersection of y = x sin(x) and y = 1 - x^2');
hold off;
1
2