vv

13805 Reputation

20 Badges

9 years, 313 days

MaplePrimes Activity


These are answers submitted by vv

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);

 

with(Statistics):

X1 := RandomVariable(Uniform(0,1)): X2 := RandomVariable(Uniform(0,1)):
Y1 := RandomVariable(Uniform(0,1)): Y2 := RandomVariable(Uniform(0,1)):
Dist := sqrt((X1-X2)^2+(Y1-Y2)^2):

f := simplify(PDF(Dist, t));
F := simplify(CDF(Dist, t));

f := -2*t*piecewise(t <= 0, 0, t <= 1, -t^2-Pi+4*t, t <= sqrt(2), (sqrt(t^2-1)*t^2+2*sqrt(t^2-1)*arcsin((t^2-2)/t^2)-4*t^2+2*sqrt(t^2-1)+4)/sqrt(t^2-1), sqrt(2) < t, 0)

 

(1/6)*piecewise(t <= 0, 0, t <= 1, t^2*(3*t^2+6*Pi-16*t), t < 2^(1/2), -12*t^2*arcsin((t^2-2)/t^2)+((-3*t^4-12*t^2+2)*(t^2-1)^(1/2)+16*t^4-8*t^2-8)/(t^2-1)^(1/2), 2^(1/2) <= t, 6)

(1)

plot([f,F], t=0..3);

 

 

Distribution function for the distance between two uniformly distributed random points in the unit square

restart;

 

The density for |x-y|^2 in the unit interval

 

int(piecewise( (x-y)^2<t, 1, 0), [x=0..1,y=0..1]) assuming t>0:

f1 := unapply(simplify(diff(%, t)), t) assuming t>0;

f1 := proc (t) options operator, arrow; piecewise(t <= 1, -(sqrt(t)-1)/sqrt(t), 1 < t, 0) end proc

(1)

 

The density for ||x-y||^2 in the unit square

 

simplify(int( f1(s)*f1(t-s),s=0..t)) assuming t>0:
f2:=unapply(piecewise(t>0,%,0), t);

f2 := proc (t) options operator, arrow; piecewise(0 < t, piecewise(t < 1, Pi-4*sqrt(t)+t, t < 2, -t+4*sqrt(t-1)-2*arcsin((-2+t)/t)-2, 2 <= t, 0), 0) end proc

(2)

 

The cdf for ||x-y||^2  in the unit square

 

simplify(int(f2(s), s=0..t)) assuming t>0:
F2:= unapply(%, t);

F2 := proc (t) options operator, arrow; (1/6)*piecewise(t < 1, -16*t^(3/2)+6*t*Pi+3*t^2, t < 2, -12*arcsin((-2+t)/t)*t+(16*t+8)*sqrt(t-1)-3*t^2-12*t+2, 2 <= t, 6) end proc

(3)

 

The cdf and pdf  for  ||x-y|| in the unit square

 

simplify(F2(t^2)) assuming t>0:
F := unapply(%, t) assuming t>0;
simplify( diff(F2(t^2),t) ) assuming t>0:
f:=unapply(%, t);

F := proc (t) options operator, arrow; (1/6)*piecewise(t < 1, t^2*(3*t^2+6*Pi-16*t), t < sqrt(2), -3*t^4-12*arcsin((t^2-2)/t^2)*t^2+16*sqrt(t^2-1)*t^2-12*t^2+8*sqrt(t^2-1)+2, sqrt(2) <= t, 6) end proc

 

proc (t) options operator, arrow; -2*t*piecewise(t <= 1, -t^2-Pi+4*t, t <= 2^(1/2), ((t^2-1)^(1/2)*t^2+2*arcsin((t^2-2)/t^2)*(t^2-1)^(1/2)-4*t^2+2*(t^2-1)^(1/2)+4)/(t^2-1)^(1/2), 2^(1/2) < t, 0) end proc

(4)

plot(f, 0..2, title="pdf for the distance between 2 points in I^2");

 

plot(F, 0..3, title="cdf for the distance between 2 points in I^2");

 

Note. Unfortunately Maple 2020 fails in computing the quadruple integral needed for a direct solution.

Download dist-points-vv.mw

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