Kitonum

21840 Reputation

26 Badges

17 years, 225 days

MaplePrimes Activity


These are answers submitted by Kitonum

See  wiki  for details.

Example of calculation (norm in the space  C[-1,1]):

restart;
f:=x->x^3-x:
maximize(abs(f(x)), x=-1..1);
                                                       
 2*sqrt(3)*(1/9)

 

NumberTheory:-Totient(n)  returns the number of positive integers coprime to   and not greater than  . See help for details.
 

Addition. Another way:

restart;
with(Physics):
phi:=n->add(KroneckerDelta[igcd(n,k),1], k=1..abs(n)-1);
NumberTheory:-Totient(14);
phi(14);

 


Edit.
 

See  here  about this.

Of cause you can just write  3+1/7 .

Here is an example of the 2 ways to calculate the value of the derivative of a function at a point. Your function can be specified as a procedure or as some expression. In the first case, it is convenient to use the differential operator  , in the second case  eval  command:

restart;
f:=(x,y)->x^2+x*y^3: 
# The function is given as a procedure
g:=x^2+x*y^3:   # The function is given as an expression
D[1](f)(0.5, 1);   # The value of the partial derivative with respect to x at the point
eval(diff(g, x), [x=0.5, y=1]);  # The same
                                                     2.0
                                                     2.0


Below the example of the same error that you have. You can not differentiate by number:

x:=0.5:  y:=1:
diff(g, x);
   
Error, invalid input: diff received .5, which is not valid for its 2nd argument
 

 

I just reduced the domain of the function:

with(plots):

animate(plot3d,[sin(Pi*(t-x))*sin(Pi*y)*Heaviside(t-x)-sin(Pi*(t+x))*sin(Pi*y)*Heaviside(t+x),x=0..4,y=piecewise(x>=0 and x<2,1/2-x/4,0)..piecewise(x>=0 and x<2,1/2+x/4,1)],t=-2*Pi..2*Pi, frames=90);
 

You can do something similar to this simple example:

restart;
for y from 1 to -1 by -0.1 do
sol:=fsolve(exp(x)=y);
if type(sol,numeric)=false then break fi;
od;
y;


As soon as y = 0 the calculation is interrupted.

restart;
f := (x,y)->sin(x)*cos(y):
plot3d(f, 0..2*Pi, 0..2*Pi);
plots:-contourplot(f, 0..2*Pi, 0..2*Pi);


PS. If you want contours with numeric labels, then see this post

restart;
sol := dsolve({(diff(r*(diff(u(r), r)), r))/r = 0, u(R0) = U2, u(h) = U1}, u(r));
plot(eval(rhs(sol), [h = 1, R0 = 5, U1 = 2, U2 = 3]), r = 1 .. 5);

It is much easier to calculate the length of this arc of the ellipse (half of the total ellipse) using its parametric equations:

eqn := (1/32)*(x-16)^2+(1/2025)*(y+0)^2 = 1;
a:=sqrt(32):  b:=sqrt(2025):
int(sqrt(diff(16+a*cos(t),t)^2+diff(b*sin(t),t)^2), t=0..Pi);
evalf(%);
plots[implicitplot]([(1/32)*(x-16)^2+(1/2025)*(y+0)^2 = 1], x = 0 .. 32, y = 0 .. 60, scaling = constrained);

 

To plot arrows, use  plots:-arrow  command, and for text use  plots:-textplot command. See help on these commans for details.

Example of the plotting:

with(plots):
P:=plot([seq(5-a/20*(x+5)^2, a=[1,2,3])], x=-5..3, -2..7, color=[red,blue,green], size=[700,300]):
A1:=arrow([-2,6],[-0.5,-1.85], width=[0.01,relative=false], head_width=[0.07,relative=false], head_length=[0.2,relative=false]):
A2:=arrow([-1.3,6],[-0.5,-1.9], width=[0.01,relative=false], head_width=[0.07,relative=false], head_length=[0.2,relative=false]):
A3:=arrow([-0.6,6],[-0.5,-1.65], width=[0.01,relative=false], head_width=[0.07,relative=false], head_length=[0.2,relative=false]):
T:=textplot([[-0.6,6.4,a=1],[-1.3,6.4,a=2],[-2,6.4,a=3]], font=[times,14]):
display(P,A1,A2,A3,T);

        

Your integral contains a large number of parameters. Integral is easy to calculate if you specify the values of these parameters. Also note that you should not use a variable and an indexed variable  with the same name in the same worksheet (you have d and d[i], x and x[i]).

Example:

restart;
eval(sum(d[i]*ln(x[i]/theta), i = 1 .. 3)/(d1*(sum(ln(x[i]/theta), i = 1 .. 3))^v),[v=2,d1=6,d[1]=1,d[2]=2,d[3]=3,x[1]=1.5,x[2]=2.3,x[3]=3.7]);
int(%, theta=0..2);
                          

 

 

Try this version. In classic GUI of Maple 2017.3 it works:

restart;
with(plots):
with(plottools):
w:=1.5:
lup := line([w,0.9], [w,5.1], color=red, thickness=4):
plt:=plots[implicitplot]((x-1)^4/24+(y-3)^4/10=2, x=w..7, y=0..12,color=red, thickness=4):
op([1,1],plt);
convert(%,listlist):
P:=polygon(%, color=gold):
plots[display]([lup,plt],scaling=constrained);
plots[display]([lup,P,plt],color=gold,scaling=constrained);

 

There are several problems with your code. Firstly,  gamma  is a protected constant in Maple and you must either replace it with another symbol or execute  local gamma;  command. In addition, you have many parameters, so your symbolic expressions swell extremely fast and become completely useless. Therefore, I suggest that all (or almost all) parameters be given numeric values and calculate all numerically (by evalf command).

Example:

restart;
local gamma;
d(0):=1+1*I;
M(0):=1-2*I;
M__s:=1-I; d__s:=2+I; gamma:=3; nu:=4;
for k from 0 to 20 do 
u(k):=evalf(-d(k)/M(k));
p(k+1):=evalf(M__s*u(k)+d__s);
d(k+1):=evalf(d(k)+gamma*p(k+1)/(nu+abs(u(k))^2));
M(k+1):=evalf(M(k)+gamma*p(k+1)*conjugate(u(k))/(nu+abs(u(k))^2));
od;

 

I think that your problem can be effectively solved if the polynomial  P  is specified with numerical coefficients. To obtain a unique solution (of course, up to the sign of  Q  polynomial), we require that the degree of  R  does not exceed  (if the degree of  P  is 2*n) .

Example:

restart;
P := 9*x^4-6*x^3+13*x^2-8*x+5;
Q:=a*x^2+b*x+c:
R:=e*x+f:
T:=Q^2-R;
[seq(coeff(T,x^k)=coeff(P,x^k), k=1..4), tcoeff(T, x)=tcoeff(P)];
solve(%);
                  


PS. Of course, in this example, the polynomial  P is matched specifically to get integer coefficients. In general, as you can see, the problem reduces to solving a polynomial system of  2*n+1 equations with 2*n+1 unknowns.

This equation has only 1 positive root. Negative roots appear due to rounding errors. For negative values near 0, the function strictly decreases and tends to 0, remaining greater than 0 (this is easy to prove, but it is clearly seen from the plot):

restart;
fsolve(-2*sqrt(-K[1]^2+1)*K[1]+4*K[1]^2-Pi-2*arctan(sqrt(-K[1]^2+1)/K[1])=0, K[1]=0..1);
                                               
0.9832314847
 

First 129 130 131 132 133 134 135 Last Page 131 of 292