Consider the equation eex x2 1 Develop a trialanderror pro
Consider the equation e^-ex = x^2 - 1. Develop a trial-and-error program accept trial x values, evaluate the answer in respect to a defined tolerance. repeat the process until satisfactory answer is reached.
Solution
We know that the solution will be between 1 and 2 since ee^-x will always be between 0 and 1.
x = 1; %declaring the value
while (exp(exp(-x)) - x^2 + 1 > 0.01 && x<=2) %checking if value within tolerance of 0.01
x = x+0.001; %incrementing x
end
disp(x); %displaying solution
