Rouben Rostamian

MaplePrimes Activity


These are answers submitted by Rouben Rostamian

restart;
with(plottools): with(plots):
s := display(sphere([0,0,0],1), style=surface, transparency=0.8);
c := display(cuboid([-1,-1,-1], [1,1,1]), transparency=0.3, style=surface);
display([c,s], axes=none, orientation=[-65,72,0]);


 

 

restart;

C := (n,x) -> cos(n*Pi/ln(2)*ln(x));

proc (n, x) options operator, arrow; cos(n*Pi*ln(x)/ln(2)) end proc

S := (n,x) -> sin(n*Pi/ln(2)*ln(x));

proc (n, x) options operator, arrow; sin(n*Pi*ln(x)/ln(2)) end proc

Your calculations assume that the functions { C(n,x), S(m,x) } form an orthogonal family with respect to the weighted integral (weight = 1/x) on the interval (1,2), but that's not true.  Let's check:

int(C(n,x)*S(m,x)/x, x=1..2);

-ln(2)*(m*cos(m*Pi)*cos(n*Pi)+n*sin(m*Pi)*sin(n*Pi)-m)/(Pi*(m^2-n^2))

simplify(%) assuming n::integer, m::integer;

-ln(2)*m*((-1)^(m+n)-1)/(Pi*(m^2-n^2))

We see that the result is not zero in general.

You may already know the difference between the colon (":") and a semicolon (";")  command terminators.  In both cases the command is executed, but in the case of the colon the result is not shown.

Important:  Always use the semicolon terminator when developing new code, especially when you are having trouble with it.  Suppressing the result through a colon deprives you of the assurance that your command works as intended.

With this in mind, go back to your code and replace the colon terminators with semicolons, and then come back here if you still have problems.

 

Just by looking at your equations it is clear that y(x)≡0 is a solution.  I suppose you are looking for nonzero solutions.

Your equations arise in the analysis of buckling of an Euler beam.  A combination of the parameters P, K(x), and L that yield nonzero solutions correspond to the beam's buckling modes.

You must be familiar with the analysis corresponding to a uniform beam, that is, when K(x) is a constant.  There one shows that buckling modes exist only when L*sqrt(P/K) = , where n is a positive integer.  When K is not a constant, there is no general formula for buckling modes.  The best you can hope for is some numerical experiments for specific choices of K(x).

restart;
m := f__1(x,y)*A + f__2(x,y)*B + f__3(x,y)*C;
f := <coeffs(m, [A,B,C])>;

I don't know how to do this in Maple but that sort of thing is easily done using specialized image manipulation tools.  I would do it with Imagemagick's command-line tools but I am sure there are many other alternatives, perhaps gimp or photoshop.

It takes only two imagemagick commands to produce the desired composite.  Let's call your two images fig.png and fig-zoomed.png.

  • Step 1:  Scale fig-zoomed.png  to half its original size and call the result fig-zoomed-scaled.png:
        convert -scale 50% fig-zoom.png fig-zoom-scaled.png
  • Step 2: Produce the composite which we call out.png:
        composite -geometry +150+50 fig-zoom-scaled.png fig.png out.png

The "-geometry +150+50" option says that the inset image will be offset relative to the upper-left corner by 150 pixels (horizontally) and 50 pixels (vertically).  Here is the result:

 

Name the plots, as in
p1 := plot(<a,c,e,g,i,a>, <b,d,f,h,j,b>);
...
p2 := plot(<a,c,e,g,i,a>, <b,d,f,h,j,b>);

and then do:
plots:-display([p1,p2], scaling=constrained);

 

restart;

A := < 3/4, -2; 1, -5/4 >;

_rtable[18446884412110971358]

diff~(<x[1](t), x[2](t)>, t) - A . <x[1](t), x[2](t)>;
sys := convert(%, list);

_rtable[18446884412110973038]

[diff(x[1](t), t)-(3/4)*x[1](t)+2*x[2](t), diff(x[2](t), t)-x[1](t)+(5/4)*x[2](t)]

n := 6:
r := 1.5:
ic := seq(([x[1](0)=r*i/n, x[2](0)=0]), i=1..n):

DEtools:-DEplot(sys, [x[1](t), x[2](t)], t=-4..12, [ic],
      view=[-1..1, -1..1], stepsize=0.1,
      linecolor=black, thickness=1, arrows=none);

Download mw.mw

That looks like a bug to me.  Maple 2018 does not crash, but fails with the error message "Error, (in Explore) while processing result".

Here is a workaround that works on Maple 2018.  See if it works for you.  Change
caption = typeset(x^2 + y^2)
to
caption = typeset("%1+%2", x^2, y^2)
 

 

restart:

omega0:= 10/3.:

Choose one of  legend_plain  or  legend_fancy:

legend_plain := [typeset(omega[0] = omega0)];

[typeset(omega[0] = 3.333333333)]

legend_fancy := [typeset(omega[0] = convert(sprintf("%.1f", omega0), symbol))];

[typeset(omega[0] = `3.3`)]

plot(omega^2/omega0, omega = 1..1.5, legend = legend_fancy);

 

Download mw.mw

I can't tell by looking in your worksheet what you want your animation to show.

But it appears that you know how to produce the individual frames/graphics of the animation. Let's say these are called p1, p2, ..., pn.  To animate, do:
plots:-display([p1, p2, ..., pn], insequence);

 

I made some effort to understand the purpose of your calculations and untangle their logic. The result is what I have shown below.  Be sure to check every detail because it is possible that I have misinterpreted your worksheet or introduced typographical errors.

restart;

DEs := diff(x1(t), t) = x2(t),
       diff(x2(t), t) = l*u(x4(t))-k*sin(2*x1(t)),
       diff(x3(t), t) = 2*k*cos(2*x1(t))*x4(t),
       diff(x4(t), t) = -x3(t);

diff(x1(t), t) = x2(t), diff(x2(t), t) = l*u(x4(t))-k*sin(2*x1(t)), diff(x3(t), t) = 2*k*cos(2*x1(t))*x4(t), diff(x4(t), t) = -x3(t)

u := x -> piecewise(x <= -1, -U_max, 1 < x, U_max, 0);

u := proc (x) options operator, arrow; piecewise(x <= -1, -U_max, 1 < x, U_max, 0) end proc

bc := x1(0) = th0,
      x2(0) = q0,
      x3(t1) + 2*G1*x1(t1) = 0,
      x4(t1) + 2*G2*x2(t1) = 0;

x1(0) = th0, x2(0) = q0, x3(t1)+2*G1*x1(t1) = 0, x4(t1)+2*G2*x2(t1) = 0

Note that the parameters are specified as equations, not as assignments!

params :=
  T0 = 300,
  G1 = 1.2e6,
  G2 = 1.2e6,
  k = 1.79333595e-6,
  l = 1/12e4,
  U_max = 5.0,
  th0 = .5,
  q0 = 0.1e-2;

T0 = 300, G1 = 0.12e7, G2 = 0.12e7, k = 0.179333595e-5, l = 0.8333333333e-5, U_max = 5.0, th0 = .5, q0 = 0.1e-2

sys := eval({DEs,bc}, {params, t1=10.0}):    # note the t1=10.0

dsol := dsolve(sys, numeric);

proc (x_bvp) local res, data, solnproc, _ndsol, outpoint, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; _EnvDSNumericSaveDigits := Digits; Digits := 15; if _EnvInFsolve = true then outpoint := evalf[_EnvDSNumericSaveDigits](x_bvp) else outpoint := evalf(x_bvp) end if; data := Array(1..4, {(1) = proc (outpoint) local X, Y, YP, yout, errproc, L, V, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; X := Vector(8, {(1) = .0, (2) = 1.428582867243206, (3) = 2.8572001869402115, (4) = 4.285793276873327, (5) = 5.714364424810432, (6) = 7.142918882256333, (7) = 8.571462217201669, (8) = 10.0}, datatype = float[8], order = C_order); Y := Matrix(8, 4, {(1, 1) = .5, (1, 2) = 0.10e-2, (1, 3) = -1218701.2042618706, (1, 4) = -12189157.44105805, (2, 1) = .5013845243918722, (2, 2) = 0.9383179909276191e-3, (2, 3) = -1218732.4725656176, (2, 4) = -10448118.857015757, (3, 1) = .5026809584542433, (3, 2) = 0.876630798947629e-3, (3, 3) = -1218758.8209411495, (3, 4) = -8706997.134761466, (4, 1) = .5038892428934152, (4, 2) = 0.8149412148685686e-3, (4, 3) = -1218780.2942966516, (4, 4) = -6965870.788812328, (5, 1) = .5050093791867353, (5, 2) = 0.753249394199044e-3, (5, 3) = -1218796.93510486, (5, 4) = -5224743.965523619, (6, 1) = .5060413706581044, (6, 2) = 0.6915553617706725e-3, (6, 3) = -1218808.7819558734, (6, 4) = -3483617.140681507, (7, 1) = .5069852198925933, (7, 2) = 0.6298591262419049e-3, (7, 3) = -1218815.8694750136, (7, 4) = -1742490.3515712114, (8, 1) = .5078409284568352, (8, 2) = 0.5681606938670946e-3, (8, 3) = -1218818.2282964045, (8, 4) = -1363.585665281027}, datatype = float[8], order = C_order); YP := Matrix(8, 4, {(1, 1) = 0.10e-2, (1, 2) = -0.431757068329379e-4, (1, 3) = -23.621210940059537, (1, 4) = 1218701.2042618706, (2, 1) = 0.9383179909276191e-3, (2, 2) = -0.4317838409608693e-4, (2, 3) = -20.15988007732689, (2, 4) = 1218732.4725656176, (3, 1) = 0.876630798947629e-3, (3, 2) = -0.43180880510326025e-4, (3, 3) = -16.732032844411012, (3, 4) = 1218758.8209411495, (4, 1) = 0.8149412148685686e-3, (4, 2) = -0.4318319801867119e-4, (4, 3) = -13.335132954895201, (4, 4) = 1218780.2942966516, (5, 1) = 0.753249394199044e-3, (5, 2) = -0.43185338547120616e-4, (5, 3) = -9.96647565352916, (5, 4) = 1218796.93510486, (6, 1) = 0.6915553617706725e-3, (6, 2) = -0.4318730388928721e-4, (6, 3) = -6.623331055162384, (6, 4) = 1218808.7819558734, (7, 1) = 0.6298591262419049e-3, (7, 2) = -0.4318909570042439e-4, (7, 3) = -3.302952234722308, (7, 4) = 1218815.8694750136, (8, 1) = 0.5681606938670946e-3, (8, 2) = -0.4319071549599433e-4, (8, 3) = -0.2577615512201638e-2, (8, 4) = 1218818.2282964045}, datatype = float[8], order = C_order); errproc := proc (x_bvp) local outpoint, X, Y, yout, L, V, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; Digits := 15; outpoint := evalf(x_bvp); X := Vector(8, {(1) = .0, (2) = 1.428582867243206, (3) = 2.8572001869402115, (4) = 4.285793276873327, (5) = 5.714364424810432, (6) = 7.142918882256333, (7) = 8.571462217201669, (8) = 10.0}, datatype = float[8], order = C_order); Y := Matrix(8, 4, {(1, 1) = .0, (1, 2) = .0, (1, 3) = 0.39283088202469616e-9, (1, 4) = 0.1583150741983841e-8, (2, 1) = -0.7580062395781635e-16, (2, 2) = -0.3025210845716929e-18, (2, 3) = 0.37361311464173746e-9, (2, 4) = -0.17786774287792475e-8, (3, 1) = 0.2598274327370506e-15, (3, 2) = 0.33166261616014577e-18, (3, 3) = 0.474826688104923e-9, (3, 4) = 0.2021512657291743e-8, (4, 1) = -0.4601610101061015e-15, (4, 2) = -0.23276499915587446e-18, (4, 3) = 0.45038562915775664e-9, (4, 4) = 0.15693529661589289e-8, (5, 1) = -0.2840761139229594e-15, (5, 2) = 0.17448199333926153e-18, (5, 3) = -0.5548514105926573e-10, (5, 4) = 0.21764372136549502e-8, (6, 1) = -0.11898771241848955e-15, (6, 2) = -0.19825386038967814e-19, (6, 3) = 0.4353070721923952e-9, (6, 4) = -0.690459617210538e-9, (7, 1) = -0.23398097137467846e-15, (7, 2) = 0.2295525899574634e-18, (7, 3) = 0.4071210128732176e-9, (7, 4) = 0.5832347248695947e-9, (8, 1) = -0.12490890196393565e-15, (8, 2) = 0.18274259637436185e-18, (8, 3) = 0.6741001502551099e-9, (8, 4) = -0.3852601004217984e-12}, datatype = float[8], order = C_order); if not type(outpoint, 'numeric') then if outpoint = "start" or outpoint = "left" then return X[1] elif outpoint = "right" then return X[8] elif outpoint = "order" then return 6 elif outpoint = "error" then return HFloat(2.1764372136549502e-9) elif outpoint = "errorproc" then error "this is already the error procedure" elif outpoint = "rawdata" then return [4, 8, [x1(t), x2(t), x3(t), x4(t)], X, Y] else return ('procname')(x_bvp) end if end if; if outpoint < X[1] or X[8] < outpoint then error "solution is only defined in the range %1..%2", X[1], X[8] end if; V := array([1 = 4, 2 = 0]); if Digits <= trunc(evalhf(Digits)) then L := Vector(4, 'datatype' = 'float'[8]); yout := Vector(4, 'datatype' = 'float'[8]); evalhf(`dsolve/numeric/lagrange`(8, 4, X, Y, outpoint, var(yout), var(L), var(V))) else L := Vector(4, 'datatype' = 'sfloat'); yout := Vector(4, 'datatype' = 'sfloat'); `dsolve/numeric/lagrange`(8, 4, X, Y, outpoint, yout, L, V) end if; [t = outpoint, seq('[x1(t), x2(t), x3(t), x4(t)]'[i] = yout[i], i = 1 .. 4)] end proc; if not type(outpoint, 'numeric') then if outpoint = "start" or outpoint = "left" then return X[1] elif outpoint = "method" then return "bvp" elif outpoint = "right" then return X[8] elif outpoint = "order" then return 6 elif outpoint = "error" then return HFloat(2.1764372136549502e-9) elif outpoint = "errorproc" then return eval(errproc) elif outpoint = "rawdata" then return [4, 8, "depnames", X, Y, YP] else error "non-numeric value" end if end if; if outpoint < X[1] or X[8] < outpoint then error "solution is only defined in the range %1..%2", X[1], X[8] end if; if Digits <= trunc(evalhf(Digits)) and (_EnvInFsolve <> true or _EnvDSNumericSaveDigits <= trunc(evalhf(Digits))) then V := array( 1 .. 6, [( 1 ) = (7), ( 2 ) = (0), ( 3 ) = (false), ( 4 ) = (false), ( 5 ) = (false), ( 6 ) = (false)  ] ); L := Matrix(7, 2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0, (3, 1) = .0, (3, 2) = .0, (4, 1) = .0, (4, 2) = .0, (5, 1) = .0, (5, 2) = .0, (6, 1) = .0, (6, 2) = .0, (7, 1) = .0, (7, 2) = .0}, datatype = float[8], order = C_order); yout := Vector(4, {(1) = .0, (2) = .0, (3) = .0, (4) = .0}, datatype = float[8]); evalhf(`dsolve/numeric/hermite`(8, 4, X, Y, YP, outpoint, var(yout), var(L), var(V))) else if _EnvInFsolve = true then Digits := _EnvDSNumericSaveDigits end if; V := array( 1 .. 6, [( 1 ) = (7), ( 2 ) = (0), ( 3 ) = (false), ( 4 ) = (false), ( 5 ) = (false), ( 6 ) = (false)  ] ); L := Matrix(7, 2, {(1, 1) = 0., (1, 2) = 0., (2, 1) = 0., (2, 2) = 0., (3, 1) = 0., (3, 2) = 0., (4, 1) = 0., (4, 2) = 0., (5, 1) = 0., (5, 2) = 0., (6, 1) = 0., (6, 2) = 0., (7, 1) = 0., (7, 2) = 0.}, order = C_order); yout := Vector(4, {(1) = 0., (2) = 0., (3) = 0., (4) = 0.}); `dsolve/numeric/hermite`(8, 4, X, Y, YP, outpoint, yout, L, V) end if; [outpoint, seq(yout[i], i = 1 .. 4)] end proc, (2) = Array(0..0, {}), (3) = [t, x1(t), x2(t), x3(t), x4(t)], (4) = 0}); solnproc := data[1]; if not type(outpoint, 'numeric') then if outpoint = "solnprocedure" then return eval(solnproc) elif member(outpoint, ["start", "left", "right", "errorproc", "rawdata", "order", "error"]) then return solnproc(x_bvp) elif outpoint = "sysvars" then return data[3] elif procname <> unknown then return ('procname')(x_bvp) else _ndsol := pointto(data[2][0]); return ('_ndsol')(x_bvp) end if end if; try res := solnproc(outpoint); [t = res[1], seq('[x1(t), x2(t), x3(t), x4(t)]'[i] = res[i+1], i = 1 .. 4)] catch: error  end try end proc

dsol(0);

[t = 0., x1(t) = HFloat(0.4999999999999999), x2(t) = HFloat(9.999999999999998e-4), x3(t) = HFloat(-1218701.2042618704), x4(t) = HFloat(-1.2189157441058049e7)]

Conclusion:  At t=0 we have x3 = -1.21870120426187*10^6, x4 = -1.21891574410580*10^7

 

 

Download mw.mw

 

Polynomial interpolation through

Newton's forward difference scheme

restart;

Procedure receives lists Xand Y of coordinates x__0, y__0, () .. (), x__k, y__k of points and
produces a polynomial of kth degree in the variable x (user-specified as the proc's
third argument) whose graph passes through those points.

The coordinates x__j must be distinct, but need not be equally spaced.

N_interp := proc(X::list, Y::list, x)
  local i, j, k, N;
  k := nops(X);
  if nops(Y) <> k then
    error "The x and y arrays should be of equals lengths";
  end if;
  N := Matrix(k);
  for j from 1 to k do
    N[1,j] := Y[j];
  end do;
  for i from 2 to k do
    for j from 1 to k + 1 - i do
      N[i,j] := (N[i-1,j+1] - N[i-1,j])/(X[j+i-1]-X[j]);
    end do;
  end do;
  unassign('i', 'j');
  N[1,1] + add(N[i+1,1]*product(x-X[j], j=1..i), i=1..k-1);
end proc:

 

Example:

X := [seq(i^2, i=0..3)];
Y := [seq(1/(i+1), i=0..3)];

[0, 1, 4, 9]

[1, 1/2, 1/3, 1/4]

ans := N_interp(X,Y,lambda);   # asking for a polynomial in lambda

1-(1/2)*lambda+(1/9)*lambda*(lambda-1)-(17/1440)*lambda*(lambda-1)*(lambda-4)

# verify the answer - should produce sequence of zeros if correct:

seq(eval(ans, lambda=X[i]) - Y[i], i=1..nops(X));

0, 0, 0, 0

 

 

Download newton-interpolation.mw

Tomleslie said there are other ways.  Here is one to produce the same object:

restart;
with(plots): with(plottools):
display(cuboid([0,0,0], [1,2,5]), scaling=constrained);

 

You don't need Maple for that—just looking at the equations it is evident theta(r)≡0 and sigma(r)≡0 is a solution.

First 33 34 35 36 37 38 39 Last Page 35 of 58