Kitonum

21455 Reputation

26 Badges

17 years, 47 days

MaplePrimes Activity


These are answers submitted by Kitonum

A:=sqrt((1-b/r)^(-1));
B:=expand(op(1,A));
sqrt(``(expand(numer(B)*(-1)/``(denom(B)*(-1)))));

 

It seems that the syntax of  dsolve  command simply does not provide a vector input form. But the problem is easily solved by reducing to the standard syntax.

Example:

X:=t-><x1(t),x2(t)>:
A:=t-><1,3; 2,5>:
X0:=<1,2>:
Sys:=map(p->convert(p,list)[], {diff(X(t),t)=~A(t).X(t), X(0)=~X0});
dsolve(Sys, {x1(t),x2(t)});

 

r:=rand(-1...1.):

Examples of use:
X:=seq(r(), i=1..10);
Y:=seq(r(), i=1..10);


Addition:

In old versions of Maple do:

r:=()->RandomTools:-Generate(float('range' = -1 .. 1., 'method' = 'uniform')):

 

limit((u^m-v^m)/(u-v), u=v);
simplify(%);

Conversion to sum is easy to make for a specific  m , for example:
expand(factor((u^10-v^10)/(u-v)));


Addition. 1. Conversion to one side (from sum to closed form):
restart;
sum(u^(m-1-i)*v^i, i = 0 .. m-1);
simplify(%, symbolic);

2. For reverse conversion, you can use a special procedure (see the code and examples below). The expression must be entered in the form similar to  (u^m-v^m)/(u-v) . u, v  and  m   can be both symbols and/or numbers (if m is number then should be  m>1). To avoid premature calculations (in the case of numbers), pay attention to their correct input (see examples).

restart;
SpecialConv:=expr->Sum(expand(op([1,1,1],expr))^(op([1,1,2],expr)-1-i)*expand(op([1,2,2,1],expr))^i, i=0..op([1,1,2],expr)-1):

Examples of use:
SpecialConv((a^n-b^n)/(a-b));
SpecialConv((5^n-2^n)/``(5-2));
SpecialConv((a^10-b^10)/(a-b));
value(%);
SpecialConv((``(5)^10-``(2)^10)/``(5-2));
SpecialConv((a^10-``(2)^10)/(a-2));


Edit.

 

Try this:

RealInt := proc(f, x)
local A, B;
A:=int(f, x);
B:=applyrule(ln(a::anything)=ln(abs(a)), A);
simplify(B) assuming real;
end proc:

Examples of use:
RealInt(1+1/x, x);
RealInt(1/sin(x), x);
RealInt(x/(x^2+1), x);
RealInt(tan(x), x);
RealInt(diff(f(x),x)/f(x), x);
RealInt(1+1/abs(x), x);
RealInt(1/x, x) assuming x<0;

 

Eq1 := [(1/2)*(R[b]*kh[a2]+R[m]*kh[a2]-Rh[m]*kh[a2]+sqrt(R[b]^2*kh[a2]^2+2*R[b]*R[m]*kh[a2]^2-2*R[b]*Rh[m]*kh[a2]^2+R[m]^2*kh[a2]^2-2*R[m]*Rh[m]*kh[a2]^2+Rh[m]^2*kh[a2]^2))/kh[a2] = 0, 0 = 0, -(1/2)*(R[b]*kh[a2]+R[m]*kh[a2]-Rh[m]*kh[a2]+sqrt(R[b]^2*kh[a2]^2+2*R[b]*R[m]*kh[a2]^2-2*R[b]*Rh[m]*kh[a2]^2+R[m]^2*kh[a2]^2-2*R[m]*Rh[m]*kh[a2]^2+Rh[m]^2*kh[a2]^2))/kh[a2] = 0]:
simplify(Eq1) assuming kh[a2]>0, R[b]+R[m]-Rh[m]>=0 ;
simplify(Eq1) assuming kh[a2]<0, R[b]+R[m]-Rh[m]<=0 ;
                         
   [R[b] + R[m] - Rh[m] = 0, 0 = 0, Rh[m] - R[b] - R[m] = 0]
                            [R[b] + R[m] - Rh[m] = 0, 0 = 0, Rh[m] - R[b] - R[m] = 0]
 

We see that the expected result is correct if  kh[a2]  and  R[b]+R[m]-Rh[m]  have the same signs.
In the general case  in real domain  we have  sqrt(a^2*b^2)=abs(a*b) .

Edit.

restart;
f:=x->x^2:
A:=plot(f(x), x=0..2.5, color=blue, thickness=2, labels=[x, f(x)]):
T:=plots:-textplot([2.4,f(2), typeset("(",2,",",f(2),")")], font=[times,16]):
P:=plot([[2,f(2)]], style=point, color=red, symbol=solidcircle, symbolsize=15):
L:=plot([[2,t,t=0..f(2)], [t,f(2),t=0..2]], linestyle=2, color=black):
plots:-display(A, T, P, L, scaling=constrained, size=[300,500]);

The result:
                     


Edit.

     

If I correctly understood the question, then a simple procedure solves the problem:

restart;
f:=diff(ChebyshevT(n, r), r):
g:=unapply(simplify(eval(f, r = 0)), n):
seq(g(n), n=1..20);
piecewise(seq(op([n=k,g(k)]), k=1..20));
# In the form of piecewise


Addition. If, as indicated by Preben to use separate formulas for these cases (even  and  odd), then piecewise form can be written in a general form and shorter:

g:=n->piecewise(n::even, 0, n::odd, n*(-1)^((n-1)/2));
seq(g(n), n=1..20); 
# Example of use

If we are interested in the set of all roots of some nonlinear equation, then the examples (OP's and vv's) show that we can not fully trust both  solve  command and fsolve and RootFinding:-Analytic  commands (the last two work in restricted intervals). Therefore, some qualitative analysis of the equation in question (even before its solution) is always useful, which concerns the existence and uniqueness of its roots. The simplest way to do this is to plot the corresponding function. Of course, the graph does not prove anything, but it allows you to notice some properties of the function, which you can then try to prove rigorously. In the example with OP's equation, it is easy to see the monotonicity of the function (it strictly increases). The analysis of the derivative shows that the function actually increases strictly on the whole real axis. Therefore, the equation can not have more than one real root. Since at the ends of the segment  [10, 20]  the function takes values ​​of different signs, the real root exists and it is unique:


 

restart;
f:=x->sqrt(3)*arctan(x/sqrt(3))-arctan(x)-1;
plot(f(x), x=-10..30);
simplify(diff(f(x), x));  # The derivative is positive
evalf([f(10), f(20)]);
fsolve(f(x), x=10..20);

proc (x) options operator, arrow; sqrt(3)*arctan(x/sqrt(3))-arctan(x)-1 end proc

 

 

2*x^2/((x^2+3)*(x^2+1))

 

[-0.47481496e-1, 0.50234438e-1]

 

13.24164500

(1)

 


 

Download root.mw

f:=piecewise( x<5, 100, x>5,200):
M:=maximize(f, x=0..10);
plot(f, x=0..10, y=0..M);

 

You specified the expression  f1  that depends on two variables  x1  and  x2 . If I understand correctly, then it is necessary to find the values of variables for which this expression is minimal. This task is easily solved by  minimize  command with  location  option:

minimize(8.044048-0.764286*x1-0.756746*x2+0.034524*x1^2+0.022222*x2*x1+0.098413*x2^2, location);  # The code
          3.126413413, {[{x1 = 10.20224318, x2 = 2.692895003}, 3.126413413]}  # The result

So the answer  x1 = 10.20224318, x2 = 2.692895003

 

 

Maple does not solve systems of this type:


 

"restart:alpha:=1:beta1:=2:beta2:=3:beta3:=4:h:=1:L:=5:xi:=6:beta:=4:f1(x):=1/(cos^(2)(x)):f2(x):=1/(sin^(2)(x)+x^(4)):g(x):=1/(cos^(4)(x)):  "

 
pd1 := -alpha*beta^2*(diff(p1(x, z), x, x))-alpha*beta1^2*(diff(p3(x, z), x, z))-alpha*beta2^2*(diff(p1(x, z), z, z))-alpha*beta3*(diff(p3(x, z), x, z))+alpha*p1(x, z)+diff(Phi(x, z), z) = f1(x)+z*f2(x)

-16*(diff(diff(p1(x, z), x), x))-8*(diff(diff(p3(x, z), x), z))-9*(diff(diff(p1(x, z), z), z))+p1(x, z)+diff(Phi(x, z), z) = 1/cos(x)^2+z/(sin(x)^2+x^4)

(1)

pd2 := -alpha*beta1^2*(diff(p1(x, z), x, z))-alpha*beta^2*(diff(p3(x, z), z, z))-alpha*beta2^2*(diff(p3(x, z), x, x))-alpha*beta3^2*(diff(p1(x, z), x, z))+alpha*p3(x, z)+diff(Phi(x, z), z) = g(x)

-20*(diff(diff(p1(x, z), x), z))-16*(diff(diff(p3(x, z), z), z))-9*(diff(diff(p3(x, z), x), x))+p3(x, z)+diff(Phi(x, z), z) = 1/cos(x)^4

(2)

pd3 := -xi*(diff(Phi(x, z), x, x)+(diff(Phi(x, z), x, x)))+diff(p1(x, z), x)+diff(p3(x, z), z) = 0

-12*(diff(diff(Phi(x, z), x), x))+diff(p1(x, z), x)+diff(p3(x, z), z) = 0

(3)

 

BCS := Phi(0, z) = 0, Phi(L, z) = 0, Phi(x, 0) = 0, Phi(x, h) = 0, p1(0, z) = 0, p1(L, z) = 0, p1(x, 0) = 0, p1(x, h) = 0, p3(0, z) = 0, p3(L, z) = 0, p3(x, 0) = 0, p3(x, h) = 0

Phi(0, z) = 0, Phi(5, z) = 0, Phi(x, 0) = 0, Phi(x, 1) = 0, p1(0, z) = 0, p1(5, z) = 0, p1(x, 0) = 0, p1(x, 1) = 0, p3(0, z) = 0, p3(5, z) = 0, p3(x, 0) = 0, p3(x, 1) = 0

(4)

pdsolve({pd1, pd2, pd3}, {BCS}, numeric);

Error, (in pdsolve/numeric) unable to handle elliptic PDEs

 

``


Addition: if we try to solve symbolically, Maple returns  NULL :

pdsolve([pd1, pd2, pd3, BCS], [p1(x, z), p3(x, z), Phi(x, z)]);
# NULL

 

Download 1_(2)_new.mw

For the solution, I used formulas for linear shooting method from the wiki


 

restart;
a,b:=0,Pi/2:
A,B:=-0.3,-0.1:
h:=Pi/8:  n:=(b-a)/h:
eq:=diff(y(x),x,x)=diff(y(x),x)+2*y(x)+cos(x):
Sol1:=dsolve({eq,y(a)=A,D(y)(a)=0}, numeric, method=classical[rk4], stepsize = h, output=Array([seq(a+h*k,k=0..n)]));
V1:=Sol1[2,1][..,2];
Sol2:=dsolve({eq,y(a)=0,D(y)(a)=1}, numeric, method=classical[rk4], stepsize = h, output=Array([seq(a+h*k,k=0..n)]));
V2:=Sol2[2,1][..,2];
X:=<seq(a+h*k,k=0..n)>;
Y:=V1+(B-V1[n+1])/V2[n+1]*V2;
exact_sol:=-1/10*(sin(x)+3*cos(x)):
plots:-display([plot(X,Y, color=blue),plot(exact_sol, x=a..b, color=red)], legend=[approx,exact]);

Vector(2, {(1) = Vector[row](3, {(1) = x, (2) = x, (3) = x}), (2) = Matrix(5, 3, {(1, 1) = 0., (1, 2) = -.3, (1, 3) = 0., (2, 1) = .392699081698724, (2, 2) = -.26501582080640973, (2, 3) = .19072466773312516, (3, 1) = .785398163397448, (3, 2) = -.13839484230713406, (3, 3) = .4758230356504398, (4, 1) = 1.17809724509617, (4, 2) = .1321628119977024, (4, 3) = .9482820251563483, (5, 1) = 1.57079632679490, (5, 2) = .6588350398199677, (5, 3) = 1.8383426590619378})})

 

Vector(5, {(1) = -.3, (2) = -.26501582080640973, (3) = -.13839484230713406, (4) = .1321628119977024, (5) = .6588350398199677})

 

Vector(2, {(1) = Vector[row](3, {(1) = x, (2) = x, (3) = x}), (2) = Matrix(5, 3, {(1, 1) = 0., (1, 2) = 0., (1, 3) = 1., (2, 1) = .392699081698724, (2, 2) = .594126892694279, (2, 3) = 2.1791320588050986, (3, 1) = .785398163397448, (3, 2) = 1.8799134917347557, (3, 3) = 4.694854392417611, (4, 1) = 1.17809724509617, (4, 2) = 4.645238733376015, (4, 3) = 10.097619402869181, (5, 1) = 1.57079632679490, (5, 2) = 10.606594599547698, (5, 3) = 21.817049575136046})})

 

Vector(5, {(1) = 0., (2) = .594126892694279, (3) = 1.8799134917347557, (4) = 4.645238733376015, (5) = 10.606594599547698})

 

Vector(5, {(1) = 0, (2) = (1/8)*Pi, (3) = (1/4)*Pi, (4) = (3/8)*Pi, (5) = (1/2)*Pi})

 

Vector[column](%id = 18446746529892031414)

 

 

 


Addition: the comparison in table form:

C1:=<approx, seq(Y[i], i=1..n+1)>:
C2:=<exact, seq(evalf(eval(exact_sol)), x=X)>:
C3:=C1-C2:
<C1|C2|C3>;
                          

Download LSM1.mw

Edit.

This is probably a bug. Here is a workaround:

restart;
int(exp(-t)/(1-t), t = epsilon .. infinity, CauchyPrincipalValue = true);
limit(%, epsilon=0);
evalf(%);
                        
 

 

Here is the solution of Problem 1. A comparison of the graphs shows that the exact solution specified in the task is incorrect.

NULL

restart;
eq:=diff(u(x),x,x)+1/9*u(x)=x^2+exp(x);
ics:=u(0)=0, D(u)(0)=a;
sol:=dsolve({eq, ics}, u(x));
a:=solve(eval(sol,[x=1,u(x)=0]));
evalf(a);
exact_sol:=eval(c1*sin(x/3)+c2*cos(x/3)+9*x^2+9*exp(x)/10-162,[c1=-9*(179*cos(1/3)-170+exp(1))/10/sin(sin(13)),c2=1611/10]);
plot([exact_sol,eval(u(x),sol)], x=0..1, color=[red,blue]);
 

diff(diff(u(x), x), x)+(1/9)*u(x) = x^2+exp(x)

 

u(0) = 0, (D(u))(0) = a

 

u(x) = sin((1/3)*x)*(3*a-27/10)+(1611/10)*cos((1/3)*x)+9*x^2-162+(9/10)*exp(x)

 

(3/10)*(3*sin(1/3)-179*cos(1/3)-exp(1)+170)/sin(1/3)

 

-.8105184240

 

-(9/10)*(179*cos(1/3)-170+exp(1))*sin((1/3)*x)/sin(sin(13))+(1611/10)*cos((1/3)*x)+9*x^2+(9/10)*exp(x)-162

 

 

 

NULL


 

Download shooting.mw

 

First 111 112 113 114 115 116 117 Last Page 113 of 290