Post on 04-Jan-2016
description
1) de la función hallar su grafica y el cuadro de la bisseccion
b.
function [c,iter] = bissec(a,b,e)iter=0; fprintf(' ==========================================================\n') fprintf(' iter a b c f(a) f(c) \n') fprintf(' ==========================================================\n')while abs(b-a) > e c=(a+b)/2; fprintf('%5d %10.6f %10.6f %10.6f %10.6f %10.6f \n', iter,a,b,c,f(a),f(c)); if f(a)*f(c) > 0 a=c; else b=c; end iter=iter+1;end; end
function y = f(x)y=(x*exp(2))-1;end
>> [c,iter] = bissec(1,2,0.001)
==========================================================
iter a b c f(a) f(c)
==========================================================
0 1.000000 2.000000 1.500000 6.389056 10.083584
1 1.500000 2.000000 1.750000 10.083584 11.930848
2 1.750000 2.000000 1.875000 11.930848 12.854480
3 1.875000 2.000000 1.937500 12.854480 13.316296
4 1.937500 2.000000 1.968750 13.316296 13.547204
5 1.968750 2.000000 1.984375 13.547204 13.662658
6 1.984375 2.000000 1.992188 13.662658 13.720385
7 1.992188 2.000000 1.996094 13.720385 13.749249
8 1.996094 2.000000 1.998047 13.749249 13.763680
9 1.998047 2.000000 1.999023 13.763680 13.770896
c =1.9990
iter = 10
2) demostrar la formula de la escalera
function [x, iter] = newtonraphson (x, e)iter = 0;fprintf ( ' =============\n')fprintf ( ' iter x \n')fprintf ( ' =============\n')while abs (f(x)) > efprintf ( ' %5d %10.6f \n', iter, x);x = x - f(x)/df(x);iter = iter + 1;if iter >1000error ( 'parece que no converge newton' );endendend
function y = f(x)y=x^4-20*x^3+700*x^2-14000*x+70000;
function y=df(x) y=4*x^3-60*x^2+1400*x-14000;end
>> [x, iter] = newtonraphson (12, 0.000001) ============= iter x ============= 0 12.000000 1 22.283582 2 18.149899 3 15.872773 4 15.033612 5 14.911875 6 14.909370
x =14.9094iter = 7
3) hallar la viga y hallar las iteraciones: por el método de la bisección.
function y = f(x)y=-185*x+1650;
>> [c,iter] = bissec(8,10,0.000001)
c =8.9189iter = 21