## 90 Reputation

13 years, 150 days

## @Rouben Rostamian   Thanks for help...

Thanks for help. It worked!

## Thank you...

This is exactly what I was looking for. This will allow me to use the specific data.

Thank you

## Thank you...

Thank you for the link and the rplacing note whish also saved space.

## @Carl Love    Perfect!  T...

Perfect!

Thank you so much; this will save a lot of time.

## Thank you...

Thank you very much!

The steps are very clear and helped me. I appreciate it

## The goal...

For the given example I am solving equation (eq) 3 times each time with random value of  S=A[i]. Then from the 3 solutions that I have I am examining certain time i.e t=2 so I have 3 different intervals B1,B2 and B3 each start with 2 (that's why first element always 2) . After that I am taking only the maximum interval, which is in our case here B3 to do more work on it.

Yes, the purpose is to find the largest second element. However I need it as an interval to complete my work.

## @Kitonum  great yes that's fixed it...

great

yes that's fixed it.

Thank you so much

## @Carl Love  Thank you for your repl...

when I applied your line to my code I get this error message:

Error, sort: 2nd argument must be a function that always returns true or false

Thank you

## @Kitonum  Thank you for your replay...

Thank you for your replay. I added your two line to my code after the final do loop but it seems it's not working. I am  getting B4 instead of datamax:= [2., 51.78712780854305]. Did I apply it wrong?

Maple code:

restart;

n := 3;

for i to n do A[i] := RandomTools:-Generate(distribution(Uniform(.5, .75))) end do;

eq := diff(X(t), t) = -S*X(t);

ic[1] := X(0) = 150;

for i to n do s[i] := dsolve({ic[1], subs(S = A[i], eq)}, X(t), range = 0 .. 10, numeric) end do;

for i to n do B[i] := eval([t, X(t)], s[i](2)) end do;

sort([B[i]], proc (x, y) options operator, arrow; is(y[2] < x[2]) end proc);

datamax := %[1];

output:
B1:=[2., 36.718220544331125]
B2:=[2., 35.08378362904457]
B3:=[2., 51.78712780854305]
[B[4]]
B[4]

Thanks

## @Carl Love  Wow! I didn't know that...

Wow! I didn't know that it could be done this way. Thanks for simplfing my complicated code. It works great.

thank you very much appreciate it

## Thank you for your replay.  The ran...

The range of values of k and mu already in the slider. The problem solved when I used “subs dummy” and now it works.

Thank you

## Thank you for your replay.  The ran...

The range of values of k and mu already in the slider. The problem solved when I used “subs dummy” and now it works.

Thank you

## Thank you very much. the situation ...

Thank you very much. the situation is now clear

thanks

## Thank you very much. the situation ...

Thank you very much. the situation is now clear

thanks

## Hello, Thank you for replay. This p...

Hello,

Thank you for replay. This piecewise(0 > x(t) and x(t) > 1, 0, x(t) > 1, 1) makes sure that 0<=x(t)<=1 and x(t) is nonnegative. But since Maple consider it 0 otherwise I am having negative values for x(t).

Thank you

 1 2 3 4 Page 1 of 4
﻿