vv

13832 Reputation

20 Badges

9 years, 317 days

MaplePrimes Activity


These are answers submitted by vv

I always prefer to change myself the coordinates. This way I avoid the two distinct conventions used by Maple for spherical.
As a bonus, I type less!

int(eval((x^2 + y^2)*z, [x=sin(u)*cos(v), y=sin(u)*sin(v), z=cos(u)]) * sin(u), u = 0 .. Pi/2, v = 0 .. 2*Pi);

        Pi/2

 

if type(lhs(ode),`*`) and rhs(ode)=0 then 
  ODE:=select(has, lhs(ode), diff) = 0
fi;

If lhs has a factor depending on y, but has not diff, you may keep it, or solve it for y.

restart;

x[n](t) = x0 + int( f(tau, x[n-1](tau)), tau=t0..t);

x[n](t) = x0+int(f(tau, x[n-1](tau)), tau = t0 .. t)

(1)

# example 1
t0:=0; x0:=1;
f:= (t, x) -> t*x;
x[0]:= t -> x0;

0

 

1

 

proc (t, x) options operator, arrow; x*t end proc

 

proc (t) options operator, arrow; x0 end proc

(2)

for n to 5 do
x[n] := unapply( x0 + int( f(tau, x[n-1](tau)), tau=t0..t),  t);
print(x[n]= x[n](t));
od:

x[1] = 1+(1/2)*t^2

 

x[2] = 1+(1/8)*t^4+(1/2)*t^2

 

x[3] = 1+(1/48)*t^6+(1/8)*t^4+(1/2)*t^2

 

x[4] = 1+(1/384)*t^8+(1/48)*t^6+(1/8)*t^4+(1/2)*t^2

 

x[5] = 1+(1/3840)*t^10+(1/384)*t^8+(1/48)*t^6+(1/8)*t^4+(1/2)*t^2

(3)

# exaplle 2 (x[n], f are vector valued)

t0:=0; x0:=<1,2>;
f:= (t, v) -> <t*v[1], v[2]> ;
x[0]:= t -> x0;

t0 := 0

 

Vector[column](%id = 18446747125427096142)

 

proc (t, v) options operator, arrow; `<,>`(t*v[1], v[2]) end proc

 

proc (t) options operator, arrow; x0 end proc

(4)

for n to 5 do
x[n] := unapply( x0 + int~( f(tau, x[n-1](tau)), tau=t0..t),  t);
print(x[n]= x[n](t));
od:

x[1] = (Vector(2, {(1) = 1+(1/2)*t^2, (2) = 2+2*t}))

 

x[2] = (Vector(2, {(1) = 1+(1/8)*t^4+(1/2)*t^2, (2) = t^2+2*t+2}))

 

x[3] = (Vector(2, {(1) = 1+(1/48)*t^6+(1/8)*t^4+(1/2)*t^2, (2) = 2+(1/3)*t^3+t^2+2*t}))

 

x[4] = (Vector(2, {(1) = 1+(1/384)*t^8+(1/48)*t^6+(1/8)*t^4+(1/2)*t^2, (2) = 2+2*t+(1/12)*t^4+(1/3)*t^3+t^2}))

 

x[5] = Vector[column](%id = 18446747125427074462)

(5)

 

NULL

 

Download Picard_iteration-vv.mw

 

restart;

aa := {{y = -2*X1*X2*alpha[1, 8]*alpha[2, 6]/(sqrt((X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X1*((-2*X1*X2*alpha[3, 6] - 2*X2*alpha[2, 2] + 2*X3)*alpha[2, 6] + X1*X2*alpha[2, 4]*(alpha[2, 8] + alpha[3, 9]))*alpha[1, 8] + X2^2*(alpha[2, 8] + alpha[3, 9])^2)*alpha[1, 8]^2) + alpha[1, 8]^2*alpha[2, 4]*X1^2 + X2*alpha[1, 8]*(alpha[2, 8] + alpha[3, 9])), z = (-sqrt((X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X1*((-2*X1*X2*alpha[3, 6] - 2*X2*alpha[2, 2] + 2*X3)*alpha[2, 6] + X1*X2*alpha[2, 4]*(alpha[2, 8] + alpha[3, 9]))*alpha[1, 8] + X2^2*(alpha[2, 8] + alpha[3, 9])^2)*alpha[1, 8]^2) - alpha[1, 8]^2*alpha[2, 4]*X1^2 + (-alpha[3, 9] - alpha[2, 8])*X2*alpha[1, 8])/(2*alpha[1, 8]^2*alpha[2, 6]*X1)}, {y = -2*X2*alpha[1, 8]*alpha[2, 6]*X1/(-sqrt((X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X1*((-2*X1*X2*alpha[3, 6] - 2*X2*alpha[2, 2] + 2*X3)*alpha[2, 6] + X1*X2*alpha[2, 4]*(alpha[2, 8] + alpha[3, 9]))*alpha[1, 8] + X2^2*(alpha[2, 8] + alpha[3, 9])^2)*alpha[1, 8]^2) + alpha[1, 8]^2*alpha[2, 4]*X1^2 + X2*alpha[1, 8]*(alpha[2, 8] + alpha[3, 9])), z = (sqrt((X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X1*((-2*X1*X2*alpha[3, 6] - 2*X2*alpha[2, 2] + 2*X3)*alpha[2, 6] + X1*X2*alpha[2, 4]*(alpha[2, 8] + alpha[3, 9]))*alpha[1, 8] + X2^2*(alpha[2, 8] + alpha[3, 9])^2)*alpha[1, 8]^2) - alpha[1, 8]^2*alpha[2, 4]*X1^2 + (-alpha[3, 9] - alpha[2, 8])*X2*alpha[1, 8])/(2*alpha[1, 8]^2*alpha[2, 6]*X1)}}:

bb := {{y = -2*X2*alpha[2, 6]*X1/(-sqrt(X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X2*alpha[1, 8]*((alpha[2, 8] + alpha[3, 9])*alpha[2, 4] - 2*alpha[2, 6]*alpha[3, 6])*X1^2 - 4*alpha[1, 8]*alpha[2, 6]*(X2*alpha[2, 2] - X3)*X1 + X2^2*(alpha[2, 8] + alpha[3, 9])^2) + (alpha[2, 8] + alpha[3, 9])*X2 + alpha[1, 8]*alpha[2, 4]*X1^2), z = (sqrt(X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X2*alpha[1, 8]*((alpha[2, 8] + alpha[3, 9])*alpha[2, 4] - 2*alpha[2, 6]*alpha[3, 6])*X1^2 - 4*alpha[1, 8]*alpha[2, 6]*(X2*alpha[2, 2] - X3)*X1 + X2^2*(alpha[2, 8] + alpha[3, 9])^2) - alpha[1, 8]*alpha[2, 4]*X1^2 + (-alpha[3, 9] - alpha[2, 8])*X2)/(2*alpha[1, 8]*alpha[2, 6]*X1)}, {y = -2*X2*alpha[2, 6]*X1/(sqrt(X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X2*alpha[1, 8]*((alpha[2, 8] + alpha[3, 9])*alpha[2, 4] - 2*alpha[2, 6]*alpha[3, 6])*X1^2 - 4*alpha[1, 8]*alpha[2, 6]*(X2*alpha[2, 2] - X3)*X1 + X2^2*(alpha[2, 8] + alpha[3, 9])^2) + alpha[1, 8]*alpha[2, 4]*X1^2 + (alpha[2, 8] + alpha[3, 9])*X2), z = (-sqrt(X1^4*alpha[1, 8]^2*alpha[2, 4]^2 + 2*X2*alpha[1, 8]*((alpha[2, 8] + alpha[3, 9])*alpha[2, 4] - 2*alpha[2, 6]*alpha[3, 6])*X1^2 - 4*alpha[1, 8]*alpha[2, 6]*(X2*alpha[2, 2] - X3)*X1 + X2^2*(alpha[2, 8] + alpha[3, 9])^2) - alpha[1, 8]*alpha[2, 4]*X1^2 + (-alpha[3, 9] - alpha[2, 8])*X2)/(2*alpha[1, 8]*alpha[2, 6]*X1)}}:

aa:=simplify(rationalize(aa)):
bb:=simplify(rationalize(bb)):

indets(aa);

{X1, X2, X3, y, z, alpha[1, 8], alpha[2, 2], alpha[2, 4], alpha[2, 6], alpha[2, 8], alpha[3, 6], alpha[3, 9], ((X1^4*alpha[1, 8]^2*alpha[2, 4]^2+2*X1*((-2*X1*X2*alpha[3, 6]-2*X2*alpha[2, 2]+2*X3)*alpha[2, 6]+X1*X2*alpha[2, 4]*(alpha[2, 8]+alpha[3, 9]))*alpha[1, 8]+X2^2*(alpha[2, 8]+alpha[3, 9])^2)*alpha[1, 8]^2)^(1/2)}

(1)

indets(bb);

{X1, X2, X3, y, z, alpha[1, 8], alpha[2, 2], alpha[2, 4], alpha[2, 6], alpha[2, 8], alpha[3, 6], alpha[3, 9], (X1^4*alpha[1, 8]^2*alpha[2, 4]^2+2*X2*alpha[1, 8]*(-2*alpha[3, 6]*alpha[2, 6]+alpha[2, 4]*(alpha[2, 8]+alpha[3, 9]))*X1^2-4*alpha[1, 8]*alpha[2, 6]*(X2*alpha[2, 2]-X3)*X1+X2^2*(alpha[2, 8]+alpha[3, 9])^2)^(1/2)}

(2)

ra:=indets(aa,radical)[]:
rb:=indets(bb,radical)[]:

simplify(ra^2/rb^2);

alpha[1, 8]^2

(3)

AA:=eval(aa, [ra=R*s*t, alpha[1,8]=t]):  # So, s = +1 or -1

BB:=eval(bb, [rb=R, alpha[1,8]=t]):

simplify( eval(y, AA[1])-eval(y,BB[1]) ), simplify( eval(z, AA[1])-eval(z,BB[1]) );
simplify( eval(y, AA[2])-eval(y,BB[2]) ), simplify( eval(z, AA[2])-eval(z,BB[2]) );

(1/2)*X2*R*(s-1)/(t*((X1*alpha[3, 6]+alpha[2, 2])*X2-X3)), -(1/2)*R*(s-1)/(t*alpha[2, 6]*X1)

 

-(1/2)*X2*R*(s-1)/(t*((X1*alpha[3, 6]+alpha[2, 2])*X2-X3)), (1/2)*R*(s-1)/(t*alpha[2, 6]*X1)

(4)

simplify( eval(y, AA[1])-eval(y,BB[2]) ), simplify( eval(z, AA[1])-eval(z,BB[2]) );
simplify( eval(y, AA[2])-eval(y,BB[1]) ), simplify( eval(z, AA[2])-eval(z,BB[1]) );

(1/2)*X2*R*(s+1)/(t*((X1*alpha[3, 6]+alpha[2, 2])*X2-X3)), -(1/2)*R*(s+1)/(t*alpha[2, 6]*X1)

 

-(1/2)*X2*R*(s+1)/(t*((X1*alpha[3, 6]+alpha[2, 2])*X2-X3)), (1/2)*R*(s+1)/(t*alpha[2, 6]*X1)

(5)

# ==> aa = bb even for complex parameters

 

 

restart;
ic:=[y(0)=0,D(y)(0)=3];
s:=Physics:-Latex(ic, output=string);
s1:=StringTools:-SubstituteAll(s, "D\\left(y \\right)", "y'");   # or,
s2:=StringTools:-SubstituteAll(s, "D\\left(y \\right)", "y^{\\prime}");

 

Try to prove (without Maple) the nice formulae due to G. Polya.

Int(x^(-x), x=0..1) = Sum(n^(-n), n=1..infinity);
Int(x^(x), x=0..1) = Sum((-1)^(n-1)*(n)^(-n), n=1..infinity);

Int(x^(-x), x = 0 .. 1) = Sum(n^(-n), n = 1 .. infinity)

 

Int(x^x, x = 0 .. 1) = Sum((-1)^(n-1)*n^(-n), n = 1 .. infinity)

(1)

evalf([%%,%])

[1.291285997 = 1.291285997, .7834305107 = .7834305107]

(2)

 

JordanForm does non accept numeric matrices containing floats, because the Jordan form is very unstable numericallly (and SingularValues is recommended for numeric tasks).

(Rank is also unstable, but it accepts floats; probably it is considered "less unstable").

Of course it's possible to cheat e.g. JordanForm(A+'sin(0)')  or convert to rationals.

 

@Stretto You want to use your own syntax! Note that Maple already has the operators `--` and `++`.

a:=10: b:=100:
a--+b;  [a,b];
                             a := 9
                              110
                            [9, 100]
 

--  IsZero works for lists too by design
-- HasZero returns false if the argument is not a rtable (and not identical 0) by design
-- AllNonZero returns true if the argument is a list because it returns  not HasZero. Really oversight. 

A simple (but not very efficient) way.

with(GraphTheory):
n := 4: degrees:=[1,2,2,3]:
L:=NonIsomorphicGraphs(n, output=graphs, outputform=adjacency):
map(proc(u) local g:=Graph(u),d:=sort(Degree(g)); `if`(d=degrees,g,NULL) end, [L]);

[GRAPHLN(undirected, unweighted, [1, 2, 3, 4], Array(1..4, {(1) = {4}, (2) = {3, 4}, (3) = {2, 4}, (4) = {1, 2, 3}}), `GRAPHLN/table/8`, 0)]

(1)

print~(DrawGraph~(%))[];

 

 

eq:=x^3 - 3*x^2 + 3*x - 1=0;
op~(solve(eq,[x]))[];

 

If you want the book result (i.e. a submatrix of A) then call LinearAlgebra:-Basis with the list of the column vectors of A.

eq:=(2*x+a^2-3*a)=a*(x-1):
solve(eq,x, parametric);

           

IsElementary:=proc(A::Matrix(square))
  local Z:=rtable_elems(A-1), ij;
  if   nops(Z)=1 then true 
  elif nops(Z)<>4 then false
  elif nops((ij:=lhs~(Z)))=2 and Z = {(ij[])=1, (ij[2],ij[1])=1, (ij[1]$2)=-1, (ij[2]$2)=-1} then true else false fi
end;

 

It's too simple to find a bug here. You must add +Pi

f:=-Pi/2 - arctan(25*x) - Pi + 2*Pi/3:
solve(f,x);
eval(f, x= 1/(25*sqrt(3)) );
solve(f+Pi, x); 
evalf(%) = fsolve(f+Pi,x);

 

First 34 35 36 37 38 39 40 Last Page 36 of 120