Kitonum

21530 Reputation

26 Badges

17 years, 84 days

MaplePrimes Activity


These are answers submitted by Kitonum

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

 

We can easily prove by hand even an more general result, that for any number of roots in the first term (starting from 2) the limit is 1/2.
We denote by  a[n]  the expression with  n  roots. For example  a[3]=sqrt(x+sqrt(x+sqrt(x)))

It's obvious that  for any  n>=2  we have   
a[n]=sqrt(x+a[n-1]) limit(a[n]/sqrt(x), x=infinity)=1,  limit(a[n]/x, x=infinity)=0

Below we prove that for any  n>=2  the result holds  limit(a[n]-sqrt(x), x=infinity) = 1/2 

We denote  A=sqrt(x+a[n-1]) - sqrt(x) ,  B=sqrt(x+a[n-1]) + sqrt(x)

For the proof, it is sufficient to make only 3 steps: multiply and divide   by  , simplify in the numerator using the difference formula for the squares, and then divide the numerator and the denominator by  sqrt(x)  (below is an illustration of these steps in Maple) :

restart;
A:=sqrt(x+a[n-1])-sqrt(x);
B:=sqrt(x+a[n-1])+sqrt(x);
C:=expand(A*B)/B;
``(expand(combine(numer(C)/sqrt(x))))/map(p->expand(combine(p/sqrt(x))),denom(C)) assuming x>0;
                               
 

Using the above limits, we get the result  1/2 


For those who want to check the result in Maple (without any steps) , here's a procedure that allows you to automatically generate the expression  a[n]  for any  :

restart;
a:=proc(n)
if n=1 then return sqrt(x) else
sqrt(x+a(n-1)) fi;
end proc:

Examples of use:

seq(a(n), n=[1,4,10]);

   

The answer is very simple - your inequality in addition to the basic unknown  r  contains several parameters  (lambda, M) and Maple simply does not know how to solve such inequalities.

Here is a much simpler example that Maple also refuses to solve:

solve(sqrt(a*x+1) < 1, x);
     Warning, solutions may have been lost


This simple example, we can still solve, if to use  assuming  option:

solve(sqrt(a*x+1) < 1, x) assuming a>0;
solve(sqrt(a*x+1) < 1, x) assuming a<0;


But for your inequality and it does not help.

I think first you need to specify the values of the parameters  lambda  and  .



 

See  ?plot,axis  help page for this.

Do you just want to check that a number  a  is the root of your equation? In this case, do 

simplify(eval(F(X)=0, X=a));

Sometimes other commands are required instead of  simplify . Then specify the exact form of your equation and the value of .
 

restart;
with(Physics):
Setup(mathematicalnotation = true);                
Setup(signature = `+---`);
ds2 := ((x^2-y^2)*cos(2*u)+2*x*y*sin(2*u))*(du^2)-2*x*(dv^2)-dx^2-dy^2;
Setup(coordinatesystems=(Z=[u, v, x, y]), metric = ds2);

 

Edit.

[{1, 2}, {2, 3}] minus~ [{2}$2];
                                                   
  [{1}, {3}]

A more traditional and programmatic way of obtaining the values of a function obtained as a result of solving an equation, etc., is to use  eval  command. See the same example as tomleslie's one:


 

restart;
PDE := diff(u(x,t),t)=-diff(u(x,t),x);
  IBC := {u(x,0)=sin(2*Pi*x),u(0,t)=-sin(2*Pi*t)};
  pds := pdsolve(PDE,IBC,numeric,time=t,range=0..1);

diff(u(x, t), t) = -(diff(u(x, t), x))

 

{u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}

 

_m2382342501312

(1)


f:=(x0,t0)->eval(u(x,t),pds:-value(t=t0)(x0));
f(0.7,0.5);  # Example of the calculation of a value of u(x,t)
evalf(Int(x->f(x,0.1), 0.25..0.75));  # Example of the calculation of an integral of u(x,t)

proc (x0, t0) options operator, arrow; eval(u(x, t), (pds:-value(t = t0))(x0)) end proc

 

HFloat(0.9510565162951535)

 

HFloat(0.18707013161493055)

(2)

 


 

Download eval.mw

ode:= diff(y(x),x)=2*x:
plots:-display(DEtools:-DEplot(ode,y(x),x = -2 .. 2,y = -2 .. 2, [[0.1,0]],
               labels=["",""],
               linecolour = red,
               color = blue,
               'arrows' = 'medium',
               axesfont=['Times', 'bold', 12]
               ), axis=[tickmarks=[color=red]]);

For your first example, everything is the same:

restart;
plots:-display(plot(sin(x),x=-Pi..Pi, color=blue),axis=[tickmarks=[color=red]]);
 

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