Kitonum

21460 Reputation

26 Badges

17 years, 47 days

MaplePrimes Activity


These are answers submitted by Kitonum

restart;
Check:=proc(L::list({numeric,symbol}), a)
local n, k, i, P;
n:=nops(L);
k:=0;
for i from 1 to n do
if L[i]=a then k:=k+1; P[k]:=i fi;
od;
if k<>0 then print(yes, convert(P, list)) else no fi;
end proc:

Examples of use:

Check([1,3,5,7,6,5], 5);
Check([1,3,5,7,6,5], 9);
Check([1,a,5,7,6,a], a);


Addition. The procedure works correctly if the list items are numbers (of  numeric  type) or symbols.

Edit.
 

We can find where the derivative is equal to infinity, equating only the first term in the expression for the derivative to infinity, since the remaining terms take only finite values for  x>=0:

f := x -> x^(3/4)-sin(x)+1/2;
D(f)(x);
solve(op(1,D(f)(x))=infinity);
                                                     


Another way (more preferable) is to use  discont  command:

f := x -> x^(3/4)-sin(x)+1/2;
D(f)(x);
discont(%, x);
                                                  

 

Edit.

 

If you need to combine several matrices or / and vectors of the same height horizontally, you can do this as in the example below:

A:=<a,b; c,d>; # Matrix
B:=<e,f>;  # Vector
C:=<g,h>;  # Vector
<A|B|C>;
                                                   

 

 

You can easily find all digits of a natural number in a binary system by successively dividing by 2. Here is the procedure for this:

restart;
Binary:=proc(n::posint)
local q, k, n1, r, L;
q:=infinity;
k:=0; n1:=n;
while q>=1 do
q:=iquo(n1, 2, 'r'); n1:=q; k:=k+1; L[k]:=r;
od:
[seq(L[k-i], i=0..k-1)];
end proc:


Example of use:

Binary(365);
convert(365, base, 2); 
# Check
                                             [1, 0, 1, 1, 0, 1, 1, 0, 1]
                                             [1, 0, 1, 1, 0, 1, 1, 0, 1]

 taro 405  Your solution is correct, except for the slip of the pen (should be  2*x+3*y-z-4  instead of  2*x+3*y-z). Vote up. But the final result is the same. The reason is that the linear transformation is degenerate and translates all the space  R^3  into the points of the plane  x+y+z=0 . But this plane will not always be a solution. If the original plane is parallel to the vector  <-4, 3, 1>, then the solution is not the entire plane  x+y+z=0, but some straight line lying in this plane. Your solution in this case leads to an error (see below).


 

restart;
A:=<<1,1,-2>|<3,4,-7>|<-5,-8,13>>;
A.<x,y,z>; # All the points lie on the plane X+Y+Z=0

Matrix(3, 3, {(1, 1) = 1, (1, 2) = 3, (1, 3) = -5, (2, 1) = 1, (2, 2) = 4, (2, 3) = -8, (3, 1) = -2, (3, 2) = -7, (3, 3) = 13})

 

Vector[column](%id = 18446745846591130310)

(1)

LinearAlgebra:-Eigenvectors(A);

Vector(3, {(1) = 18, (2) = 0, (3) = 0}), Matrix(3, 3, {(1, 1) = -2/5, (1, 2) = -4, (1, 3) = 0, (2, 1) = -3/5, (2, 2) = 3, (2, 3) = 0, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0})

(2)

solve(2*x+3*y-z=4,z); # This plane are parallel to the vector <-4, 3, 1>
vec:=<x,0,0> + <0,y,0> + <0,0,%>;
A:=<<1,1,-2>|<3,4,-7>|<-5,-8,13>>;
B:=A.vec;
C:=solve({X=B[1],Y=B[2]},{x,y});
Z=eval(B[3],C);

-4+2*x+3*y

 

Vector(3, {(1) = x, (2) = y, (3) = -4+2*x+3*y})

 

Matrix(3, 3, {(1, 1) = 1, (1, 2) = 3, (1, 3) = -5, (2, 1) = 1, (2, 2) = 4, (2, 3) = -8, (3, 1) = -2, (3, 2) = -7, (3, 3) = 13})

 

Vector[column](%id = 18446745846595634350)

 

 

Error, invalid input: eval received NULL, which is not valid for its 2nd argument, eqns

 

 


 

Download answer.mw

restart;
eqn := m*`&ell;`^2*(diff(q[1](t), t, t))+k[t]*`&ell;`^2*q[1]+5*k[r]*q[1]-4*k[r]*q[2]+k[r]*q[3]-5*P*`&ell;`*q[1]+2*`&ell;`*P*q[2]+2*`&ell;`*T*q[1]-`&ell;`*T*q[2] = 0:
eqn:=expand(eqn/k[t]/`&ell;`^2);
subs([k[r]=alpha*(k[t]*`&ell;`^2),P=sigma*(k[t]*`&ell;`),T=theta*(k[t]*`&ell;`)], eqn); # Or
expand(%*k[t]);

 

restart;
plot([sin, cos], -Pi .. Pi, title = "Simple Trig Functions", legend = ["Sine Plot", "Cosine Plot"], titlefont = ["ARIAL", 15], labels = ["x values", ` Re`^(`1`/`2`)*C__f], labeldirections = ["horizontal", "vertical"], labelfont = ["HELVETICA", 16], linestyle = [solid, longdash], axesfont = ["HELVETICA", "ROMAN", 16], legendstyle = [font = ["HELVETICA", 9], location = right], tickmarks = [[-Pi = -180^o, -2*Pi*(1/3) = -120^o, -(1/3)*Pi = -60^o, 0 = `0`^o, (1/3)*Pi = 60^o, 2*Pi*(1/3) = 120^o, Pi = 180^o], default]);


Or

restart; 
plot([sin, cos], -Pi .. Pi, title = "Simple Trig Functions", legend = ["Sine Plot", "Cosine Plot"], titlefont = ["ARIAL", 15], labels = ["x values", typeset("Re",``^(`1`/`2`), C__f)], labeldirections = ["horizontal", "vertical"], labelfont = ["HELVETICA", 16], linestyle = [solid, longdash], axesfont = ["HELVETICA", "ROMAN", 16], legendstyle = [font = ["HELVETICA", 9], location = right], tickmarks = [[-Pi = -180^o, -2*Pi*(1/3) = -120^o, -(1/3)*Pi = -60^o, 0 = `0`^o, (1/3)*Pi = 60^o, 2*Pi*(1/3) = 120^o, Pi = 180^o], default]);


Addition. I advise adding 2 options  size=[1000,400], scaling=constrained  and slightly reducing the font size for the axes  (take 14 instead of 16). Then your plot looks better.

See the help on  Finance:-WienerProcess  command.

I took  n<=4 , because I did not understand what the (three) dots mean if  n>=5 .

Y:=(delta,b,n)->piecewise(n=0,1/(1+b^2), n=1,arctan(1/b), n=2,1+ln(b^2 + 1)/2-b*arctan(1/b), n=3,1/2*(2*delta-3*b-2*b*ln(b^2 + 1)/2+arctan(1/b)*(b^2-1)), n=4,(1/36)*(18*delta^2-36*delta*b+33*b^2-11+6*ln(b^2 + 1)/2*(3*b^2-1)+6*b*arctan(1/b)*(3-b^2)));

plot(Y(2,b,4), b=0..10); 
# Example of use
 

From your question, I first learned about  Interpolation  package. But when I tried to deal with his work when working with your examples, the message always appears "Kernel connection has been lost"

All your examples are easy to solve in  CurveFitting  package. Only it is necessary to use an exact arithmetic, otherwise due to rounding errors Maple writes that at the node points  (x=0,1, .. ,10))  the derivative is not defined.

restart;
with(CurveFitting):
points := [seq(x, x = 0 .. 10)]; 
data := [seq(sqrt(1+x^2), x = 0 .. 10)];
f:=unapply(Spline(points, data, x), x);
int(f(x), x = 0 .. 1);
evalf(%); 
eval(diff(f(x), x), x = 2);
evalf(%);
plot(f(x), x = 0 .. 10);
plot([f(x), diff(f(x), x)], x = 0 .. 10);

 

 

Because  is the imaginary unit in Maple, then I use  T  instead. Below we build a table  T  that allows us to find the values  T[i1,i2,i3,i4]  for the indices  [i1,i2,i3,i4] . I think that this is something equivalent to a tensor.

restart;
for i1 from 1 to 3 do
  for i2 from 1 to 3 do
    for i3 from 1 to 3 do
      for i4 from 1 to 3 do
        if i1=i2 and i2=i3 and i3=i4 then
        T[i1,i2,i3,i4]:=1.0;
        else
        T[i1,i2,i3,i4]:=0.0 end if;
        end do:
      end do:
    end do:
  end do:
T:=convert(T, table);
                


Examples of use:

T[1,2,3,4];
T[2,2,2,2];
                                         
 0.
                                          1.


Of course, we can define this much shorter as a function of 4 variables:

T:=(i1,i2,i3,i4)->`if`(i1=i2 and i2=i3 and i3=i4, 1., 0.):

 

Examples of use:

T(1,2,3,4);
T(2,2,2,2);

I replaced  sum  with  add  and got the following result:

restart;
M:=4: N:=2: alpha:=1:
 
add(add(((-1)^i2*GAMMA(N-i2+alpha)*2^(N-2*i2)/(GAMMA(alpha)*factorial(i2)*factorial(N-2*i2)*(N-2*i2+1))*(GAMMA(k+1)*(k+alpha)*GAMMA(alpha)^2/(Pi*2^(1-2*alpha)*GAMMA(k+2*alpha))))*(add((1/2)*(-1)^i*GAMMA(k-i+alpha)*2^(k-2*i)*(1+(-1)^(N-2*i2+1+k-2*i))*GAMMA((1/2)*N-i2+1+(1/2)*k-i)*GAMMA(alpha+1/2)*L[k]/(GAMMA(alpha)*factorial(i)*factorial(k-2*i)*GAMMA(alpha+3/2+(1/2)*N-i2+(1/2)*k-i)), i = 0 .. floor((1/2)*k))), i2 = 0 .. floor((1/2)*N)), k = 0 .. M);

                                               -(1/6)*L[1]+(1/6)*L[3]
                                              

You can easily calculate this using  LinearAlgebra  package (here we have a more compact syntax than the one suggested above):

P1 := [-17/12,11/36,-65/36]:
P5 := [-11/12,-7/36,-47/36]:
P6 := [-2/3,-1/9,-8/9]:
P8 := [-5/4,-1/12,-17/12]:
V1:=convert(P8-P5, Vector);
V2:=convert(P6-P5, Vector);
V3:=convert(P1-P5, Vector);
with(LinearAlgebra):
V1 &x V2 . V3;

 

restart;
A:=proc(x::list)
local N, L;
N:=nops(x);
L:={$1..N};
Matrix(N,(i,j)->`if`(i<>j,mul(x[i]-x[k],k=L minus {i,j})/mul(x[j]-x[k],k=L minus {j}), add(1/(x[i]-x[k]), k=L minus {i})));
end proc:


Example of use:

A([a,b,c,d]);
           

 

 

I've adjusted your syntax a little. Maple finds the exact solution of this equation in a closed form:

restart;
sys[1] := [-(diff(u(x, t), t, t))-(diff(u(x, t), x, x))+u(x, t) = 2*exp(-t)*(x-(1/2)*x^2+(1/2)*t-1), u(x, 0) = x^2-2*x, u(x, 1) = u(x, 1/2)+((1/2)*x^2-x)*exp(-1)-((3/4)*x^2-(3/2)*x)*exp(-1/2), u(0, t) = 0, D[1](u)(1, t) = 0]:
ans:=pdsolve(sys[1]);
pdetest(ans, sys[1]);
plot3d(eval(u(x,t), ans), x=0..2, t=0..2);

             

First 118 119 120 121 122 123 124 Last Page 120 of 290