Rouben Rostamian

MaplePrimes Activity


These are answers submitted by Rouben Rostamian

restart;
with(plots):
a := (k,p) -> (100-p)*exp(-k/2):
pvals := [0, 50, 100, 150, 200]:
colors := [blue, red, green, magenta, cyan]:
display(seq(pointplot([seq([k,a(k,p)], k=0..10)]), p in pvals),
    symbol=solidcircle, symbolsize=15, color=colors, legend=pvals);

 

I have no idea what you mean by a "composite function".

There is nothing like that in your equation.

 

As to your equation, you can solve it by hand.  You don't need Maple for it.

Begin with observing that ("abs(W)())^(2)" is the same as W^2.  So in your equation

test := abs(diff(u(x, t), x)+diff(u(x, t), t))^2 = abs(diff(u(x, t), x))^2+abs(diff(u(x, t), t))^2

abs(diff(u(x, t), x)+diff(u(x, t), t))^2 = abs(diff(u(x, t), x))^2+abs(diff(u(x, t), t))^2

drop the absolute values and get:

test := (diff(u(x, t), x)+diff(u(x, t), t))^2 = (diff(u(x, t), x))^2+(diff(u(x, t), t))^2

(diff(u(x, t), x)+diff(u(x, t), t))^2 = (diff(u(x, t), x))^2+(diff(u(x, t), t))^2

Expand the left-hand side and cancel the common terms.  Your equation reduces to

test := 2*(diff(u(x, t), x))*(diff(u(x, t), t)) = 0

2*(diff(u(x, t), x))*(diff(u(x, t), t)) = 0

We conclude that the solution of your PDE is either u(x, t) = f(x) or "u(x,t)=g(t),"
where f and g can be anything.

Download Partial_Differential_Equations_of_Composite_Functions-with-solution.mw

Your question makes sence if x is the entire real line, and the solution and its derivatives vanish at infinity.  We cannot have real infinities in a numerical calculation, so here I am take a largish x interval and impose the vanishing conditions at the interval's endpoints.

restart;

pde := diff(u(x,t),t) + diff(u(x,t),x$3) = 0;

diff(u(x, t), t)+diff(diff(diff(u(x, t), x), x), x) = 0

ibc := u(x,0)=f(x), u(a,t)=f(a), u(b,t)=f(b), D[1](u)(b,t)=D(f)(b);

u(x, 0) = f(x), u(a, t) = f(a), u(b, t) = f(b), (D[1](u))(b, t) = (D(f))(b)

a, b := -30, 10;

-30, 10

f := x -> 2/cosh(x)^2;

proc (x) options operator, arrow; 2/cosh(x)^2 end proc

pdsol := pdsolve(pde,{ibc}, numeric, spacestep=1e-2);

_m140290941899936

pdsol:-animate(t=0..1, frames=30);

Download mw.mw

What you have given as the "expected result" is not correct. Here is what you should get:

restart;

with(LinearAlgebra):

doit := proc(A::Matrix)
        local Q, R;
        Q, R := QRDecomposition(A, fullspan);
        return R . Q;
end proc:

A[0] := Matrix(  [[3.0, 1.0, 4.0], [1.0, 2.0, 2.0], [0., 13.0, 2]] );

Matrix(3, 3, {(1, 1) = 3.0000000000, (1, 2) = 1.0000000000, (1, 3) = 4.0000000000, (2, 1) = 1.0000000000, (2, 2) = 2.0000000000, (2, 3) = 2.0000000000, (3, 1) = 0., (3, 2) = 13.0000000000, (3, 3) = 2})

for i from 1 to 6 do
        A[i] := doit(A[i-1]);
end do;

Matrix(3, 3, {(1, 1) = 3.5000000000, (1, 2) = 4.4551702856, (1, 3) = -0.38180177416e-1, (2, 1) = 4.1412558482, (2, 2) = 3.5466472303, (2, 3) = 12.0839572279, (3, 1) = 0., (3, 2) = .38352988531, (3, 3) = -0.46647230321e-1})

Matrix(3, 3, {(1, 1) = 7.7653061224, (1, 2) = -3.5051266356, (1, 3) = -8.5280146144, (2, 1) = -.89936886875, (2, 2) = -3.1345831016, (2, 3) = -6.7655727021, (3, 1) = 0., (3, 2) = .81618126365, (3, 3) = 2.3692769792})

Matrix(3, 3, {(1, 1) = 8.1244016476, (1, 2) = -.40507893145, (1, 3) = 7.9914478264, (2, 1) = .41538662602, (2, 2) = -1.6766201724, (2, 3) = 8.6407060706, (3, 1) = 0., (3, 2) = .12815076053, (3, 3) = .55221852481})

Matrix(3, 3, {(1, 1) = 8.0993732348, (1, 2) = -1.5529006707, (1, 3) = -8.3271445271, (2, 1) = -0.84696189481e-1, (2, 2) = -2.2815760830, (2, 3) = -8.0017846681, (3, 1) = 0., (3, 2) = 0.91610146538e-1, (3, 3) = 1.1822028481})

Matrix(3, 3, {(1, 1) = 8.1153608751, (1, 2) = -1.1146392649, (1, 3) = 8.2940086384, (2, 1) = 0.24045008835e-1, (2, 2) = -1.9737094365, (2, 3) = 8.2142484334, (3, 1) = 0., (3, 2) = 0.34222832520e-1, (3, 3) = .85834856143})

Matrix(%id = 36893628848063747244)

Approximate eigenvalues

sort(Diagonal(A[i-1]));

Vector(3, {(1) = -2.1123294319, (2) = 1.0002884200, (3) = 8.1120410119})

Precise eigenvalues

Eigenvalues(A[0]);

Vector(3, {(1) = -2.0669460973+0.*I, (2) = .95415900373+0.*I, (3) = 8.1127870936+0.*I})

Download mw.mw

plot([seq(x+k, k=1..1.5, 0.1)], x=0..1, view=0..3);

 

dsol := dsolve({sys, ics}, numeric);
plots:-odeplot(dsol, [[t,x(t)],[t,y(t)],[t,z(t)]],
    t=0..0.005, color=[red,green,blue]);

restart;

 

Variables

 

A := 3;

3

B := 4;

4

 

 

Process 1

 

process1 := proc(x)
  return x^2*(A + B);
end proc:

 

Process 2

 

process2 := proc(x)
  return x^2*(A - B);
end proc:

 

 

Main

 

if A > B then
  process1(10);
else
  process2(12);
end if;

-144

 

Download mw.mw

 

Here is the translation into Maple of your hand-written solution.

restart;

System of equations (1)

eq1 := x__a = 1 + 2*t__1;
eq2 := y__a = t__1;
eq3 := z__a = -3 - 2*t__1;

x__a = 1+2*t__1

y__a = t__1

z__a = -3-2*t__1

System of equations (2)

eq4 := x__b = 1 - t__2;
eq5 := y__b = t__2;
eq6 := z__b = 3 + 2*t__2;

x__b = 1-t__2

y__b = t__2

z__b = 3+2*t__2

System of equations (3)

eq7 := x__a - 1 = K*(x__b - 1);
eq8 := y__a + 2 = K*(y__b + 2);
eq9 := z__a - 3 = K*(z__b - 3);

x__a-1 = K*(x__b-1)

y__a+2 = K*(y__b+2)

z__a-3 = K*(z__b-3)

Solve nine equations for nine unknowns

sol := solve({eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9}, {K, t__1, t__2, x__a, x__b, y__a, y__b, z__a, z__b});

{K = 11/2, t__1 = 3, t__2 = -12/11, x__a = 7, x__b = 23/11, y__a = 3, y__b = -12/11, z__a = -9, z__b = 9/11}

 

Download mw.mw

Your command

% sh ./Maple2021.2LinuxX64Installer.run

attempts to execute a shell script but Maple2021*.run is not a shell script; it is an executable binary. So drop the "sh" and do

% chmod +x Maple2021.2LinuxX64Installer.run
% ./Maple2021.2LinuxX64Installer.run

Here is a solution along the lines of the construction that you described in response to my question. There are more sophisticated ways of doing this. This answer intentionally uses a bare minimum of Maple in order to avoid overwhelming you.

restart;

with(plots):

with(plottools):

Define the coordinates of the vertices A and B.  Maple is happier working

with fractions rather than decimal point representations, so we write

17/2 instead of 8.5.

A, B := [ 0, 0 ], [ 17/2, 0 ];

[0, 0], [17/2, 0]

Draw the circles that you have described

display(
        line(A,B, color=red, thickness=5),
        circle(A, 5),
        circle(B, 4),
scaling=constrained);

Vertex C is where the circles intersect. There of two intersections,
so you get two choices for C.

 

To determine C's coordinates, we write down the equations of the

two circles, and solve them as simultaneous equations.

Circle1 := x^2 + y^2 = 5^2;  # circle centered at A
Circle2 := (x - 17/2)^2 + y^2 = 4^2;  # circle centered at B

x^2+y^2 = 25

(x-17/2)^2+y^2 = 16

Here are the two intersection points

sols := solve({Circle1, Circle2}, explicit);

{x = 325/68, y = (5/68)*399^(1/2)}, {x = 325/68, y = -(5/68)*399^(1/2)}

Pick the first one for C

C := subs(sols[1], [x,y]);

[325/68, (5/68)*399^(1/2)]

Time to plot the triangle

display(polygon([A,B,C]),
        color="Red", thickness=5, scaling=constrained, axes=normal);

 

Download mw.mw

 

Not an equation, but a numeric procedure.

my_x := proc(t)
        if not type(t, realcons) then return 'procname'(args); end if; 
        subs(y=t, f - 0.001 = g);
        fsolve(%, x = 0 .. 1);
end proc;
plot(my_x(y), y = 0 .. 2, view = 0 .. 1, labels = [y, x]);

The equation may be solved for y and therefore the graph may be plotted through plot() rather than implicitplot(). The following produces the plot shown in Kitonum's answer.

x^2+(y-x^(2/3))^2 = 1;
solve(%, y);
subs(x^(2/3)=surd(x^2,3), [%]);
plot(%, x=-1..1, color=red, thickness=3);

 

Is there a reason for looking at xhat as a function of all those variables?  Why not take xhat to be a function of a_1 only.  The solution will involve the remaining variables as parameters.

restart;

sys_ode := diff(xhat(a_1), a_1) = a_3*x + a_1, diff(yhat(a_1), a_1) = a_2 - a_4*y + f(x), diff(uhat(a_1), a_1) = a_3*u + 2*a_4*u, diff(vhat(a_1), a_1) = a_4*v + diff(f(x), x)*u;

diff(xhat(a_1), a_1) = a_3*x+a_1, diff(yhat(a_1), a_1) = a_2-a_4*y+f(x), diff(uhat(a_1), a_1) = a_3*u+2*a_4*u, diff(vhat(a_1), a_1) = a_4*v+(diff(f(x), x))*u

ics := xhat(0) = x, yhat(0) = y, uhat(0) = u, vhat(0) = v;

xhat(0) = x, yhat(0) = y, uhat(0) = u, vhat(0) = v

solution_a1 := dsolve([sys_ode, ics], [xhat(a_1), yhat(a_1), uhat(a_1), vhat(a_1)]);

{uhat(a_1) = a_1*a_3*u+2*a_1*a_4*u+u, vhat(a_1) = (diff(f(x), x))*u*a_1+a_4*v*a_1+v, xhat(a_1) = (1/2)*a_1^2+a_3*x*a_1+x, yhat(a_1) = -a_1*a_4*y+f(x)*a_1+a_1*a_2+y}

Download mw.mw

 

There is no meaningful way to do what you are asking, and that's not because of any shortcoming on the part of Maple.

Your equations are defined in a three-dimensional phase space, that is, the associated vector field is 3D and the solution curve is a curve in 3D.  You plot the projection of that 3D curve onto the (V,In) plane.  That works fine since the projection of a 3D curve onto a 2D plane is still a curve.

In contrast, the projection of a 3D vector field onto a 2D plane is not a vector field because each point of your 2D plotting domain is the foot of the projection of all the vectors in 3D that lie "above" that point.

Change
if not is({args}, set(numeric)) then return ('procname')('args') end if;
to
if not type({args}, set(numeric)) then return ('procname')('args') end if;
and it will work.

Comment added later:

It is likely that numeric is not what you want.   For instance, Pi is not numeric.  To allow for symbolic constants such as Pi as arguments, change numeric to realcons.  Here is the way I would do it:

if not type([args], list(realcons)) then return 'procname'(args) end if;

 

First 12 13 14 15 16 17 18 Last Page 14 of 58