Kitonum

14458 Reputation

24 Badges

11 years, 270 days

MaplePrimes Activity


These are answers submitted by Kitonum

I think that we should not trust to the symbolic solutions of the equations with the parameters obtained with Maple. Here are two simple examples.

with(RealDomain):

solve(sqrt(x-a)=x, x);

solve(a*x^2-2*x+4=0, x);

Both answers are incorrect. The first equation has two solutions only in the range  0 <=a< 1/4 . For other values ​​of the parameter  a  there are no solutions or only one solution. This is easily seen by constructing graphs. 

The solution of the second equation is correct only for  a<>0  and  a<=1/4 .

Both equations can be correctly solved in the package Mathematica. Here, for example, the first example:

Your equation  3a(1+z)^2=2(a(1+z)^3+b)^(1/2)  with two parameters  a  and  b  is much more complex. You can correctly and  explicitly solve it in Mathematica by using commands

ToRadicals[
Reduce[3*a*(1 + z)^2 == 2*(a*(1 + z)^3 + b)^(1/2), z, Reals]]
The output is very cumbersome.

f:= A^2-2*sqrt(A^2+1)+1;

f2:= simplify(algsubs(A^2+1 = M^2,  f)) assuming M>0;

             f := A^2-2*(A^2+1)^(1/2)+1

                     f2 := M^2-2*M

The procedure Routes finds all the routes with a travel length of n in a NxN square and the number of such routes.

Routes:=proc(N::posint, n::nonnegint)

local L, Rule; global T;

if n>=N^2 then T:=[]: print(0);   else

L:=[seq(seq([[i, j]], j=1..N), i=1..N)];

 

Rule:=proc(K)  # Continuation of the route by 1 step

local S, k, M, r, p;

S:=[ ]; k:=nops(K[1]);

for r in K do

M:=[ ]:

if r[k]=[1, 1] then for p in [[1, 2], [2, 2], [2, 1]] do  # Bottom left corner

if convert([seq(r[i]<>p, i=1..k-1)], `and`) then M:=[op(M),[op(r), p]]: fi:

od:

S:=[op(S), op(M)]: fi:

if r[k]=[1, N] then for p in [[1, N-1], [2, N-1], [2, N]] do  # Top left corner

if convert([seq(r[i]<>p, i=1..k-1)], `and`) then M:=[op(M),[op(r), p]]: fi:

od:

S:=[op(S), op(M)]: fi:

if r[k]=[N, N] then for p in [[N-1, N], [N-1, N-1], [N, N-1]] do  # Top right corner

if convert([seq(r[i]<>p, i=1..k-1)], `and`) then M:=[op(M),[op(r), p]]: fi:

od:

S:=[op(S), op(M)]: fi:

if r[k]=[N, 1] then for p in [[N-1, 1], [N-1, 2], [N, 2]] do  # Bottom right corner

if convert([seq(r[i]<>p, i=1..k-1)], `and`) then M:=[op(M),[op(r), p]]: fi:

od:

S:=[op(S), op(M)]: fi:

if r[k,1]=1 and r[k,2]<>1 and r[k,2]<>N then for p in [[1, r[k,2]-1], [2, r[k,2]-1], [2, r[k,2]-1], [2, r[k,2]+1], [1, r[k,2]+1]] do                      # Left side

if convert([seq(r[i]<>p, i=1..k-1)], `and`) then M:=[op(M),[op(r), p]]: fi:

od:

S:=[op(S), op(M)]: fi:

if r[k,2]=N and r[k,1]<>1 and r[k,1]<>N then for p in [[r[k,1]-1, N], [r[k,1]-1, N-1], [r[k,1], N-1], [r[k,1]+1, N-1], [r[k,1]+1, N]] do                    # Top side

if convert([seq(r[i]<>p, i=1..k-1)], `and`) then M:=[op(M),[op(r), p]]: fi:

od:

S:=[op(S), op(M)]: fi:

if r[k,1]=N and r[k,2]<>1 and r[k,2]<>N then for p in [[N, r[k,2]+1], [N-1, r[k,2]+1], [N-1, r[k,2]], [N-1, r[k,2]-1], [N, r[k,2]-1]] do                    # Right side

if convert([seq(r[i]<>p, i=1..k-1)], `and`) then M:=[op(M),[op(r), p]]: fi:

od:

S:=[op(S), op(M)]: fi:

if r[k,2]=1 and r[k,1]<>1 and r[k,1]<>N then for p in [[r[k,1]-1, 1], [r[k,1]-1, 2], [r[k,1], 2], [r[k,1]+1, 2], [r[k,1]+1, 1]] do                    # Bottom side

if convert([seq(r[i]<>p, i=1..k-1)], `and`) then M:=[op(M),[op(r), p]]: fi:

od:

S:=[op(S), op(M)]: fi:

if r[k,1]<>1 and r[k,1]<>N and r[k,2]<>1 and r[k,2]<>N then for p in [[r[k,1]-1, r[k,2]-1], [r[k,1]-1, r[k,2]], [r[k,1]-1, r[k,2]+1], [r[k,1], r[k,2]+1], [r[k,1]+1, r[k,2]+1], [r[k,1]+1, r[k,2]], [r[k,1]+1, r[k,2]-1], [r[k,1], r[k,2]-1]] do  # Inside

if convert([seq(r[i]<>p, i=1..k-1)], `and`) then M:=[op(M),[op(r), p]]: fi:

od:

S:=[op(S), op(M)]: fi:

od;

S;

end proc;

 

T:=(Rule@@n)(L);  # List of all the routes

nops(T);  # Number of all the routes

fi;

 

end proc;


Example:

Routes(4, 6);

T[10000]; T[20000]; T[60000];

 

See http://www.mapleprimes.com/questions/142417-Generating-Matrix-Code

In your recurrence equation, that to find all  U[i+1, j+1]  need to know the values ​​of the previous two rows and two columns.

solve(r*U[i-1,j+1] -2*r*U[i,j+1] +r*U[i+1,j+1] = r*U[i-1,j] -2*r*U[i,j] +r*U[i+1,j], U[i+1,j+1]);

 
 Therefore, in the matrix must be specified the first two rows and columns.

Formal arguments of the procedure:  L1, L2, M1, M2 - the first two rows and the first two columns of the matrix.
Code of the procedure:

P:=proc(L1, L2, M1, M2)

local f, n, i, j, U;

f:=(i, j) -> U[i-1,j]-2*U[i,j]+U[i+1,j]-U[i-1,j+1]+2*U[i,j+1];

n:=nops(L1);

for i from 1 to n do

U[1, i]:=L1[i]; U[2, i]:=L2[i]; U[i, 1]:=M1[i]; U[i, 2]:=M2[i];

od;

for i from 2 to n-1 do

for j from 2 to n-1 do

U[i+1, j+1]:=f(i,j);

od; od;

Matrix([seq([seq(U[i, j], j=1..n)], i=1..n)]);

end proc; 


Example:

P([1, 3, 4, 4.5, 4.75],[3, 5, 6, 6.5, 6.75], [1, 3, 4, 4.5, 4.75], [3, 5, 6, 6.5, 6.75]);

The number  e  is coded in Maple as  exp(1) . If you are used to the traditional designation, at first you must to assign to the symbol  e  this value or use a palette:

e:=exp(1):
evalf(e);

2.718281828

To the 1st question:

restart;

f:=x->piecewise((x>=0.19740 and x<0.91510) or (x>=3.3390 and x<4.0567), tan(x), undefined);

plot(f(x), view=[-1..5, -0.5..1.5], scaling=constrained);


To the 2nd question:

restart;

solve({ 0.2 <= tan(x), tan(x)< 1.3, x>0, x<Pi});

plot(tan(x), x=lhs(%[1])..rhs(%[2]));

You can easily build the new graph as a parametrically defined curve (see ?plot/details):

restart;

x, y, m, n:=1, 2, 3, 4:

sol:=dsolve({(D(a))(t) = x-y*a(t), (D(b))(t) = m*a(t)-n*b(t), a(0)=0, b(0)=0.5}, {a(t), b(t)}):

a:=unapply(rhs(sol[1]), t):

b:=unapply(rhs(sol[2]), t):

h:=unapply(60/0.98 * a(t)*b(t), t):

plot([a(t), h(t), t=0..10], thickness=2, labels=["a(t)", "h(t)"]);

Replace the square brackets by round brackets:

(24+24*beta[1]*x+24*beta[2]*x^2+24*beta[3]*x^3+24*beta[4]*x^4)+(2*(beta[1]+2*beta[2]*x+3*beta[3]*x^2+4*beta[4]*x^3))*(-24+24*x)+(2*beta[2]+6*beta[3]*x+12*beta[4]*x^2)*(12-24*x+12*x^2)-L^4*m[0]*Omega^2*(-(1/2)*x^2-R*x+R+1/2)*(12-24*x+12*x^2)/EI[0]-F*L^2*(12-24*x+12*x^2)/EI[0]-L^4*m[0]*Omega^2*(-x-R)*(12*x-12*x^2+4*x^3)/EI[0]-L^4*m[0]*omega^2*(6*x^2-4*x^3+x^4)/EI[0];

collect(%, x);

To solve the problem you need to determine the values ​​of all the parameters, specify the initial conditions and assign names to the found solutions.

Example:

restart;

x, y, m, n:=1, 2, 3, 4:

sol:=dsolve({(D(a))(t) = x-y*a(t), (D(b))(t) = m*a(t)-n*b(t), a(0)=0, b(0)=0.5}, {a(t), b(t)});

a:=unapply(rhs(sol[1]), t);

b:=unapply(rhs(sol[2]), t);

plot(60/0.98 * a(t)*b(t), t=0..10, labels=["t", "h(t)"]);

In my code, I relied on your formula, in which the number  n  determines the size of the segment of the boundary value problem and the number of parts into which divided this segment. If we divide these two parameters, we obtain a slightly more general problem. The number  theta can also be considered discretely as in your formula, and it can more accurately be considered by the integral, if your last formula to the limit as  n  tends to infinity. In the example below 0.001 step corresponds to the division of the interval from 0 to 3 per 3000 parts:

restart;

a:=3:  n:=3000:

ode:=diff(T(x),x$2)-T(x)^2=0;

bc:=T(0)=1,T(a)=0;

V:=dsolve({ode, bc}, numeric):

AverageT:=evalf(Int(x->rhs(V(x)[2]), 0..a))/a;

`T`:=[seq(rhs(V(x)[2]), x=a/n..a, a/n)]:

Int_theta:=evalf(sqrt(Int(x->(rhs(V(x)[2])-AverageT)^2, 0..a)/a)/AverageT);

theta:=sqrt(add((`T`[i]-AverageT)^2, i=1..n)/(n-1))/AverageT;

 

If   increases, the theta will be close to  Int_theta .

restart;

n:=3:

ode:=diff(T(x),x$2)-T(x)^2=0;

bc:=T(0)=1,T(n)=0;

V:=dsolve({ode, bc}, numeric);

AverageT:=evalf(Int(x->rhs(V(x)[2]), 0..3))/n;

`T`:=[seq(rhs(V(x)[2]), x=1..3, 1)];

theta:=sqrt(add((`T`[i]-AverageT)^2, i=1..3)/(n-1))/AverageT;

Solution by substitution  x-1=t^2 :

eq1:=sqrt(x+3-4*sqrt(x-1))+sqrt(x+8-6*sqrt(x-1))=1:

eq2:=x-1=t^2:

simplify(algsubs(eq2, eq1)) assuming t>=0;

sol:=solve(%);

L:=convert(sol, list);

x:=unapply(solve(eq2, x), t);

RealRange(x(L[1]), x(L[2]));  # All roots of the initial equation

 

Of course, after the equation is solved with respect to  t , it is easier to solve it by hand for  x , using the equality x=1+t^2

On the solution of discrete optimization problems, see ?DirectSearch[Search].

Solution of the problem:

The example shows that the solution of such problems with DirectSearch package is not effectively.

integer.mw

Your problem is easily solved by exhaustive search. Denoted by  a, b, c, d, e, f, g, h  vertices of the cube:

Code:

L:=combinat[permute]({seq(i^2, i=1..8)}):

n:=infinity: S:={}:

for i in L do

a, b, c, d, e, f, g, h := i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]:

m := a*b+b*c+c*d+a*d+a*e+b*f+c*g+d*h+e*f+f*g+g*h+e*h: S:=S union {m}:

if m<n then n:=m:

M:=[m, ["a"=a, "b"=b,"c"= c, "d"=d, "e"=e, "f"=f, "g"=g, "h"=h]]:  fi:

od:

S:  # The set of all possible values of this sum 

nops(S);

max(S);

min(S);

M; 


622

9420

3586 

[3586, ["a" = 1, "b" = 36, "c" = 9, "d" = 64, "e" = 49, "f" = 16, "g" = 25, "h" = 4]]


First 207 208 209 210 211 212 213 Last Page 209 of 227