Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 357 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

The integrand has singularities at -I, 2*I, and 5. All of these are at distance greater than 1 from sqrt(11/2). So no singularities are enclosed by the path of integration. So the answer is 0.

If Maple ever gives you 2D output that you don't understand, just use lprint(%) to see the 1D equivalent. In this case, it will reveal the LerchPhi.

I don't think that dsolve's BVP solvers can handle complex numbers. But your BVP contains a parameter, A3. We can solve for this parameter and then use one of dsolve's IVP solvers, which do handle complex numbers. To solve for A3, note that the right side of your ODE doesn't contain the dependent variable, u. Thus we can use a combination of numeric integration and fsolve.
 

restart:

A1:= 5.5:  n:= .59:  A2:= 11818.:  h0:= 0.402e-3:
L:= .1:  dpx := -11823.9:  uc:= 0.44e-2:

ODE:= (A3,y)->
   (h0^(n+1)*L/sqrt(n)*(A1*exp(sqrt(n)*y/L)-A2*exp(-sqrt(n)*y/L))+dpx*y*h0+A3)^(1/n)
;

proc (A3, y) options operator, arrow; (h0^(n+1)*L*(A1*exp(sqrt(n)*y/L)-A2*exp(-sqrt(n)*y/L))/sqrt(n)+dpx*y*h0+A3)^(1/n) end proc

ODEINT:= proc(A3)
option remember;
local y;
   evalf(Int(ODE(A3,y), y= 0..1, epsilon= 1e-7)) - uc
end proc:

ReINT:= proc(A3x, A3y)
   Digits:= 15:
   Re(ODEINT(A3x + I*A3y))
end proc:

ImINT:= subs(Re= Im, eval(ReINT)):

Digits:= 7:
a3:= fsolve([ReINT, ImINT]);

[2.3776470627663, -1.0154578732062]

A3:= Complex(a3[]);

2.3776470627663-1.0154578732062*I

Solve as IVP:

Digits:= 15:
sol:= dsolve({diff(u(y),y) = ODE(A3,y), u(0)=0}, numeric):

plots:-odeplot(
   sol, [[y, Re(u(y))], [y, Im(u(y))]], y= 0..1,
   legend= [real, imag], labels= [y, u(y)]
);

Verify that boundary condition at u(1) is satisfied:

abs(eval(u(y), sol(1)) - uc);

0.489191321784278e-7

sol(.5);

[y = .5, u(y) = .504669074500681-.965536950733450*I]

``

Download Complex_BVP.mw

 

The cause of the anomaly that you described is that print doesn't return values; it merely displays them in your worksheet. The purpose of print is to display supplementary information from the middle of a procedure. It is not appropriate to use it at the end of a procedure to return the procedure's main return value. If you do use it like this, the actual returned value (not the displayed value) is NULL, which is of type exprseq, which is what you're experiencing. So, all you need to do is change print(Hm) to simply Hm.

I think that you may have the mistaken idea that a "statement" needs to be on a single line. Actually, there's no practical limit to the number of lines that it can take, the number of substatements internal to it, or the depth of their nesting.

Change

if m1 <= 2^(2*k-1) then t1 := (C+(-A1*(m1^2)))/A2 end if;
Do (t1);

to

if m1 <= 2^(2*k-1) then
   t1 := (C+(-A1*(m1^2)))/A2;
   Do (t1)
end if;

And do likewise for the other if-then blocks.

The line

E2:= V(x2);

should be

E2:= V(x2(i));

 

It's not a source of the error, but I'm concerned about your use of Seed. What is its significance? Why not use rand()?

You should not use randomize() until you have your code running correctly without it because its use will make some bugs harder to find.

Please post code in plaintext form, or post a worksheet. I was unable to test my answer above because I couldn't run your code because it's in a form that can't be copied-and-pasted.

If the function has a Taylor series at x=a, then that's what's returned. For complex-valued functions (which most functions are), having a Taylor series at x=a is equivalent to the function being differentiable throughout an open set containing x=a. Next, if it has a Laurent series at x=a, then that's what's returned. Having a Laurent series at x=a is equivalent to there being a positive integer n such that (x-a)^n*f(x) has a Taylor series at x=a. Finally, if a more-generalized type of series can be found, then that's what's returned. I don't know the details of these more-generalized series, but my first guess is that they're always of the form M((x-a)*g(x-a)), where M(z) is a Maclaurin series and g(x) is a relatively simple function (such as ln(x) or x^r for some r, 0 < |r| < 1) that is not differentiable at x=a.

Here's a somewhat systematic approach to reducing arctrig(algebraic number) to a rational multiple of Pi.
 

restart:

x1:= arcsin(1/2*(2+(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2));

arcsin((1/2)*(2+(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2))

p:= evala(Norm(z-convert(op(x1), RootOf)));

z^16-4*z^14+(13/2)*z^12-(11/2)*z^10+(165/64)*z^8-(21/32)*z^6+(21/256)*z^4-(1/256)*z^2+1/32768

d:= degree(p);

16

p2:= combine(eval(p, z= invfunc[op(0,x1)](x)));

(1/32768)*cos(16*x)

s:= solve(p2, allsolutions);

(1/32)*Pi+(1/16)*Pi*_Z1

Z:= indets(s, And(name, Not(constant)))[];

_Z1

S:= [seq(eval(s, Z= k), k= 0..d-1)];

[(1/32)*Pi, (3/32)*Pi, (5/32)*Pi, (7/32)*Pi, (9/32)*Pi, (11/32)*Pi, (13/32)*Pi, (15/32)*Pi, (17/32)*Pi, (19/32)*Pi, (21/32)*Pi, (23/32)*Pi, (25/32)*Pi, (27/32)*Pi, (29/32)*Pi, (31/32)*Pi]

S[min[index](abs~(x1 -~ S))];

(15/32)*Pi

 

Download arctrig_of_algebraic.mw

I consider that last step to be "exact and symbolic" because the min is exactly 0.

The more-typical (but more difficult to implement) solution to this error is to introduce a coefficient called a continuation parameter. The coefficient is usually applied to the more-complicated terms of the ODEs, but it can appear anywhere, and in multiple locations. In this case, I applied it to the nonlinear terms. I used CONT for the coefficient, and changed your first ODE to

ODEforNum1:= 
   diff(u(eta), eta$4) +
   2/(eta+k)*diff(u(eta), eta$3) -
   1/(eta+k)^2*diff(u(eta), eta$2) +
   1/(eta+k)^3*diff(u(eta), eta) +
   CONT*e1*(
      -k/(eta+k)*(diff(u(eta), eta)*diff(u(eta), eta$2)-u(eta)*diff(u(eta), eta$3)) -
      k/(eta+k)^2*(diff(u(eta), eta)^2-u(eta)*diff(u(eta), eta$2)) -
      k/(eta+k)^3*u(eta)*(diff(u(eta), eta))
   ) = 0
;

The only (mathematical) change that I made was the introduction of CONT. The rest is just formatting so that I could easily read the input.

After that, you just need to declare the continuation parameter in the dsolve command:

numsol1:= dsolve(
   {BCSforNum1, BCSforNum2, ODEforNum1, ODEforNum2},
   numeric, output= listprocedure, continuation= CONT
);

The continuation is a kind of bootstrapping. The coefficient starts at 0, which eliminates the complicated terms, and it's gradually increased to 1, which returns the original ODEs. Obviously, in order for this to produce correct results, the parameter can only be used as a coefficient.

To do it with arrow notation:

Vector[row](6, i-> 4*i)

Like this:

plots:-display(
   plot(1/ra, x= 0..0.5, filled),
   plot(1/ra, x= 0.5..1),
   plot([[0.5, 0], [0.5, eval(1/ra, x= 0.5)]]), #vertical line segment
   view= [DEFAULT, 0..10] #Limit the vertical extent.
);

Is that what you mean?

Your subs commands treat y as if it were a function (expression), but it is just a free variable because it is not defined anywhere in your code. Your plot commands treat Psi as if it were a free variable, but it is a function (expression) that you have defined.

Here's a solution that can be easily generalized to higher dimensions and an arbitrary number of bodies.
 

restart:

List the names of the space dimensions. The number of these can be changed.

Space:= [x,y]:

The exponent to use on the distance  in the denominators. Using 3 corresponds to ordinary gravity.

expon:= 2:

Declare the objects that are moving. I prefer letter names over numbers for the objects. Each object has an inital position and velocity and a mass. The number of objects can be changed.

ObjProps:= table([
   a = Record(r0= [1, 1], v0= [0, 0.8], mass= 1),
   b = Record(r0= [1.5, 2], v0= [1, 1.4], mass= 1),
   c = Record(r0= [2.5, 3], v0= [0.2, -1], mass= 1)
]):

Objs:= {indices(ObjProps, nolist)};

{a, b, c}

Procedure to subscript the elements of  the Space vector with a particular object.

SpaceObj:= ob-> map(`?[]`, Space, [ob]):

Construct the ODEs.

ODEs:= {
   seq(
      seq(
         diff(V[Ob](t), t$2) =
         add(
            ObjProps[ob][mass]*(V[ob]-V[Ob])(t)/
               LinearAlgebra:-Norm(
                  <(SpaceObj(ob) - SpaceObj(Ob))(t)>,
                  Euclidean, conjugate= false
               )^expon          
           ,ob= Objs minus {Ob}
         )
        ,Ob= Objs
      )
     ,V= Space
   )
}:
'ODEs' = <ODEs[]>;

ODEs = (Matrix(6, 1, {(1, 1) = diff(diff(x[a](t), t), t) = (x[b](t)-x[a](t))/((x[b](t)-x[a](t))^2+(-y[a](t)+y[b](t))^2)+(x[c](t)-x[a](t))/((x[c](t)-x[a](t))^2+(-y[a](t)+y[c](t))^2), (2, 1) = diff(diff(x[b](t), t), t) = (-x[b](t)+x[a](t))/((-x[b](t)+x[a](t))^2+(y[a](t)-y[b](t))^2)+(x[c](t)-x[b](t))/((x[c](t)-x[b](t))^2+(-y[b](t)+y[c](t))^2), (3, 1) = diff(diff(x[c](t), t), t) = (-x[c](t)+x[a](t))/((-x[c](t)+x[a](t))^2+(y[a](t)-y[c](t))^2)+(-x[c](t)+x[b](t))/((-x[c](t)+x[b](t))^2+(y[b](t)-y[c](t))^2), (4, 1) = diff(diff(y[a](t), t), t) = (-y[a](t)+y[b](t))/((x[b](t)-x[a](t))^2+(-y[a](t)+y[b](t))^2)+(-y[a](t)+y[c](t))/((x[c](t)-x[a](t))^2+(-y[a](t)+y[c](t))^2), (5, 1) = diff(diff(y[b](t), t), t) = (y[a](t)-y[b](t))/((-x[b](t)+x[a](t))^2+(y[a](t)-y[b](t))^2)+(-y[b](t)+y[c](t))/((x[c](t)-x[b](t))^2+(-y[b](t)+y[c](t))^2), (6, 1) = diff(diff(y[c](t), t), t) = (y[a](t)-y[c](t))/((-x[c](t)+x[a](t))^2+(y[a](t)-y[c](t))^2)+(y[b](t)-y[c](t))/((-x[c](t)+x[b](t))^2+(y[b](t)-y[c](t))^2)}))

Construct the initial conditions.

ICs:= op~({
   seq(
      [SpaceObj(Ob)(0) =~ ObjProps[Ob][r0], D~(SpaceObj(Ob))(0) =~ ObjProps[Ob][v0]][],
      Ob= Objs
   )
});

{x[a](0) = 1, x[b](0) = 1.5, x[c](0) = 2.5, y[a](0) = 1, y[b](0) = 2, y[c](0) = 3, (D(x[a]))(0) = 0, (D(x[b]))(0) = 1, (D(x[c]))(0) = .2, (D(y[a]))(0) = .8, (D(y[b]))(0) = 1.4, (D(y[c]))(0) = -1}

Sol:= dsolve(ODEs union ICs, numeric):

Plot of trajectories:

plots:-odeplot(
   Sol, SpaceObj~(Objs)(t), t= 0..10,
   legend= [Objs[]], scaling= constrained
);

Animation:

plots:-display([
   seq(
      plot(
         subs(Sol(t), (`[]`@SpaceObj)~(Objs)('t')),
         style= point, symbol= solidcircle, symbolsize= 12,
         color= [red, blue, green]
      ), t= 0..10, .1
   )], insequence
);

 


 

Download Three-body.mw

You misplaced the closing brace. You have

pds:= pdsolve({eq1, eq2, IBC, numeric, spacestep = 1/10});

It should be

pds:= pdsolve({eq1, eq2}, IBC, numeric, spacestep = 1/10);

Then there's a more-subtle problem with your initial/boundary conditions. You have D[1](u)(x,0). Are you sure that that shouldn't be D[2](u)(x,0)? The former can't be handled by pdsolve(..., numeric).

When entering the expression, you must explicity enter the dot:

p:= C.A + A;

This will indicate that you want noncommutative multiplication.

First 193 194 195 196 197 198 199 Last Page 195 of 395