clear;clc;
%% 4.1
% solve x^2-7x+6=0
syms x
disp '4.1'
disp(solve(x^2-7*x+6==0,x))
%% 4.2
syms x y z
eq42 = [2*x+y-2*z==3,2*x-y-2*z==0,x+y+3*z==12];
disp '4.2'
disp(solve(eq42,[x,y,z]))
%% 4.3
syms x y
eq43 = [(4-x)^2+(1-y)^2==6^2,(6-x)^2+(1-y)^2==6^2];
s43 = solve(eq43,[x,y]);
disp '4.3'
disp 'x:'
disp(s43.x)
disp 'y:'
disp(s43.y)
%% 4.4
syms x
eq44 = cos(x) == x^2-6;
disp '4.4'
disp(vpasolve(eq44,x,[-3,0]))
disp(vpasolve(eq44,x,[0,3]))
f1 = figure;
fplot(@(x) cos(x),[-3,3]);
hold on
fplot(@(x) x.^2-6,[-3,3]);
%% 4.5
syms x
eq45 = cos(x)==sin(x);
disp '4.5'
disp(vpasolve(eq45,x,[0,1]))
disp(vpasolve(eq45,x,[1,4]))
disp(vpasolve(eq45,x,[4,8]))
%% 4.6
syms x
eq46g = (x-3)^2-3;
eq46f = 2*x;
disp '4.6'
f2 = figure();
fplot(@(x) (x-3).^2-3,[-5,10]);
hold on
fplot(@(x) 2*x,[-5,10]);
axis([-5,8,-4,15])
disp(vpasolve(eq46g == eq46f,x,[0,3]))
disp(vpasolve(eq46g == eq46f,x,[3,8]))