mmcdara

3728 Reputation

17 Badges

6 years, 32 days

MaplePrimes Activity


These are questions asked by mmcdara

I solve numerically a DAE system whose independent variable is named t and the dependent variables are d[1](t), ..., d[n](t).
I would like to to 2D or 3D plots of the solutions and color the resulting curve using a function f(...) of the remaining dependent variables.

Here is a simple example.

restart

with(plots):

0

(1)

sys := {
   diff(x(t), t) = v(t)
  ,diff(v(t), t) = cos(t)
  ,x(0) = -1
  ,v(0) = 0

  ,px(t) = piecewise(x(t) >=0, 1, -1)
  ,pv(t) = piecewise(v(t) >=0, 1, -1)
}:

sol := dsolve(sys, numeric):

 

odeplot(sol, [t, x(t), v(t)], t=0..4*Pi)
 

 

# I would like to color this space curve depending on the signs of x(t) and y(t)
#
# for instance, f being a "color function"
f := proc(s)
  local a, b:
  if s::numeric then
    a := round(eval(px(t), sol(s))):
    b := round(eval(pv(t), sol(s))):
    return piecewise(a+b = 2, "Green", a = 1, "Red", b = 1, "Blue", "Gold")
  end if:
end proc:

SOL := proc(s)
  if s::numeric then
    eval([t, x(t), v(t)], sol(s))
  end if:
end proc:


# I would like to make something like this to work

plot3d(SOL(s), s=0..4*Pi, colorfunc=f(s)):  #... which generates a void plot


 

# In some sense a continuous version of this

opts := symbol=solidbox, symbolsize=20:
display( seq(pointplot3d({SOL(s)}, opts, color=f(s)), s in [seq](0..6, 0.1)) );

 

 

Download coloring.mw

How can I fix (if possible) the syntax in the command 

plot3d(SOL(s), s=0..4*Pi, colorfunc=f(s)):

???

Thanks in advance

(Maple 2015)

Why is m1(t) not evaluated correctly when I use a compound condition?

restart:
m2(t) = piecewise(x1(t) < c and v1(t) < 0, 1,  0);
       m2(t) = piecewise(x1(t) < e2 and v1(t) < 0, 1, 0)

m1(t) = piecewise(x1(t) = c and v1(t) > 0, 0,  1);
                           m1(t) = 1

This doesn't happen for simple conditions
 

m2(t) = piecewise(x1(t) < c, 1,  0);
m1(t) = piecewise(x1(t) = c, 0,  1);
               m2(t) = piecewise(x1(t) < c, 1, 0)
               m1(t) = piecewise(x1(t) = c, 0, 1)

TIA

Sorry to bother moderators again but a question from @panke has just disappeared.
I browsed its old questions but found none in a recent past related to the one removed.
Can you please tell me where it has been moved ?

TIA

PS: I understand perfectly the need to avoid multiple occurrences of a same thread, but in case of the displacement of a question, couldn't a systematic message be sent?

I was developping an answer to @jennierubyjane  but the question disappeared meanwhile.

Here is the answer hopping for someone to restore the initial question (if it still matters?).
To  @jennierubyjane : comments and advices are in Maple 1D font within your original worksheet.

EDITED : Answer has been displaced here  233262-How-Do-I-Solve-Error-in-Dsolvenumericbvpconvertsys

I want to compute the series expansion of i3_r wrt (x, y, z) at point (x=y=z=0):

i2   := (x,y) -> -(1/2)*I*(exp(I*x)*(sin(x)/x)-exp(I*y)*(sin(y)/y))/(x-y):
i3_r := -(1/2)*I*(i2(y,z)-i2(y,x))/(z-x);

My first attempt was to compute this mulltiple series expansion this way:

ordre := 3:
sx := convert( series(i3_r, x, ordre), polynom);
sy := convert( series(sx  , y, ordre), polynom);
sz := convert( series(sy  , z, ordre), polynom);

But this gives me sy=sz=0 whatever the expansion order.

I then do this:

sx :=              convert(series(i3_r , x, ordre), polynom):
sy := add(map(u -> convert(series(u    , y, ordre), polynom), [op(expand(sx))])):
sz := add(map(u -> convert(series(u    , z, ordre), polynom), [op(expand(sy))]));

and obtained non zero results for both sy and sz (but are they are correct ?).

Could you explain me what happens and tell me how to find the series expansion of i3_r wrt (x, y, z) ?

TIA

1 2 3 4 5 6 7 Last Page 2 of 33