Árpád apánk
Blog. ennyi. semmi több. megtalalsz itt jó pár infót rólam, az életemről, meg néhány érdekes dolgot is, csak épp fejlesszem ki. addig is türelem kispajtás :)
2010/07/15
2008/05/20
tizedik
> evalf(int(x^2+1,x=-1..1));
2.666666667
> f:=x->x^2+1;
f := proc (x) options operator, arrow; x^2+1 end proc
> ff:=evalf(f(-sqrt(3)/3)+f(sqrt(3)/3));
ff := 2.666666667
> evalf(int(x^3-1,x=0..2));
2.
> g:=x->x^3-1;
g := proc (x) options operator, arrow; x^3-1 end proc
> gg:=evalf(g((-sqrt(3)/3)+1)+g((sqrt(3)/3)+1));
gg := 1.999999999
> z:=x->cos(Pi*x);
z := proc (x) options operator, arrow; cos(Pi*x) end proc
> evalf(int(cos(Pi*x),x=0..1));
0.
> zz:=evalf((1/2)*((5/9)*z((-(-sqrt(15)/5)+1)/2))+(8/9)*z(1/2)+(5/9)*z((-(sqrt(15)/5)+1)/2));
zz := .2605477402
> n:=x->x^2+3*x+2;
n := proc (x) options operator, arrow; x^2+3*x+2 end proc
> diff(n(x),x);
2*x+3
> nn=expand((n(x+0.01)-n(x))/0.01);
nn = 3.01+2.*x
> m:=x->sin(x);
m := sin
> diff(diff(m(x),x),x);
-sin(x)
> mm:=expand((m(x+0.01)-2*m(x)+m(x-0.01))/0.01^2);
mm := -.99999*sin(x)
> xx:=[1,2,3,4,5];
xx := [1, 2, 3, 4, 5]
> yy:=[1,-3,-1,0,1];
yy := [1, -3, -1, 0, 1]
> c:=interp(xx,yy,x);
c := 1/3*x^4-9/2*x^3+65/3*x^2-85/2*x+26
> D(2.5)(c);
0
> px:=[Pi/2,Pi,3*Pi/2,2*Pi,5*Pi/2];
px := [Pi/2, Pi, 3*Pi/2, 2*Pi, 5*Pi/2]
> py:=[1,0,-1,0,1];
py := [1, 0, -1, 0, 1]
> d:=interp(px,py,x);
d := -8*x^4/(3*Pi^4)+16*x^3/Pi^3-94*x^2/(3*Pi^2)+22*x/Pi-4
> D(Pi)(d);
0
> with(CurveFitting);
>
[BSpline, BSplineCurve, Interactive, LeastSquares, PolynomialInterpolation, RationalInterpolation, Spline, ThieleInterpolation]
> PolynomialInterpolation(px,py,x,Newton);
-8*x^4/(3*Pi^4)+16*x^3/Pi^3-94*x^2/(3*Pi^2)+22*x/Pi-4
> with(plots);
Warning, the name changecoords has been redefined
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, disp...[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, disp...[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, disp...
> h:=[[x[0],y(x[0])]];
for i from 0 to 9 do
x[0]:=0;
y(x[0]):=2;
x[i+1]:=x[i]+0.1;
y(x[i+1]):=y(x[i])+0.1*(1+x[i]^2);
h:=[op(h),[x[i+1],y(x[i+1])]];
end do;
h := [[0, 2]]
x[0] := 0
y(0) := 2
x[1] := .1
y(.1) := 2.1
h := [[0, 2], [.1, 2.1]]
x[0] := 0
y(0) := 2
x[2] := .2
y(.2) := 2.201
h := [[0, 2], [.1, 2.1], [.2, 2.201]]
x[0] := 0
y(0) := 2
x[3] := .3
y(.3) := 2.305
h := [[0, 2], [.1, 2.1], [.2, 2.201], [.3, 2.305]]
x[0] := 0
y(0) := 2
x[4] := .4
y(.4) := 2.414
h := [[0, 2], [.1, 2.1], [.2, 2.201], [.3, 2.305], [.4, 2.414]]
x[0] := 0
y(0) := 2
x[5] := .5
y(.5) := 2.530
h := [[0, 2], [.1, 2.1], [.2, 2.201], [.3, 2.305], [.4, 2.414], [.5, 2.530]]
x[0] := 0
y(0) := 2
x[6] := .6
y(.6) := 2.655
h := [[0, 2], [.1, 2.1], [.2, 2.201], [.3, 2.305], [.4, 2.414], [.5, 2.530], [.6, 2.655]]
x[0] := 0
y(0) := 2
x[7] := .7
y(.7) := 2.791
h := [[0, 2], [.1, 2.1], [.2, 2.201], [.3, 2.305], [.4, 2.414], [.5, 2.530], [.6, 2.655], [.7, 2.791]]
x[0] := 0
y(0) := 2
x[8] := .8
y(.8) := 2.940
h := [[0, 2], [.1, 2.1], [.2, 2.201], [.3, 2.305], [.4, 2.414], [.5, 2.530], [.6, 2.655], [.7, 2.791], [.8, 2.940]]
x[0] := 0
y(0) := 2
x[9] := .9
y(.9) := 3.104
h := [[0, 2], [.1, 2.1], [.2, 2.201], [.3, 2.305], [.4, 2.414], [.5, 2.530], [.6, 2.655], [.7, 2.791], [.8, 2.940], [.9, 3.104]]
x[0] := 0
y(0) := 2
x[10] := 1.0
y(1.0) := 3.285
h := [[0, 2], [.1, 2.1], [.2, 2.201], [.3, 2.305], [.4, 2.414], [.5, 2.530], [.6, 2.655], [.7, 2.791], [.8, 2.940], [.9, 3.104], [1.0, 3.285]]
> pointplot(h);
[Plot]
>
kilencedik
> with(student);
[D, Diff, Doubleint, Int, Limit, Lineint, Product, Sum, Tripleint, changevar, completesquare, distance, equate, integrand, intercept, intparts, leftbox, leftsum, makeproc, middlebox, middlesum, midpoi...[D, Diff, Doubleint, Int, Limit, Lineint, Product, Sum, Tripleint, changevar, completesquare, distance, equate, integrand, intercept, intparts, leftbox, leftsum, makeproc, middlebox, middlesum, midpoi...
> f:=x->x^7*ln(x)+x-cos(x);
f := proc (x) options operator, arrow; x^7*ln(x)+x-cos(x) end proc
> g:=x->exp(-x^2);
g := proc (x) options operator, arrow; exp(-x^2) end proc
> h:=x->exp(x)*sin(x);
h := proc (x) options operator, arrow; exp(x)*sin(x) end proc
> evalf(int(f(x),x=2..3));
783.5712461
> evalf(int(g(x),x=-1..1));
1.493648266
> evalf(int(h(x),x=0..Pi));
12.07034632
> middlebox(f(x),x=2..3);
[Plot]
> evalf(middlesum(f(x),x=2..3,10));
781.0907780
> evalf(simpson(f(x),x=2..3,100));
783.5712470
> middlebox(g(x),x=-1..1,10);
[Plot]
> evalf(middlesum(g(x),x=-1..1));
1.509195888
> evalf(simpson(g(x),x=-1..1,100));
1.493648269
> middlebox(h(x),x=0..Pi,10);
[Plot]
> evalf(middlesum(h(x),x=0..Pi));
12.66778405
> evalf(simpson(h(x),x=0..Pi,100));
12.07034606
> teglalap:=proc(f,a,b,n)
local h,d;
h:=(b-a)/n;
d:=(b-a)/n*sum(f(a-h/2+i*h),i=1..n);
return evalf(d);
end proc;
>
teglalap := proc (f, a, b, n) local h, d; h := (b-a)/n; d := (b-a)*(sum(f(a-1/2*h+i*h), i = 1 .. n))/n; return evalf(d) end proc
> teglalap(f,2,3,10);
781.0907781
> with(Student[Calculus1]);
[AntiderivativePlot, ApproximateInt, ArcLength, Asymptotes, Clear, CriticalPoints, DerivativePlot, ExtremePoints, FunctionAverage, FunctionChart, GetMessage, GetNumProblems, GetProblem, Hint, Inflecti...[AntiderivativePlot, ApproximateInt, ArcLength, Asymptotes, Clear, CriticalPoints, DerivativePlot, ExtremePoints, FunctionAverage, FunctionChart, GetMessage, GetNumProblems, GetProblem, Hint, Inflecti...[AntiderivativePlot, ApproximateInt, ArcLength, Asymptotes, Clear, CriticalPoints, DerivativePlot, ExtremePoints, FunctionAverage, FunctionChart, GetMessage, GetNumProblems, GetProblem, Hint, Inflecti...
> ApproximateInt(f(x),x=2..3);
5/2+271818611107/12800000000*ln(43/20)-1/10*cos(9/4)-1/10*cos(43/20)-1/10*cos(41/20)-1/10*cos(11/4)-1/10*cos(53/20)-1/10*cos(51/20)-1/10*cos(49/20)-1/10*cos(47/20)-1/10*cos(59/20)-1/10*cos(57/20)+2488...5/2+271818611107/12800000000*ln(43/20)-1/10*cos(9/4)-1/10*cos(43/20)-1/10*cos(41/20)-1/10*cos(11/4)-1/10*cos(53/20)-1/10*cos(51/20)-1/10*cos(49/20)-1/10*cos(47/20)-1/10*cos(59/20)-1/10*cos(57/20)+2488...
>
nyolcadik
> with(CurveFitting);
>
[BSpline, BSplineCurve, Interactive, LeastSquares, PolynomialInterpolation, RationalInterpolation, Spline, ThieleInterpolation]
> expand(PolynomialInterpolation([0,1,2,3],[1,3,-1,2],x,form=Lagrange));
>
>
13/6*x^3-19/2*x^2+28/3*x+1
> lag:=expand(PolynomialInterpolation([0,1,2,3],[1,3,-1,2],x,form=Newton));
>
lag := 13/6*x^3-19/2*x^2+28/3*x+1
> pointplot({[0,1],[1,3],[2,-1],[3,2]},symbolsize=25);
[Plot]
> display(pointplot({[0,1],[1,3],[2,-1],[3,2]},symbolsize=25),plot(lag,x=-1..4,y=-5..5));
[Plot]
> with(plots);
Warning, the name changecoords has been redefined
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, disp...[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, disp...[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, disp...
> xi:=[0,1,3,4.2,5,5.8,7,8];
>
xi := [0, 1, 3, 4.2, 5, 5.8, 7, 8]
> yi:=[1,2.5,2.3,5,3.5,4.2,7,10];
yi := [1, 2.5, 2.3, 5, 3.5, 4.2, 7, 10]
> sp1:=Spline(xi,yi,x);
sp1 := PIECEWISE([1.+2.04045418599999984*x-.540454185700000034*x^3, x < 1], [2.080908371+.419091629299999990*x-1.62136255679615826*(x-1)^2+.680908371300000037*(x-1)^3, x < 3], [-4.013625568+2.10454185...
> display(pointplot({[0,1],[1,2.5],[3,2.3],[4.2,5],[5,3.5],[5.8,4.2],[7,7],[8,10]},symbolsize=25),plot(sp1,x,y=-1..12,color=green),plot(lag1,y=-5..12,x=-4..4,color=blue));
[Plot]
> lag1:=expand(PolynomialInterpolation(xi,yi,x,form=Lagrange));
lag1 := 47.66577892*x+59.68279433*x^3-89.75801475*x^2-.2626950677*x^6-18.98393180*x^4+3.147340024*x^5+0.8728350885e-2*x^7+1.000000000
> f:=x->(cos(Pi*x))^3-4*x;
f := proc (x) options operator, arrow; cos(Pi*x)^3-4*x end proc
> xx:=[-1,-1/2,0,1/2,1];
xx := [-1, (-1)/2, 0, 1/2, 1]
> g:=x->A*x^3+B*x^2+C*x+D;
g := proc (x) options operator, arrow; A*x^3+B*x^2+C*x+D end proc
> y1:=map(f,xx);
y1 := [3, 2, 1, -2, -5]
> osszeg:=(A,B,C,D)->sum((y1[i]-(g(xx[i])))^2,i=1..5);
osszeg := proc (A, B, C, D) options operator, arrow; sum((y1[i]-g(xx[i]))^2, i = 1 .. 5) end proc
> DA:=diff(osszeg(A,B,C,D),A);
DA := 17+65*A/16+17*C/4
> DB:=diff(osszeg(A,B,C,D),B);
DB := 4+17*B/4+5*D
> DC:=diff(osszeg(A,B,C,D),C);
DC := 20+17*A/4+5*C
> DD:=diff(osszeg(A,B,C,D),D);
DD := 2+5*B+10*D
> eqA:=DA=0;
>
eqA := 17+65*A/16+17*C/4 = 0
> eqB:=DB=0;
eqB := 4+17*B/4+5*D = 0
> eqC:=DC=0;
eqC := 20+17*A/4+5*C = 0
> eqD:=DD=0;
eqD := 2+5*B+10*D = 0
>
> megold:=solve({eqA,eqB,eqC,eqD},{A,B,C,D});
megold := {C = -4, A = 0, D = 23/35, B = (-12)/7}
> polinom:=subs(megold,g(x));
polinom := 23/35-12/7*x^2-4*x
> LeastSquares(xx,y1,x,curve=A*x^3+B*x^2+C*x+D);
23/35-12/7*x^2-4*x
> with(stats);
[anova, describe, fit, importdata, random, statevalf, statplots, transform]
> with(statplots);
[boxplot, histogram, scatterplot, xscale, xshift, xyexchange, xzexchange, yscale, yshift, yzexchange, zscale, zshift]
> scatterplot(xx,y1,symbolsize=25);
[Plot]
> c:=scatterplot(xx,y1,symbolsize=25):
> display(c,plot(polinom,x=-1..1));
[Plot]
>
hetedik
> | herm:=x->a0+a1*x+a2*x^2+a3*x^3+a4*x^4+a5*x^5; |
> | x0:=-1; |
> | x1:=0; |
> | x2:=1; |
> | herm(x0)=1; |
> | herm(x1)=1; |
> | herm(x2)=-2; |
> | hermder:=x->a1+2*a2*x+3*a3*x^2+4*a4*x^3+5*a5*x^4; |
> |
> | hermder(x0)=2; |
> | hermder(x1)=3; |
> | hermder(x2)=0; |
> | b:=solve({herm(x0)=1,herm(x1)=1,herm(x2)=-2,hermder(x0)=2,hermder(x1)=3,hermder(x2)=0}); |
> | c:=subs(b,herm(x)); |
> | plot(c,x=-1..1); |
> |
> | newtonpolegyutt:=proc(xk,yk) local n,i,j; n:=nops(xk)-1; for i from 0 to n do a[i+1]:=yk[i+1]; end do; for i from 1 to n do for j from n to i by -1 do a[j+1]:=(a[j+1]-a[j])/(xk[j+1]-xk[j-i+1]); end do; end do; return op(a); end proc; |
> |
Warning, `a` is implicitly declared local to procedure `newtonpolegyutt`
> | xk:=[0.0,0.1,0.2,0.3,0.4,0.5]; |
> | yk:=map(sin,xk); |
> | a:=newtonpolegyutt(xk,yk); |
> | newtonpol:=proc(xk,a,x) local p,i,n; n:=nops(xk)-1; p:=a[n+1]; for i from n-1 to 0 by -1 do p:=a[i+1]+(x-xk[i+1])*p; end do; return p; end proc; |
> | newtonpol(xk,a,0.45); |
> | sin(0.45); |
> | f:=x->exp(2*x); |
> | xk:=[seq(-1+k/4,k=0..8)]; |
> | yk:=map(f,xk); |
> | a:=evalf(newtonpolegyutt(xk,yk)); |
> | expand(newtonpol(xk,a,x)); |
> |
hatodik
> | f:=x->x*cos(x); |
> | z:=interp([0,2*Pi/3,4*Pi/3,2*Pi],[f(0),f(2*Pi/3),f(4*Pi/3),f(2*Pi)],x); |
> | evalf(z); |
> | plot(f); |
> | with(plots); |
Warning, the name changecoords has been redefined
> | gr1:=plot(f(x),x=0..2*Pi,color=red): |
> | gr2:=plot(z,x=0..2*Pi,color=green): |
> | display(gr1,gr2); |
> | lagrange:=proc(x,y,a) local n,v,i,j,t; v:=0; n:=nops(x); for i from 0 to n-1 do t:=y[i+1]; for j from 0 by 1 to i-1 do t:=t*(a-x[j+1])/(x[i+1]-x[j+1]); end do; for j from i+1 to n-1 do t:=t*(a-x[j+1])/(x[i+1]-x[j+1]); end do; v:=v+t; end do; end proc; |
> |
> | expand(lagrange([0,2*Pi/3,4*Pi/3,2*Pi],[f(0),f(2*Pi/3),f(4*Pi/3),f(2*Pi)],x)); |
> | t:=(b+a)/2-(b-a)/2*cos(2*k-1)*Pi/(2*n); |
> | f2:=x->sin(x)+cos(x); |
> | t1:=(2*Pi+0)/2-(2*Pi-0)/2*cos((2*1-1)*Pi/(2*4)); |
> | t2:=(2*Pi+0)/2-(2*Pi-0)/2*cos((2*2-1)*Pi/(2*4)); |
> | t3:=(2*Pi+0)/2-(2*Pi-0)/2*cos((2*3-1)*Pi/(2*4)); |
> | t4:=(2*Pi+0)/2-(2*Pi-0)/2*cos((2*4-1)*Pi/(2*4)); |
> | c:=evalf(interp([t1,t2,t3,t4],[f(t1),f(t2),f(t3),f(t4)],x)); |
> | gr1:=plot(f(x),x=0..2*Pi,color=red): |
> | gr2:=plot(z,x=0..2*Pi,color=green): |
> | gr3:=plot(c,x=0..2*Pi,color=blue): |
> | display(gr1,gr2,gr3); |
> | with(numapprox); |
> | plot(ChebyshevT(5,x),x=-1..1); |
> |