8125 Reputation

17 Badges

8 years, 228 days

MaplePrimes Activity

These are answers submitted by Kitonum

The most general way to specify a transformation in  R^2  or  R^3  is  plottools:-transform  command. In the following example, the unit circle is rotating by 90 degrees and simultaneously is reducing by 2 times:

f:=t->plottools:-transform((x,y)->convert(<cos(t),-sin(t); sin(t),cos(t)>.(<2,0>+(1-t/Pi)*(<x,y>-<2,0>)), list)):
A:=plots:-implicitplot((x-2)^2+y^2-1, x=-1..3, y=-1..3, color=red, thickness=2):
plots:-animate(plots:-display, ['f(t)'(A)], t=0..Pi/2, frames=100, scaling=constrained);





cycfunc:=proc(Expr, vars)
local n, P;
P:=[seq([seq(vars[j], j=i..n), seq(vars[j], j=1..i-1)], i=1..n)];
if `and`(seq(Expr=subs(`=`~(vars, p), Expr), p=P)) then return true else false fi;
end proc:


Example of use:

cycfunc(a^2*b + b^2*c + c^2*a, [a,b,c]);



Here is the procedure for finding the minimum and the value of the variable  x  in which it is achieved (the nearest to a) according to your plan:

P:=proc(Expr, a, b, n)
local X, Y, m, i;
X:=[seq(a+k*(b-a)/n, k=0..n)];
Y:=[seq(eval(Expr,x=t), t=X)];
for i from 1 to n+1 do
if Y[i]=m then return [X[i], m]  fi;
end proc:


Example of use:

P(x^2-3*x+5, 0, 10, 100);
                                                               [3/2, 11/4]




f := x->0.012981+0.080285*cos(0.9519256799*x)+0.041370*cos(1.903851360*x)+
RootFinding:-Analytic(diff(f(x), x) = 0, x, re = -6 .. 6, im = -0.1 .. 0.1);
sort(simplify([%], zero));  
# Sorted list of all the extreme points

[-5.080827670, -4.391753823, -3.300249925, -2.208746026, -1.519672179, 0., 1.519672179, 2.208746026, 3.300249925, 4.391753823, 5.080827670]

Addition. If you need the coordinates of the points in a plane with an indication of the type of extremum it can be done as follows:

f := x->0.012981+0.080285*cos(0.9519256799*x)+0.041370*cos(1.903851360*x)+
RootFinding:-Analytic(diff(f(x), x) = 0, x, re = -6 .. 6, im = -0.1 .. 0.1):
sort(simplify([%], zero)):  
# Sorted list of all the extreme points
map(t->[`if`((D@@2)(f)(t)>0, Min, Max), [t, f(t)] ], %);  # These points in the plane

[[Min, [-5.080827670, -0.03003674673]], [Max, [-4.391753823, -0.01222338857]], [Min, [-3.300249925, -0.061477]], [Max, [-2.208746026, -0.01222338856]], [Min, [-1.519672179, -0.03003674679]], [Max, [0., 0.170473]], [Min, [1.519672179, -0.03003674679]], [Max, [2.208746026, -0.01222338856]], [Min, [3.300249925, -0.061477]], [Max, [4.391753823, -0.01222338857]], [Min, [5.080827670, -0.03003674673]]]

M := plottools:-arc([0, 0], 1, (1/6)*Pi .. 3*Pi*(1/4), color = blue, thickness = 4):
A:=plots:-display(plot(op(M)[1], color = "DeepPink", filled, scaling = constrained), M);
plots:-display(f(A), scaling=constrained, axes=normal, view=[-1..1,0..1,0..0.5]);


Addition. Here is another way for 3d:

Arc:=plots:-spacecurve([x,sqrt(1-x^2),0], x=-1/sqrt(2)..sqrt(3)/2, color=blue, thickness=3):
B:=plot3d([x,y,0], x=-1/sqrt(2)..sqrt(3)/2,y=0..sqrt(1-x^2), style=surface, color = "DeepPink", scaling = constrained, axes=normal, view=[-1..1,0..1,0..0.5]):


To investigate the dependence of the tangent field of a differential equation of a parameter, you can use  Explore  command:

Explore(DEtools:-DEplot(diff(y(x),x) = sqrt(1+(a*x)+(2*y(x))),y(x), x=-2..2, y=0..1), a=-2...2.);


Your function can not be expanded in powers  q  and  m  (ie, in the neighborhood of [0,0]) because q->sqrt(q)  is not differentiable at the point q=0 (the derivative equals infinity) but can be expanded for example in the neighborhood of [1,0] :

mtaylor(tanh(B*J*sqrt(q)*z+B*Jo*m), [q=1, m=0], 9);

Obviously this is the series for the function  y->a*cos(sqrt(beta)*y)  (a  and  beta  are parameters) in the neighborhood  y=0

A check:

series(a*cos(sqrt(beta)*y), y = 0, 25);






Probably you mean a hexagonal prism?

f:=piecewise(x>-1 and x<-1/2, sqrt(3)*(x+1), x>=-1/2 and x<=1/2, sqrt(3)/2, x>1/2, -sqrt(3)*(x-1)):
plot3d(2, x=-1..1, y=-f..f, style=surface, color=khaki, filled);




X:=[0, 1, 2, 3, 4]:
Y:=[1, 2, 2.5, 4, 3]:
plot(X, Y);

If you would like to curve was smoother, use  CurveFitting:-Spline  command (see help for details)


Addition. Here is a smooth curve through the same 5 points:

evalf[3](CurveFitting:-Spline(X,Y, x));
plot(%, x=0..4);


If I understand your problem properly then use  view  option (below is the changed the last line of your code):

display(f1, g1, view = [0.8 .. 1.2, 0 .. 0.4]);





The problem is easy to solve, if we note that  abs(x1-x2)  is the distance between the points with the coordinates  x1  and  x2  on the real axis.

a:=0: b:=1.6: c:=4: d:=4.4:
f:=convert(abs(x-b)+abs(a-x)+abs(x-a)+abs(d-x)+abs(b-d), fraction):
minimize(f, x=0..convert(d, fraction));
plot(f, x=0..d, 0..15);  
# Visual check


We see that the problem has no unique solution. The variable  x  can vary in the range  0 .. 1.6



acer here gave a partial solution of the problem. Below the full solution is given

assume(n, posint):
x:=r*cos(t):  y:=r*sin(t):
r1:=eval(r,n=2):  r2:=eval(r,n=4):
plots:-display(<plots:-display(plot(r1, t=0..2*Pi, coords=polar, color=red), plot(r2, t=0..4*Pi, coords=polar, color=blue), title="Red curve for n=2, blue curve for n=4")| plots:-display(plot(r1, t=0..2*Pi, coords=polar, color=red), plot(r2, t=0..4*Pi, coords=polar, color=blue), view=[-0.05..0.05,-0.05..0.05], title="Zoom 20:1 near the origin")>, scaling=constrained);  # The plots of the curves for n=2 and n=4
PP1:=seq(simplify(convert([r1*cos(t),r1*sin(t)],radical)),t=[Pi/4,3*Pi/4]);  # 2 points on the first curve 
PP2:=seq(simplify([r2*cos(t),r2*sin(t)]),t=[Pi/3,Pi/2]);  # 2 points on the second curve 
P:=eval({[r1*cos(t),r1*sin(t)],[r2*cos(t),r2*sin(t)]}, t=0)[]; # The common point
Int(eval([sqrt('diff(x(t),t)'^2+'diff(y(t),t)'^2),t=0..n*Pi],n=4)[])=int(eval([sqrt(diff(x,t)^2+diff(y,t)^2),t=0..n*Pi],n=4)[]);  # The length of the curve for n=4
A:=op(trigsubs(numer(%)))/op(trigsubs(denom(%))); # This is simplified dy/dx
B:=(normal@expand)~(%);  # This is the desired form for dy/dx
sol:=solve(denom(A)=0, t, allsolutions);  # The formula for all the solutions
indets(%)[1]: # The name of a parameter in the set of all the solutions
h:=subs(%=1, sol);  # The smallest positive solution
n*Pi/h;  # The number of solutions in the range 0<=t<n*Pi 



Because all solutions are equally spaced, then the number of solutions is equal to the quotient of devision the  length of the interval by the smallest positive solution


In fact, these expressions are identical. See

A:=(sin(t)*sin(t/n)-cos(t)*cos(t/n)) /(sin(t)*cos(t/n)+cos(t)*sin(t/n));

Output of the last command is  .


ff := t->plots:-display(plottools:-point([cos(t), sin(t), t], colour = red, symbolsize = 50, symbol = solidsphere));
plots:-animate(ff,[t], t=0..4*Pi, frames=100);


unapply causes an error due to premature calculation.


1 2 3 4 5 6 7 Last Page 1 of 123