sand15

802 Reputation

11 Badges

10 years, 56 days

MaplePrimes Activity


These are replies submitted by sand15

@Carl Love 

 

Sorry for the last reply: the screen capture doesn't appear even if it was correctly correctly displayed in the preview window.
Il will try again when I am home

@radaar 

And I repeat too that your solution is {x(t)=sin(t), y(t)=cos(t)}
See also Preben's answer

@radaar 

I hope you have understood why your solution x(t) is just a sine wave (if not look to my answer to Kitonum).
The solution of SYS2 is just the one of SYS={diff(x(t), t)=y(t), diff(y(t), t)=-x(t), x(0)=0, y(0)=1}:

But, if you are still unconvinced, just do this

SYS := {diff(x(t), t)=y(t), diff(y(t), t)=-x(t), x(0)=0, y(0)=1}:
Tmax:=600:
GlobalPlot := NULL:
for n from 1 to floor(Tmax/8) do
   sol := dsolve(SYS, numeric, range=8*(n-1)..8*n):
   GlobalPlot := GlobalPlot, odeplot(sol, [t, x(t)], 8*(n-1)..8*n):
   X:=subs(sol(8*n), x(t)):
   Y:=subs(sol(8*n), y(t)):
   SYS :=  {diff(x(t), t)=y(t), diff(y(t), t)=-x(t), x(8*n)=X, y(8*n)=Y}:
end do:
plots:-display(GlobalPlot):


Still not convinced?
Then do this

restart:
gate := 1 - ( Heaviside(t - (8*n - epsilon)) - Heaviside(t - (8*n + epsilon)) ):
SYS := {diff(x(t), t) = y(t)*gate, diff(y(t), t) = -x(t)*gate, x(0)=0, y(0)=1}:
FormalSolution := solve(limit~(SYS, epsilon=0), {x(t}, y{t]);

FormalSolution is the solution of
{diff(x(t), t)=piecewise(t<>8*n, y(t), 0), diff(y(t), t)=piecewise(t<>8*n, -x(t), 0), x(0)=0, y(0)=1}
whatever the value of n.
Note FormalSolution is {x(t)=sin(t), y(t)=cos(t)}, meaning the discontinuity at t=8*n has absolutly no influence.

If you have several such rhs discontinuities, FormalSolution still represents the solution: the argument is that one discontinuity at t=8*n having no influence then a numerable number of them do not have neither

@Kitonum 

 

Consider the following problem:

gate := 1 - ( Heaviside(t - (8*n - epsilon)) - Heaviside(t - (8*n + epsilon)) ):
SYS := {diff(x(t), t) = y(t)*gate, diff(y(t), t) = -x(t)*gate, x(0)=0, y(0)=1}:

Would you say this system has no solution?
Easy to check that Maple returns one, at least one n and epsilon has recieved numerical values; for instance
dsolve(subs({n=1, epsilon=0.1}, SYS), {x(t), y(t)})

Now it is also obvious that the rhs of SYS tend to the rhs of SYS2 when epsilon --> 0.
And thus, at least for epsilon <> 0, the limit of the solution of SYS tend to the one of SYS2.


The solution x(t)  is "globally" a sine function, excepted in the range [8*n=epsilon, 8*n+epsilon] where it is flat with a constant value equal to x(8*n-epsilon).
More precisely x(t) is made of:

  1. a sine function sin(t)  from t=0 to t=8*n-epsilon (assuming n > 0),
  2. a plateau x(t)= x(8*n-epsilon) from t=8*n=epsilon to t= 8*n+epsilon,
  3. and finally a translated sine function sin(t+2*epsilon) beyond t=8*n+epsilon,

As epsilon  --> 0  this plateau shrinks at t=8*n and, when epsilon=0, the solution (the one of SYS2) is a continuous sine curve (a cosine cuve for y(t))

The numerical solution can easily be obtained with 
sol := dsolve(SYS, numeric, parameters=[n, epsilon])

 

 

Another point of view:

  1. Solve SYS from 0 to T=8*n-epsilon
    let's note sol1 the corresponding solution and XT and YT the values of the solution at timùe T for x(t) and y(t) respectivey
  2. Solve {diff(x(t), t) = y(t)*gate, diff(y(t), t) = -x(t)*gate, x(T)=XT, y(T)=YT} up to t=8*n+epsilon
    Obviously this second solution is x(t)=XT, y(t)=YT
    Let's note TT =8*n+epsilon
  3. Solve {diff(x(t), t) = y(t)*gate, diff(y(t), t) = -x(t)*gate, x(TT)=XT, y(TT)=YT}
  4. Connect these 3 solutions

@Mariusz Iwaniuk 

Is this one correct ?
(I think one should plot func and not ifunc)

Volterra2.mw

 

It's me again...

I used CurveFitting:-Spline with degrees 1 and 3, and CurveFitting:-PolynomialInterpolation with different values for the option 'form'.
In all the cases i get no error but the method seems to diverge.
More precisely, in my first answer I had plotted only  [sinh(x), ifunc(1)(x)]  and  [sinh(x), ifunc(2)(x)]  and it looked well ( ifunc(2)(x) was closer too sinh(x) than  ifunc(1)(x) was).
I pushed a little bit forward by plotting  [sinh(x), ifunc(4)(x)]  ... and  ifunc(1)(x)  looks like some kind of parabola A*x^2 with A < 0 !!!

Maybe I did inadvertently some mistake when I modified your code ????

@maple2015 

With the correct values of X and Y fsolve('DetKFF(z)', z=0.1) should return 0.362284....

 

@digerdiga 

As vv said "You are not allowed to expand like this.".

More generaly, a sequence S of terms can be convergent even the sequences build from parts of the terms are not.

Take this far-fetched exemple :
S[n]=n-n  for n >=0 ...  obviously S "converges" to 0
Write S as U+V with
U[n]=n and V[n]=-n 
Then U and V both diverge and S=U+V seems to be undefinite (+infinity)+(-infinity)
 

@vv

 

My mistakes:

  •  You also have a syntax error in f()  [a ":" after proc()  not accepted in 1d].
    Appologies, I rewrote the content of a pdf file; in the code the ":" are not present after proc()
    (furthermore it generates an error if there is a delcration statement after the "proc" line, for instance local ....)
     
  • I effectively made a mistake by tipping args(k) instead of instead of arg[k] (furthermore I knew the sorrect syntax
    Strangely it seems to be correctly interpreted by Maple 2015: printing the quantity named "objet" returns the correct name
     
  • Last but not least: One more time I have forgotten that names constructed with "||" are global !!

 

Then the answer is: either I use the awfull sequence
    if n=1 then print(Object1)
  elif n=2 then print(Object1)
  …
  end if

or either I construt a list ObjectList:=[Object1, ...ObjectN] and a list ListA := [A] and I do this

 Choice := proc(a::list)
  local n, object:
  n := ListTools:-Search(true, a):
  object := ObjectList[n]
  print(object):
end proc:


Thank's for your answer, even if it is not always pleasant to be remembered we are an airhead !

@tomleslie 

"  The advantage(?) of doing it this  ...": right, it seems a better (the only one?) way to manage "pseudo axis"
 

By the way: I did a mistake in my original post.
I wrote

  • the empirical marginal distribution of X (Histogram), put below the line "y = min({y[n], n=1..N} )" and rotated by 180 degrees

In fact I should have written:

  • the empirical marginal distribution of X (Histogram), put below the line "y = min({y[n], n=1..N} )" and SYMMETRIZED around the x axis

A simple task to do with plottools:-transform
reflection := plottools:-transform((x,y) -> [x, -y])

From now on the two histograms are placed correctly by using only plottools:-transform ... you deinitely gave me a good advice.
 

@ThU

It's good enough for me.

By the way, where did you find this stylesheet = [vertexcolor = "White",vertexborder=false]) info ?

Thanks again

@ThU 

 

Correction: CTRL+J doesn't work.


Thank you anyway
 

@ThU 
"Do you mean the vertical bar at the location of the cursor? " : Yes,

The problem is now solved (see my previous "auto-answer"), but I'm keeping by my side your "control-J" trick ... for the last time.
Thanks for the answer

 

 

  1. I opened the worksheet "W"  with an older Maple version (Maple 2015): it contained the vertical location bar
  2. I saved it with another name
  3. And finally opened this new fir with Maple 2018 ... and this bar was miraculously restored !!!

I let the people in charge of this site to decide for themselves  if this question/auto-answer must be retained or removed

@Carl Love 

I give up : I DON'T KNOW HOW TO DO AN OBJECTIVE COMPARISON

I used your last version of NimMatrix with parameters 5, 5  (NimMatrix(5,5))

Procedure 1 :
 T := NULL;
for r from 1 to 100 do
   T := T, CodeTools[Usage](Code(...), output=cputime)  # from your answer to the "other" thread
end do:
add(T)/100

Procedure 2 : (from acer's suggestion)
 CodeTools[Usage](Code(...), output=cputime, iterations=10


Results
  indicator                Proc 1                   Proc2            

 cpu time/run             16.9 s                     32.75 s             

memory size            0.95 GiB                  0.95 GiB

I repeated this twice and obtained the same ratio of 2 between the cpu times.
For proc1 the 10 times range between 15.49 s and 18.08 s

For "My best code" chich uses no sophisticated material nor the option remember, the cpu times are the same (up to unavoidable fluctuations) with proc1 and proc2.

Then : what is the cpu time (16 s or 32 s) I have to take to do an OBJECTIVE comparison ???

 

First 15 16 17 18 19 20 21 Last Page 17 of 25