mmcdara

6750 Reputation

18 Badges

8 years, 193 days

MaplePrimes Activity


These are answers submitted by mmcdara


 

restart:

with(Finance):

W := WienerProcess():

P := PathPlot(W(t), t = 0..3, timesteps = 50, replications = 1):
P;

 

W__points := plottools:-getdata(P)[1, -1]

`#msub(mi("W"),mi("points"))` := Vector(4, {(1) = ` 51 x 2 `*Matrix, (2) = `Data Type: `*float[8], (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

(1)

f := (t, lambda) -> exp(lambda*t)

proc (t, lambda) options operator, arrow; exp(lambda*t) end proc

(2)

Lambda := -1:

Z__points := `<|>`(W__points[..,1], W__points[..,2] *~ f~(W__points[..,1], Lambda))

`#msub(mi("Z"),mi("points"))` := Vector(4, {(1) = ` 51 x 2 `*Matrix, (2) = `Data Type: `*anything, (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

(3)

plot([W__points, Z__points], color=[blue, red], legend=[typeset('W'(t)), typeset('W'(t)*exp(Lambda*t))])

 

 


 

Download WienerProcess.mw

In case your Maple version does not have Statistics:-HeatMap (which is unnecessary given you have only two colors), I propose you two alternatives based upon plots:-sparsematrixplot

Option 1 (the simplest... IMO)

restart:
go2 := proc() 
  plots:-sparsematrixplot(LinearAlgebra:-RandomMatrix(50, generator = 0 .. 1), axes = none)
end proc:

plots:-animate(go2, [], i = 1 .. 10, frames=10, background=gray, title="")


Option 2 (using Explore the way acer did)

restart
go2 := proc(i) 
  plots:-display(
    plots:-sparsematrixplot(LinearAlgebra:-RandomMatrix(50, generator = 0 .. 1), axes = none)
    , plottools:-rectangle([0.5$2], [50.5$2], color=gray, style=polygon)
  ) 
end proc:

Explore(go2(i), parameters=[i = 1 .. 10], animate, numframes = 10)

 

MyRule := cos = (theta -> sqrt(1-sin(theta)^2));

Then, e being some expression invoking sines and cosines, remove these latters by executing

eval(e, MyRule)

But you must be more detailed and, by the way, providing an example would help us delivering a better solution.


... by chosing a good model (and this is not a joke !).

PART ONE: OUT OF ANY PHYSICAL CONSIDERATIONS

Looking to your experimental points suggest a fisrst order approximation could be a "capacitor charge curve".
So a model of the form:

(1-exp(-beta*t) / (1-exp(-beta))    (with beta > 0)


Using this extremely simple model already gives a pretty good result provided the addition of a scaling parameter

CapacitorCharge := t ->  scaling * (1 -exp(-beta*t)) / (1-exp(-beta)):

obj := add( ( CapacitorCharge~(c_time) - c_strain )^~2 ):

opt := NLPSolve(obj, {beta >= 1e-6, scaling >= 1e-6 });

 [0.00306881881374611830, [beta = 1.7599456583228286), scaling = 0.16882154828021012]]

display(
   ScatterPlot(c_time, c_strain, symbol=circle, color=blue),
   plot(eval(CapacitorCharge(t), opt[2]), t=0.00..max(c_time), color=black)
)

It's up to you to add more components with the same generic model.
For instance

CapacitorCharge := (t, s, b) ->  s * (1 -exp(-b*t)) / (1-exp(-b)):

TwoComponentModel := unapply(CapacitorCharge(t, s1, b1)  + CapacitorCharge(t, s2, b2), t):

obj := add( ( TwoComponentModel~(c_time) - c_strain )^~2 ):

eps := 1e-6:
opt := Optimization:-NLPSolve(
              obj
              , {
                   s1 >= eps
                   , s2 >= 2*s1  # illustrative example
                   , b1 >= eps
                   , b2 >= 2*b1  # illustrative example
                }
             ):

plots:-display(
   Statistics:-ScatterPlot(c_time, c_strain, symbol=circle, color=blue)
   , plot(eval(TwoComponentModel(t), opt[2]), t=0.00..max(c_time), color=black)
)



Why did you fail?
I suggest you to begin modifying your creep_strain procedure this way

creep_strain := proc(t, n)
  epsilon[0]*(1 + alpha[theta]*add(-(B[i]*(-beta[i]*t + exp(-beta[i] *t) -1))/beta[i],i=1..n))
end proc;

and use Explore to see what happens, in particular how your model (and already its single component version that creep_strain(t, 1) represents) looks almost linear in the range t=0..5

# My Maple 2015 doesn't accept indexed parameters:

One_component_model := eval(creep_strain(t, 1), {B[1] = p, beta[1] = q});

Explore( plot(One_component_model, t=0..5),  parameters=[p=1e-3 .. 1, q=1e-4..1e-2]);


This plot is also quite informative.

plots:-display(
   Statistics:-ScatterPlot(c_time, c_strain, symbol=circle, color=blue)
   , plot(eval(CapacitorCharge(t), opt[2]), t=0.00..max(c_time), color=black)
   , plot(eval(creep_strain(t, 1), eval(opt[2], {scaling=B[1], beta=beta[1]})), t=0.00..max(c_time), color=red)
)



PART TWO: ACCOUNTING FOR PHYSICAL CONSIDERATIONS

Your data come very likely from experiments on some viscoelastic material whose behavior you have inferred could be modeled by your creep_strain function.
As it seems not to be the case, this mean that your hypothesis is not coroborated by the observations, so use another viscoelastic model.
For instance, a simple Kelvin-Voigt model gives this:

(the # The bounds have to be adjusted trick prevents getting identical components, an alternative possibiily using a penalized objective function is given further)
 

restart;

with(Statistics):with(plots):with(Optimization):with(LinearAlgebra):


# given data from strain rate curve
E_0[theta] := 7.883352314*10^9;
alpha__theta:= 0.982

7883352314.

 

.982

(1)


# experimental creep data under 44 at 100 degree celcius
c_strain := Vector ([<<0>,<0.0284698>,<0.0533808>,<0.0782918>,<0.0996441>,<0.124555>,<0.142349>,<0.156584>,<0.16726>,<0.177936>,<0.181495>,<0.188612>,<0.192171>,<0.19573>,<0.19573>,<0.202847>,<0.206406>,<0.206406>,<0.209964>,<0.209964>,<0.209964>,<0.206406>,<0.209964>>]):

c_time := Vector ([<<0>,<0>,<0.048>,<0.192>,<0.352>,<0.544>,<0.704>,<0.896>,<1.088>,<1.312>,<1.52>,<1.76>,<1.984>,<2.208>,<2.464>,<2.736>,<3.088>,<3.392>,<3.664>,<4.016>,<4.352>,<4.592>,<4.832>>]):
sigma[0] := 44*10^6;
epsilon[0] := sigma[0]/E_0[theta];

44000000

 

0.5581381911e-2

(2)


# change vector to list
c_strain := convert(c_strain,list):
c_time := convert(c_time,list):

# extract zero from list
c_strain := c_strain [2..-1];
c_time := c_time [2..-1];

[0.284698e-1, 0.533808e-1, 0.782918e-1, 0.996441e-1, .124555, .142349, .156584, .16726, .177936, .181495, .188612, .192171, .19573, .19573, .202847, .206406, .206406, .209964, .209964, .209964, .206406, .209964]

 

[0, 0.48e-1, .192, .352, .544, .704, .896, 1.088, 1.312, 1.52, 1.76, 1.984, 2.208, 2.464, 2.736, 3.088, 3.392, 3.664, 4.016, 4.352, 4.592, 4.832]

(3)


# for further calculation need to know how many elements are in the list
M := nops(c_strain);
N := nops(c_time);

22

 

22

(4)

CreepCompliance := (t, b) ->  (1 -exp(-b*t)) / b;

NComponentModel := n -> unapply( add((s||i)*CreepCompliance(t, b||i) , i=1..n), t):

obj := add( ( NComponentModel(1)~(c_time) - c_strain )^~2 ):

eps := 1e-6:
opt1 := Optimization:-NLPSolve( obj, {s1 >= eps , b1 >= eps});

p1 := plot(eval(NComponentModel(1)(t), opt1[2]), t=0.00..max(c_time), color=red, legend="1 component"):

proc (t, b) options operator, arrow; (1-exp(-b*t))/b end proc

 

[0.306881881374612654e-2, [b1 = HFloat(1.759945698076013), s1 = HFloat(0.3588601594387053)]]

(5)

obj := add( ( NComponentModel(2)~(c_time) - c_strain )^~2 ):


# The bounds have to be adjusted
opt2 := Optimization:-NLPSolve( obj, {s1 >= eps , b1 >= eps, seq(s||i >= i*s1, i=2..2), seq(b||i <= b1/i, i=2..2)}, iterationlimit=1000);

p2 := plot(eval(NComponentModel(2)(t), opt2[2]), t=0.00..max(c_time), color=gold,  legend="2 component"):

[0.248686340520870054e-2, [b1 = HFloat(9.456637765812436), b2 = HFloat(1.5989324936628084), s1 = HFloat(0.151139596903752), s2 = HFloat(0.302279193807504)]]

(6)

obj := add( ( NComponentModel(3)~(c_time) - c_strain )^~2 ):

# The bounds have to be adjusted
opt3 := Optimization:-NLPSolve( obj, {s1 >= eps , b1 >= eps, seq(s||i >= i*s1, i=2..3), seq(b||i <= b1/i, i=2..3)}, iterationlimit=1000);


p3 := plot(eval(NComponentModel(3)(t), opt3[2]), t=0.00..max(c_time), color=green, legend="3 component"):

[0.903884243564256960e-3, [b1 = HFloat(2623.8980292663596), b2 = HFloat(1003.4673088312021), b3 = HFloat(1.2326587006633738), s1 = HFloat(0.019813059395107035), s2 = HFloat(44.00190510657462), s3 = HFloat(0.203419406454798)]]

(7)

plots:-display(
   Statistics:-ScatterPlot(c_time, c_strain, symbol=circle)
   , p1, p2, p3
)

 

 

 

Download Kelvin_Voigt_mmcdara.mw


Here is the penalized version: Kelvin_Voigt_penalized_mmcdara.mw

 

@AHSAN 

RandColor := () -> ColorTools:-Color([seq(rand(0. .. 1.)(), i=1..3)]):

plot_list := [
  seq(
    plot(
      data_points[][i]
      , legend=typeset(''epsilon'' = `&epsilon;_values`[i])
      , color = RandColor()
     )
     , i = 1 .. nops(data_points)
    )
]:

plots:-display(
  plot_list
  , title="P_max vs. k"
  , labels=["k", "P_max"]
)

I used RandColor but you can also defime tge colors this way:

MyColors := [red, green, blue, ...]:

plot_list := [
  seq(
    plot(
      data_points[][i]
      , legend=typeset(''epsilon'' = `&epsilon;_values`[i])
      , color = MyColors[i]
     )
     , i = 1 .. nops(data_points)
    )
]:

plots:-display(
  plot_list
  , title="P_max vs. k"
  , labels=["k", "P_max"]
)

Note: I used a slightly different example as yours does not contain any first derivative of the y functions.

Worksheet fuxian1030_mmcdara.mw contains a step-by-step code to make you understand more easily the approach I used.
It is basically the assembling strategy @dharr talked about, excepted I did not use dcoeffs

A procedure which provides the same result the previous worksheet does is:

restart

eqmat := proc(eqs)
  local neq  := numelems(eqs):
  local U, f, Udeg, a, b, n, sub, M, S, SUB, d:

  uses LinearAlgebra:

  U     := convert( remove(has, indets(eqs, function), diff), list);
  f     := convert( indets(eqs, function), list);
  Udeg  := degree~(eval(eval(f, U =~ exp(K*t)), t=0), K);
  a, b  := (min, max)(Udeg);

  for n from 1 to neq do
    op||n := [op(lhs(eqs[n]))];
  end do;

  SUB := 0:
  for d from b to a+1 by -1 do
    sub  := [ seq( add( select(has, op||n, diff~(U, t$d)) ) = 0, n=1..neq) ];
    M, S := GenerateMatrix(sub,  diff~(U, t$d));
    SUB  := SUB + (M . ``(< diff~(U, t$d) >) = S);

    for n from 1 to neq do
      op||n := remove(has, op||n, diff~(U, t$d));
    end do:
  end do:

  sub  := [ seq( add( select(has, op||n, U) ) = 0, n=1..neq) ];
  M, S := GenerateMatrix(sub,  U);
  SUB  := SUB + (M . ``(< U >) = S);
  
  return SUB
end proc:

  


Illustration 1

eqn1 := m__1*(diff(y__1(t), `$`(t, 2)))+k__1*y__1(t)+k__2*(y__1(t)-y__2(t))-eta__1*(diff(y__1(t), t)) = 0;
eqn2 := m__2*(diff(y__2(t), `$`(t, 2)))+k__2*(y__2(t)-y__1(t))+eta__2*(diff(y__2(t), t)) = 0;
 

m__1*(diff(diff(y__1(t), t), t))+k__1*y__1(t)+k__2*(y__1(t)-y__2(t))-eta__1*(diff(y__1(t), t)) = 0

 

m__2*(diff(diff(y__2(t), t), t))+k__2*(y__2(t)-y__1(t))+eta__2*(diff(y__2(t), t)) = 0

(1)

eqmat([eqn1, eqn2])

Typesetting[delayDotProduct](Matrix(2, 2, {(1, 1) = `#msub(mi("m"),mi("1"))`, (1, 2) = 0, (2, 1) = 0, (2, 2) = `#msub(mi("m"),mi("2"))`}), `.`(Vector(2, {(1) = diff(`#msub(mi("y"),mi("1"))`(t), t, t), (2) = diff(`#msub(mi("y"),mi("2"))`(t), t, t)})), true)+Typesetting[delayDotProduct](Matrix(2, 2, {(1, 1) = -`#msub(mi("&eta;",fontstyle = "normal"),mi("1"))`, (1, 2) = 0, (2, 1) = 0, (2, 2) = `#msub(mi("&eta;",fontstyle = "normal"),mi("2"))`}), `.`(Vector(2, {(1) = diff(`#msub(mi("y"),mi("1"))`(t), t), (2) = diff(`#msub(mi("y"),mi("2"))`(t), t)})), true)+Typesetting[delayDotProduct](Matrix(2, 2, {(1, 1) = `#msub(mi("k"),mi("1"))`+`#msub(mi("k"),mi("2"))`, (1, 2) = -`#msub(mi("k"),mi("2"))`, (2, 1) = -`#msub(mi("k"),mi("2"))`, (2, 2) = `#msub(mi("k"),mi("2"))`}), `.`(Vector(2, {(1) = `#msub(mi("y"),mi("1"))`(t), (2) = `#msub(mi("y"),mi("2"))`(t)})), true) = (Vector(2, {(1) = 0, (2) = 0}))

(2)


In case the odes contain functions other than y__1(t) and y__2(t):

eqmat := proc(eqs, U)
  local neq  := numelems(eqs):
  local f, Udeg, a, b, n, sub, M, S, SUB, d:

  uses LinearAlgebra:

  f     := convert( indets(eqs, function), list);
  Udeg  := degree~(eval(eval(f, U =~ exp(K*t)), t=0), K);
  a, b  := (min, max)(Udeg);

  for n from 1 to neq do
    op||n := [op(lhs(eqs[n]))];
  end do;

  SUB := 0:
  for d from b to a+1 by -1 do
    sub  := [ seq( add( select(has, op||n, diff~(U, t$d)) ) = 0, n=1..neq) ];
    M, S := GenerateMatrix(sub,  diff~(U, t$d));
    SUB  := SUB + (M . ``(< diff~(U, t$d) >) = S);

    for n from 1 to neq do
      op||n := remove(has, op||n, diff~(U, t$d));
    end do:
  end do:

  sub  := [ seq( add( select(has, op||n, U) ) = 0, n=1..neq) ];
  M, S := GenerateMatrix(sub,  U);
  SUB  := SUB + (M . ``(< U >) = S);
  
  return SUB
end proc:

eqn1 := m__1*(diff(y__1(t), `$`(t, 2)))+k__1*y__1(t)+k__2*(y__1(t)-y__2(t))-eta__1(t)*(diff(y__1(t), t)) = 0;
eqn2 := m__2(t)*(diff(y__2(t), `$`(t, 2)))+k__2*(y__2(t)-y__1(t))+eta__2(t)*(diff(y__2(t), t)) = 0;
 

m__1*(diff(diff(y__1(t), t), t))+k__1*y__1(t)+k__2*(y__1(t)-y__2(t))-eta__1(t)*(diff(y__1(t), t)) = 0

 

m__2(t)*(diff(diff(y__2(t), t), t))+k__2*(y__2(t)-y__1(t))+eta__2(t)*(diff(y__2(t), t)) = 0

(3)

eqmat([eqn1, eqn2], [y__1(t), y__2(t)])

Typesetting[delayDotProduct](Matrix(2, 2, {(1, 1) = `#msub(mi("m"),mi("1"))`, (1, 2) = 0, (2, 1) = 0, (2, 2) = `#msub(mi("m"),mi("2"))`(t)}), `.`(Vector(2, {(1) = diff(`#msub(mi("y"),mi("1"))`(t), t, t), (2) = diff(`#msub(mi("y"),mi("2"))`(t), t, t)})), true)+Typesetting[delayDotProduct](Matrix(2, 2, {(1, 1) = -`#msub(mi("&eta;",fontstyle = "normal"),mi("1"))`(t), (1, 2) = 0, (2, 1) = 0, (2, 2) = `#msub(mi("&eta;",fontstyle = "normal"),mi("2"))`(t)}), `.`(Vector(2, {(1) = diff(`#msub(mi("y"),mi("1"))`(t), t), (2) = diff(`#msub(mi("y"),mi("2"))`(t), t)})), true)+Typesetting[delayDotProduct](Matrix(2, 2, {(1, 1) = `#msub(mi("k"),mi("1"))`+`#msub(mi("k"),mi("2"))`, (1, 2) = -`#msub(mi("k"),mi("2"))`, (2, 1) = -`#msub(mi("k"),mi("2"))`, (2, 2) = `#msub(mi("k"),mi("2"))`}), `.`(Vector(2, {(1) = `#msub(mi("y"),mi("1"))`(t), (2) = `#msub(mi("y"),mi("2"))`(t)})), true) = (Vector(2, {(1) = 0, (2) = 0}))

(4)
 

 

Download fuxian1030_mmcdara_2.mw

I'm always puzzled by your questions: are you looking for the reasoning that leads to the solution, or for the way to get it with Maple, using only its built-in functions?
Whatever here are rsponses for those two situations:

restart:

0

(1)


Reasoning

#  Prob(Ben + Jamie) = 50
#  Prob(Ben + Jamie) = Prob(Ben = 5 and Jamie=45)
#                      +
#                      Prob(Ben = 10 and Jamie=40)
#                      +
#                      Prob(Ben = 20 and Jamie=30)
#  
#  Prob(Ben + Jamie) = 0 * 0
#                      +
#                      1/3 * 1/2
#                      +
#                      1/3 * 1/2
#  
#  Prob(Ben + Jamie) = 1/6
#                      +
#                      1/6
#  
#  Prob(Ben + Jamie) = 1/3


or using the heavy artillery

with(Statistics):

Ben  := RandomVariable(EmpiricalDistribution([5, 10, 20])):
Jamie := RandomVariable(EmpiricalDistribution([30, 40])):

Total := Ben + Jamie

_R+_R0

(2)

# Maple failure

Probability(Total = 50) # ????

0

(3)

# Workaround

eps := 10^(-6):  # any strictly positive value strictly lower than 5
Probability(Total <= 50+eps) - Probability(Total <= 50-eps)

1/3

(4)
 

 

Download Prob.mw

@Alfred_F 

@vv  idea:

 

restart

with(plots):
with(plottools):

R := 1

1

(1)

C := 2*Pi/3*R + h + 4*alpha*(R-h);
S := Pi/3*R^2;

(2/3)*Pi+h+4*alpha*(1-h)

 

(1/3)*Pi

(2)

dom := solve(
         {
           C = 2*Pi*R
           , S = Pi*R^2/3
           , h > 0
           , H > 0
           , h+H < R
           , alpha > 0
         }
         , {alpha, h, H}
       )
       assuming R > 0

{alpha = -(1/12)*(4*Pi-3*h)/(h-1), 0 < H, 0 < h, H < 1, h < 1-H}

(3)

# example 0 (the simplest one)

__h := 0:
hdom := eval(dom, h=__h);

solve(select(has, %, H));

__H := 1/6;

__alpha := eval(alpha, select(has, hdom, alpha));


pattern := (c1, c2) -> display(
  sector([0, 0], R-__h-__H.. R-__h, 0..__alpha, color=c1, style=polygon),
  sector([0, 0], 1, 0..2*Pi/3, color=c2, style=polygon),
  sector([0, 0], R-__h-__H.. R-__h, 0..2*Pi/3+__alpha, color=c2, style=polygon)
):

{alpha = (1/3)*Pi, 0 < 0, 0 < H, 0 < 1-H, H < 1}

 

{0 < H, H < 1}

 

1/6

 

(1/3)*Pi

(4)

cou := ["red", "green", "blue"]:

display(
  seq(rotate(pattern(cou[i], cou[4-i]), 2*Pi/3*(i-1)), i=1..3)
  , scaling=constrained
);

 

 

# example 1:

__h := 1/4:
hdom := eval(dom, h=__h);

solve(select(has, %, H));

__H := 1/2;

__alpha := eval(alpha, select(has, hdom, alpha));


pattern := (c1, c2) -> display(
  sector([0, 0], R-__h-__H.. R-__h, 0..__alpha, color=c1, style=polygon),
  sector([0, 0], 1, 0..2*Pi/3, color=c2, style=polygon),
  sector([0, 0], R-__h-__H.. R-__h, 0..2*Pi/3+__alpha, color=c2, style=polygon)
):

{alpha = (4/9)*Pi-1/12, 0 < 1/4, 0 < H, 0 < 3/4-H, H < 1}

 

{0 < H, H < 3/4}

 

1/2

 

(4/9)*Pi-1/12

(5)

cou := ["red", "green", "blue"]:

display(
  seq(rotate(pattern(cou[i], cou[4-i]), 2*Pi/3*(i-1)), i=1..3)
  , scaling=constrained
);

 

# example 2:

__h := 1/6:
hdom := eval(dom, h=__h);

solve(select(has, %, H));

__H := 4/6;

__alpha := eval(alpha, select(has, hdom, alpha));


pattern := (c1, c2) -> display(
  sector([0, 0], R-__h-__H.. R-__h, 0..__alpha, color=c1, style=polygon),
  sector([0, 0], 1, 0..2*Pi/3, color=c2, style=polygon),
  sector([0, 0], R-__h-__H.. R-__h, 0..2*Pi/3+__alpha, color=c2, style=polygon)
):

{alpha = (2/5)*Pi-1/20, 0 < 1/6, 0 < H, 0 < 5/6-H, H < 1}

 

{0 < H, H < 5/6}

 

2/3

 

(2/5)*Pi-1/20

(6)

cou := ["red", "green", "blue"]:

display(
  seq(rotate(pattern(cou[i], cou[4-i]), 2*Pi/3*(i-1)), i=1..3)
  , scaling=constrained
);

 

 


 

Download trisection.mw


In the rectangle ABCB I set  A = (a, 3) and C = (5, b).
Then (anticlockwise sense)  B = (5, 3) and D = (a, b).

Implicit assumptions: a <> 5 and b <> 3  (see further on)
 

restart
local D
A := a, 3: 
C := 5, b:
B := C[1], A[2]:
D := A[1], C[2]:

# equation of the line BD joining B and D
slope     := ( D[2]-B[2] ) / ( D[1]-B[1] ):
intercept := B[2]:
shift     := B[1]:
BD        := -slope*(x-shift)+intercept:

solve(identity(BD = 2*x+c, x))      

                 {a = a, b = -2 a + 13, c = -7}


Here are the solutions we get using package geometry (which exhibits the conditions for the problem to have a solution) with_geometry.mw

With my Maple 2015 version display doesn't accept legends, so I modified approxPlot and ActualLine accordingly.
One way to fix the "log issue" is to set Digits to a high value (here 40).

slight_adjustments.mw

There is no need to convert such a simple comment into an answer, so I ask anyone who could be tempted to do this to think otherwise.
Thanks in advance.

@Stretto

A trick to force randomize() to generate a different seed for successive calls in the row:

restart
kernelopts(version)
Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895

randomize(rand()());
for i from 1 to 5 do
  randomize(rand()());
end do;
                          748886360495
                          654798511244
                          711907514675
                          83349168327
                          652437266289
                          514482612642

Informations about the delay time between successive calls of  randomize() for them to generate different seeds, and random generation of color sequences are given in the attached file

restart

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(1)

# Sleep time = 0.1 second.

StringTools:-FormatTime("%Y-%m-%d %H:%M:%S");

r := randomize();
for i from 1 to 5 do
  Threads:-Sleep(0.1):
  r := r, randomize():
end do:
[r][2..5] -~ [r][1..4]

"2024-10-13 20:58:37"

 

172884591703284

 

[0, 0, 0, 100000]

(2)

# Sleep time = 0.5 second.

StringTools:-FormatTime("%Y-%m-%d %H:%M:%S");

r := randomize();
for i from 1 to 5 do
  Threads:-Sleep(0.5):
  r := r, randomize():
end do:
[r][2..5] -~ [r][1..4]

"2024-10-13 20:58:38"

 

172884591803284

 

[0, 100000, 0, 100000]

(3)

# Sleep time = 1 second.

StringTools:-FormatTime("%Y-%m-%d %H:%M:%S");


r := randomize();
for i from 1 to 5 do
  Threads:-Sleep(1):
  r := r, randomize():
end do:

[r][2..5] -~ [r][1..4]

"2024-10-13 20:58:40"

 

172884592003284

 

[100000, 100000, 100000, 100000]

(4)

# Sleep time = 2 seconds

StringTools:-FormatTime("%Y-%m-%d %H:%M:%S");

r := randomize();
for i from 1 to 5 do
  Threads:-Sleep(2):
  r := r, randomize():
end do:

[r][2..5] -~ [r][1..4]

"2024-10-13 20:58:45"

 

172884592503284

 

[200000, 200000, 200000, 200000]

(5)

# A trick to force randomize() to generate a different seed almost instatenously

randomize(rand()());
for i from 1 to 5 do
  randomize(rand()());
end do;

470050003177

 

257848795012

 

381950329600

 

25592485277

 

162733964008

 

140513006590

(6)

# Random generations in a row of sequences of 4 colors

u := rand(0. .. 1.):
for i from 1 to 10 do
  randomize(rand()()):
  print( seq( ColorTools:-Color([u(), u(), u()]), j=1..4) )
end do:

_m4533002976, _m4533007200, _m4533011424, _m4533015648

 

_m4534440416, _m4534444640, _m4534448864, _m4534473568

 

_m4534579392, _m4534567232, _m4533772736, _m4533768768

 

_m4533505952, _m4533403680, _m4533399712, _m4533395744

 

_m4532108928, _m4532104960, _m4532100992, _m4532064256

 

_m4531649856, _m4531645888, _m4531641920, _m4531637952

 

_m4531592160, _m4531588192, _m4531584224, _m4531432800

 

_m4530772800, _m4530777504, _m4531994048, _m4532000032

 

_m4532087424, _m4532091776, _m4532223072, _m4532227488

 

_m4534440032, _m4534444448, _m4534448960, _m4534473856

(7)

# The a-priori-natural way to do this

u := rand(0. .. 1.):
for i from 1 to 10 do
  randomize():
  print( seq( ColorTools:-Color([u(), u(), u()]), j=1..4) )
end do:

_m4439707776, _m4439729440, _m4439736096, _m4439741824

 

_m4441450144, _m4441454368, _m4441458592, _m4441462816

 

_m4441518144, _m4441841856, _m4441846080, _m4441850304

 

_m4441909728, _m4441913952, _m4441918176, _m4441922400

 

_m4442424192, _m4442452992, _m4442457216, _m4442461440

 

_m4442725664, _m4442729888, _m4442824224, _m4442828448

 

_m4442863296, _m4442867520, _m4442871744, _m4443166784

 

_m4443231584, _m4443235808, _m4443240032, _m4443244256

 

_m4440702720, _m4440706944, _m4440776704, _m4440780928

 

_m4442171552, _m4442241312, _m4442245536, _m4442249760

(8)

# A little bit less safe (latency=0.001 second) than the randomize(rand()()) trick

for i from 1 to 10 do
  randomize(1000*parse(StringTools:-FormatTime("%y%m%d%H%M%S"))+round(time()*1000));
  print( seq( ColorTools:-Color([u(), u(), u()]), j=1..4) )
end do:

_m4521591648, _m4521587680, _m4521583712, _m4521579744

 

_m4521542624, _m4521538656, _m4521112800, _m4521108832

 

_m4521071744, _m4521067776, _m4521063808, _m4521059840

 

_m4520797440, _m4520793472, _m4520789504, _m4520785536

 

_m4520474048, _m4520470080, _m4520466112, _m4520462144

 

_m4520425024, _m4520421056, _m4520281920, _m4520277952

 

_m4520240864, _m4520236896, _m4520232928, _m4520228960

 

_m4519970656, _m4519966688, _m4519962720, _m4519958752

 

_m4519708704, _m4519704736, _m4519700768, _m4519696800

 

_m4519659680, _m4519655712, _m4519516576, _m4519512608

(9)
 

 

Download here.mw

@AHSAN 

Note that we could get a far better rendering giving up ColumnGraph and using directly PLOT or plottools
Whatever here is a Proposal.mw

I was about to deliver my reply when I saw acer has been faster.
Whatever here is a vay to construct rapidly the curve Y1=f(X1) (I hope I didn't make any mistake)
Proc_Error_mmcdara.mw

restart;

# At this point no there is no assigned names as the following command confirms
anames(user);  # nothing displayed

read "C:\\Program Files (x86)\\Maple 11\\test3.m";

# Run again anames(user) to see what are the names which where saved in the m file
anames(user);  # now a sequence of names is displayed, unless the m file is empty

# Let us assume A is one of the names
# To display its content type eval(A).
# You may also check it's type using whattype(A).


Example:  read.mw

Here is a procedure named Echo which reads a m file and displays its content Echo.mw, more or less what you expected from interface(echo=(integer > 2)) to do.

First one

0.6 instead of 0, 6

Second one

-1 instead of --1

Once corrected:

eq := u = 0.6*sqrt(t)-1+exp(-t)

u = .6*t^(1/2)-1+exp(-t)

(1)

# solve eq wrt u (obvious result)

solve(eq, u)

.6000000000*t^(1/2)-1.+exp(-1.*t)

(2)

# solve eq wrt t

solve(eq, t);

2.777777778*(u*exp(RootOf(-25*(exp(_Z))^2*u^2+9*_Z*(exp(_Z))^2-50*(exp(_Z))^2*u-25*(exp(_Z))^2+50*u*exp(_Z)+50*exp(_Z)-25))+exp(RootOf(-25*(exp(_Z))^2*u^2+9*_Z*(exp(_Z))^2-50*(exp(_Z))^2*u-25*(exp(_Z))^2+50*u*exp(_Z)+50*exp(_Z)-25))-1.)^2/(exp(RootOf(-25*(exp(_Z))^2*u^2+9*_Z*(exp(_Z))^2-50*(exp(_Z))^2*u-25*(exp(_Z))^2+50*u*exp(_Z)+50*exp(_Z)-25)))^2

(3)

# To go further you have to give u some value, for instance 1:

[solve(eval(eq, u=1), t)]; # t is useless as eval(eq, u=1) only depends on t
number_of_solutions := numelems(%);

[11.11094502, -.6795452073-.2578617583*I, -.6795452073+.2578617583*I, -.6675848351-20.36043710*I, -.6675848351+20.36043710*I, -.5133022487-13.86497050*I, -.5133022487+13.86497050*I, -.3856082244-7.202703595*I, -.3856082244+7.202703595*I]

 

9

(4)

fsolve(eval(eq, u=1))

11.11094502

(5)

fsolve(eval(eq, u=1), complex)

-.6795452073+.2578617583*I

(6)

# Note that
# fsolve(eval(eq, u=1), {t}, complex, maxsols=number_of_solutions)
# returns only the previous solution in Maple 2015


Download fsolve.mw

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