A matek feladatos topicbeli korilleszteses kerdesre itt egy kod a mapleprimesrol,mivel regsztralos az oldal (by Thomas Schramm):
restart:
#The general equation for a circle is:
Kreis := (x,y)->x^2+y^2-2*a*x-2*b*y-c=0; #ez a kifejtett alak
#A set of [x,y] coordinates for which we might want to fit a circle are:
Px := [6, 3, 9, 2, 5]: Py := [2, 2, 5, 3, 2]:
Punkte := zip((x,y)->[x,y], Px, Py);
#Using this data we construct the corresponding system of equations:
gls := { op( zip( Kreis, Px, Py) ) };
#and solve this over-determined system using:
lsg := linalg[leastsqrs](gls, {a,b,c});
#The radius of the circle is given by:
r := evalf( subs( lsg, sqrt(c + a^2 + b^2) ) );
#Substituting the values for a, b and c into our circle equation, gives the parameteric description of our circle-fit as:
KF := subs(lsg, Kreis(x,y));
#The solution curve (circle) of the implicit equation can be directly plotted using:
g1 := plots[implicitplot]( KF, x=0..10, y=-11..11, thickness=2):
#And the datapoints using:
g2 := plot( Punkte, style=point, symbol=cross, color=blue):
#We display both the data and the circle together.
plots[display]( {g1,g2}, scaling=constrained );