Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >> %HARJOITUKSET
- >> %1. e^x = -x^2+2x+6
- >> x=-2:0.01:4;
- >> f1=exp(x);
- >> f2=-x^2+2*x+6;
- Error using ^ (line 51)
- Incorrect dimensions for raising a matrix to a power.
- Check that the matrix is square and the power is a
- scalar. To perform elementwise matrix powers, use '.^'.
- >> f2=-x.^2+2*x+6;
- >> figure
- >> plot(x,f1,x,f2)
- >> grid
- >> %Kuvasta nähdään, että leikkauspisteet ovat likimain
- >> > % -1.57 ja 1.88
- > % -1.57 ja 1.88
- ↑
- Error: Invalid use of operator.
- >> %Määritetään derivaatta
- >> syms x
- >> diff(exp(x)+x.^2-2*x-6)
- ans =
- 2*x + exp(x) - 2
- >> %ratkaisut
- >> x=-1.57;
- >> delta=100;
- >> while(delta>0.000001)
- f=exp(x)+x.^2-2*x-6;
- Df=2*x+exp(x)-2;
- X=x-f/Df;
- delta=abs(X-x);
- x=X;
- end
- >> x
- x =
- -1.6076
- >> x=1.88;
- >> delta=100;
- >> while(delta>0.000001)
- f=exp(x)+x.^2-2*x-6;
- Df=2*x+exp(x)-2;
- X=x-f/Df;
- delta=abs(X-x);
- x=X;
- end
- >> x
- x =
- 1.8397
- >> % Vastukest ovat x= -1.6076 ja 1.8397
- >>
- >>
- >> %Harjoitus 2
- >> %6cos(x) = 2x+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement