vv

12453 Reputation

19 Badges

9 years, 279 days

MaplePrimes Activity


These are answers submitted by vv

a:=5: b:=3:
F := proc(u)
   plots[display](
   plot([sqrt(a^2*cos(u)^2+b^2*sin(u)^2)+ a*cos(t)*cos(u)-b*sin(t)*sin(u),
             sqrt(a^2*sin(u)^2+b^2*cos(u)^2)+ a*cos(t)*sin(u)+b*sin(t)*cos(u), t=0..2*Pi]),
   plot([sqrt(a^2*cos(v)^2+b^2*sin(v)^2),sqrt(a^2*sin(v)^2+b^2*cos(v)^2),v=0..u],color=blue));
end proc:
plots[animate](F, [u], u = 0 .. Pi,  scaling = constrained );

Strangely, if you simply remove the assumptions in your sheet, it works.

To compute the (linear!) fit, you don't need the presence in memory of the vectors X,Y.
It is enugh to have X,Y in a text file (each line containing x_i, y_i)  and read it line by line, e.g.

f:="c:/temp/xy.txt";
A:=Vector(5);B:=Vector(3);
line:=readline(f):
while line<>0 do
x,y:=op(sscanf(line,"%f%f"));
A := A + Vector([1,x,x^2,x^3,x^4]);
B := B + Vector([y,x*y,x^2*y]);
line:=readline(f);
od:
p:= <A[1],A[2],A[3];A[2],A[3],A[4];A[3],A[4],A[5]>^(-1).B:
p[1]+p[2]*t+p[3]*t^2;  # the linear fit (parabola)


You have in two places subs({r=x, s=t} instead of subs({x=r, t=s}.

Note that it is not a good idea to use exclusively ":" instead of ";". You will have no chance to debug the code.

Compute the antiderivative first.

J:=Int((4/3)*t^(3/2)/sqrt(x-t), t = 0 .. x);

int((4/3)*t^(3/2)/sqrt(x-t), t):
J = limit(%,t=x,left) - limit(%,t=0,right) assuming x>0;



Edit. Actually,

value(J) assuming x>0;

also works.

 

 

It is obvious that b should not be allowed to be too large, otherwise the graph may become almost "dense" and will fit any data.

For example, DirectSearch ==>

DataFit(a*sin(b*x+c)+d, [b<=2,b>=0], Vector(X), Vector(Y), x, fitmethod = lms, strategy = globalsearch, method = quadratic);

gave

which seems resonable.

The arctan function seems to be not very "smart".

For example,

arctan( cos(t/2),sin(t/2)) assuming t>0,t<Pi/2;

simplifies to Pi/2 - t/2

but equivalent expressions

arctan( 1+cos(t),sin(t)) assuming t>0,t<Pi/2;

simplify(  arctan( 1+cos(2*t),sin(2*t))  ) assuming t>0,t<Pi/4;

do not.

In such circumstances I think that it would be better to use an inert variant; at least Maple will not try to simplify.

roundcoeffs:=proc(p,x)  local t;
 add(round~([coeffs(p,x,t)]) *~ [t])
end:

p:=3.5*x^2+3.2*x-6.5+88.3*x*y-y^3+a*y:
roundcoeffs(p,[x,y]);

Use

f := unapply(evalf(x^2/(sin(x)+x+1)), x);

 

restart;
f:=(x,y)->evalf(2*x*Int(sqrt(1+y^2*(t*x-1)^2/(1-(t*x-1)^2)), t = 0 .. 1)):
m:=19;n:=9;
G:=Matrix(m*n,3,datatype=float);
k:=0;
for i to m  do   for j to n do
k:=k+1;
G[k,1]:=2*i/(m+1); G[k,2]:=j/(n+1); G[k,3]:=f(2*i/(m+1),j/(n+1))
od od:


f_fit:=a1*x*sqrt(1+y^2*((a2*x-a3)^2/(1-(a4*x-1)^2)));
Statistics[NonlinearFit](f_fit, G, [x, y], initialvalues = [a1 = 1, a2 = 0, a3 = 0, a4=1/2],
output = [leastsquaresfunction, residuals]);
f1:=unapply(%[1],x,y);

printf("x    y    f(x,y)    f_fit(x,y)  \n");    
for x_ from 0.1 to 1.9 by 0.1 do
for y_ from 0.1 to 0.9 by 0.1 do
printf("%2.1f  %2.1f  %6f  %6f\n",x_,y_,f(x_,y_), f1(x_,y_)      );
od; od;

You may replace arcsin by wrongarcsin where:

wrongarcsin := x -> piecewise(x<0, arcsin(x)+2*Pi, arcsin(x));

You may simply "cut" the polynomial, or use:

hor:= (f,x,i) -> numapprox[hornerform](select(u -> degree(u,x)<=i, f) ,x);

f:=add( (10*i+1)*x^i, i=0..6);
hor(f,x,3);

Your notations are not clear (at least for me).

Given the function  g = f(r,theta)*r
you can integrate it in the domain

A = { (r,theta) :  a<= r <= b,  c(r) <= theta <= d(r)}

or

 B = { (r,theta) :  a<= theta <= b,  c(theta) <= r <= d(theta)}.

In the A case, the integral is
int(int(g, theta=c(r)..d(r)), r = a..b);

and similarly for B.

Please rephrase your question in this context.

numtheory[cfrac](3/11+3*sqrt(3),'periodic', 'quotients');

The only possibility I see is to visualize.

E.g. the z-sections using

ee:=subs( [a[1]=x,a[2]=y,a[3]=z], %);
f:=unapply(rhs(ee)-lhs(ee),x,y,z);
Explore(  plots[implicitplot](f(x,y,z)>=0, x=-20..20,y=-20..20,filledregions,numpoints=15000),
parameters = [z=-20..20] );

First 105 106 107 108 109 110 111 Page 107 of 111