Kitonum

20214 Reputation

26 Badges

15 years, 318 days

MaplePrimes Activity


These are replies submitted by Kitonum

@Carl Love  for the useful information on the binary search.

@Carl Love  I did not understand the meaning of your comment. Did you mean that the procedure should check that the given list already is sorted and produce an error message otherwise? Or something else?

@Loeky Haryanto 

You can leave the arrows in your code, but then you should write  g:=x->f(x)+a[i]*x^(k-1)  instead of  f:=x->f(x)+a[i]*x^(k-1) , because a contradiction arises: f  is determined through f. In fact, on the left you have one function, and on the right - the other.

This works:

restart;
P:= 7919; #(this is the1000-th prime)
S:=5000; k:=5:
a:=[0$i=1..k];
f:=[0$i=1..k];
a[1]:=S;
f:=x->a[1];

with(RandomTools):
for i from 2 to k do
a[i]:=Generate(integer(range=1..P-1));
g:=x->f(x)+a[i]*x^(k-1);
g(x);
od;

@ravenHound  May be  plots:-textplot  command will be usefull:

restart;
f:=(x,c,k)->c*x/(k+x):
plots:-display(plot([f(x,5,2), f(x,5,3)], x=0..50, color=[red,blue], size=[800,400]), plots:-textplot([[12,4.5,"k=2"], [12,3.8,"k=3"]], font=[times,16])) ;

 

I just copied your code into the Maple 2018 worksheet. There are no errors:

restart;
g := x -> (10*x)/(3+x);

f := x -> (10*x)/(5+x);

h := x -> (8*x)/(5+x);

plots:-display(
  plot( [g(x),f(x), h(x)], x=0..30, color=[red,blue, green], legend = ["k=3,c=10", "k=5, c=10","k=5,c=8"]));


Addition. plots:-display  is superfluous in your code.  

 plot( [g(x),f(x), h(x)], x=0..30, color=[red,blue, green], legend = ["k=3,c=10", "k=5, c=10","k=5,c=8"]);

works exactly the same.

@zdamasceno  Now everything is clear. At first I just did not understand the meaning of what you first called the boundary condition. In fact, this is just an initial approximation using Newton's method. In Maple, you do not need to specify it. Here are 2 solutions to your example. In the first, this initial approximation is indicated. In the second solution, the range for the wanted solution is specified instead. The results (lists  S1  and  S2) are identical.


 

restart;
eqns := {(1-sin(b_u)*sin(s)/(cos(b_u-y_f)*cos(s-y_f)))*(1/cos(s-y_f)^2-1/sin(s)^2) = -(cot(s)+tan(s-y_f)+Z)*sin(b_u)*(cos(s)/cos(s-y_f)+sin(s)*sin(s-y_f)/cos(s-y_f)^2)/cos(b_u-y_f)};
b_u := 1/tan(0.8);
Z := 892/(27417000*f_z);
y_f := 9*Pi/180;
b:=(1/4)*Pi-1/2*(b_u-y_f);
S1:=[seq(rhs(fsolve(eval(eqns, f_z=a), s=b)[]), a=0.00005..0.0005, 0.000001)];
S2:=[seq(rhs(fsolve(eval(eqns, f_z=a), s=0..1)[]), a=0.00005..0.0005, 0.000001)];
plots:-implicitplot(eqns[], f_z=0..0.0005, s=0..0.5, gridrefine=5);
 

{(1-sin(b_u)*sin(s)/(cos(b_u-y_f)*cos(s-y_f)))*(1/cos(s-y_f)^2-1/sin(s)^2) = -(cot(s)+tan(s-y_f)+Z)*sin(b_u)*(cos(s)/cos(s-y_f)+sin(s)*sin(s-y_f)/cos(s-y_f)^2)/cos(b_u-y_f)}

 

.9712146007

 

(223/6854250)/f_z

 

(1/20)*Pi

 

.3783306795

 

[.3468796678, .3474070141, .3479168706, .3484100977, .3488875002, .3493498314, .3497977973, .3502320603, .3506532426, .3510619290, .3514586698, .3518439834, .3522183586, .3525822564, .3529361122, .3532803376, .3536153220, .3539414337, .3542590220, .3545684178, .3548699351, .3551638720, .3554505117, .3557301234, .3560029633, .3562692750, .3565292909, .3567832322, .3570313098, .3572737251, .3575106702, .3577423287, .3579688761, .3581904799, .3584073008, .3586194921, .3588272010, .3590305684, .3592297292, .3594248129, .3596159437, .3598032407, .3599868184, .3601667868, .3603432514, .3605163137, .3606860715, .3608526185, .3610160453, .3611764388, .3613338829, .3614884583, .3616402429, .3617893116, .3619357368, .3620795884, .3622209337, .3623598377, .3624963633, .3626305710, .3627625196, .3628922656, .3630198639, .3631453673, .3632688272, .3633902931, .3635098130, .3636274334, .3637431991, .3638571539, .3639693399, .3640797980, .3641885680, .3642956881, .3644011959, .3645051273, .3646075176, .3647084008, .3648078099, .3649057771, .3650023336, .3650975096, .3651913345, .3652838370, .3653750449, .3654649851, .3655536839, .3656411669, .3657274590, .3658125843, .3658965663, .3659794279, .3660611915, .3661418787, .3662215107, .3663001080, .3663776908, .3664542784, .3665298901, .3666045443, .3666782591, .3667510521, .3668229406, .3668939413, .3669640706, .3670333444, .3671017783, .3671693876, .3672361869, .3673021908, .3673674135, .3674318687, .3674955699, .3675585303, .3676207627, .3676822797, .3677430936, .3678032163, .3678626596, .3679214350, .3679795536, .3680370264, .3680938641, .3681500772, .3682056759, .3682606703, .3683150701, .3683688850, .3684221243, .3684747973, .3685269129, .3685784800, .3686295071, .3686800027, .3687299750, .3687794322, .3688283822, .3688768328, .3689247915, .3689722659, .3690192631, .3690657905, .3691118549, .3691574633, .3692026225, .3692473390, .3692916192, .3693354697, .3693788965, .3694219059, .3694645037, .3695066959, .3695484883, .3695898865, .3696308961, .3696715224, .3697117709, .3697516469, .3697911553, .3698303015, .3698690902, .3699075263, .3699456147, .3699833600, .3700207670, .3700578400, .3700945835, .3701310020, .3701670997, .3702028808, .3702383495, .3702735099, .3703083659, .3703429216, .3703771807, .3704111471, .3704448245, .3704782166, .3705113270, .3705441592, .3705767168, .3706090031, .3706410216, .3706727756, .3707042683, .3707355029, .3707664827, .3707972106, .3708276899, .3708579234, .3708879142, .3709176651, .3709471790, .3709764588, .3710055072, .3710343270, .3710629208, .3710912913, .3711194411, .3711473728, .3711750888, .3712025918, .3712298840, .3712569680, .3712838461, .3713105207, .3713369940, .3713632684, .3713893460, .3714152291, .3714409198, .3714664203, .3714917327, .3715168590, .3715418013, .3715665616, .3715911420, .3716155442, .3716397704, .3716638223, .3716877019, .3717114110, .3717349514, .3717583249, .3717815334, .3718045784, .3718274618, .3718501852, .3718727503, .3718951588, .3719174123, .3719395124, .3719614607, .3719832586, .3720049079, .3720264099, .3720477663, .3720689784, .3720900477, .3721109756, .3721317637, .3721524132, .3721729255, .3721933021, .3722135443, .3722336533, .3722536305, .3722734772, .3722931946, .3723127841, .3723322469, .3723515841, .3723707970, .3723898868, .3724088547, .3724277019, .3724464294, .3724650384, .3724835301, .3725019056, .3725201659, .3725383121, .3725563453, .3725742665, .3725920768, .3726097773, .3726273688, .3726448525, .3726622293, .3726795001, .3726966661, .3727137280, .3727306869, .3727475437, .3727642993, .3727809546, .3727975105, .3728139679, .3728303277, .3728465907, .3728627578, .3728788299, .3728948077, .3729106921, .3729264840, .3729421841, .3729577932, .3729733121, .3729887416, .3730040825, .3730193355, .3730345014, .3730495809, .3730645748, .3730794838, .3730943085, .3731090498, .3731237083, .3731382847, .3731527797, .3731671941, .3731815283, .3731957832, .3732099594, .3732240575, .3732380781, .3732520220, .3732658897, .3732796819, .3732933992, .3733070421, .3733206113, .3733341074, .3733475310, .3733608827, .3733741629, .3733873724, .3734005116, .3734135812, .3734265817, .3734395135, .3734523774, .3734651737, .3734779031, .3734905661, .3735031631, .3735156947, .3735281614, .3735405637, .3735529021, .3735651771, .3735773892, .3735895388, .3736016265, .3736136527, .3736256179, .3736375225, .3736493670, .3736611519, .3736728776, .3736845445, .3736961531, .3737077039, .3737191972, .3737306335, .3737420132, .3737533368, .3737646045, .3737758170, .3737869745, .3737980774, .3738091263, .3738201214, .3738310631, .3738419519, .3738527881, .3738635721, .3738743042, .3738849849, .3738956146, .3739061935, .3739167221, .3739272007, .3739376296, .3739480092, .3739583400, .3739686221, .3739788559, .3739890419, .3739991803, .3740092714, .3740193156, .3740293132, .3740392646, .3740491700, .3740590298, .3740688443, .3740786138, .3740883386, .3740980190, .3741076553, .3741172478, .3741267969, .3741363027, .3741457657, .3741551861, .3741645641, .3741739001, .3741831943, .3741924471, .3742016587, .3742108294, .3742199594, .3742290490, .3742380985, .3742471082, .3742560782, .3742650090, .3742739007, .3742827535, .3742915679, .3743003439, .3743090818, .3743177820, .3743264445, .3743350698, .3743436580, .3743522093, .3743607240, .3743692024, .3743776446, .3743860509, .3743944215, .3744027567, .3744110566, .3744193215, .3744275517, .3744357473, .3744439085, .3744520356, .3744601288, .3744681883, .3744762142, .3744842069, .3744921665, .3745000933, .3745079873, .3745158489, .3745236782, .3745314755, .3745392408, .3745469745, .3745546767, .3745623476, .3745699874, .3745775963, .3745851744, .3745927220, .3746002392, .3746077263, .3746151834, .3746226106, .3746300082, .3746373764, .3746447152, .3746520250, .3746593058, .3746665579, .3746737813, .3746809764, .3746881431]

 

[.3468796678, .3474070141, .3479168706, .3484100977, .3488875002, .3493498314, .3497977973, .3502320603, .3506532426, .3510619290, .3514586698, .3518439834, .3522183586, .3525822564, .3529361122, .3532803376, .3536153220, .3539414337, .3542590220, .3545684178, .3548699351, .3551638720, .3554505117, .3557301234, .3560029633, .3562692750, .3565292909, .3567832322, .3570313098, .3572737251, .3575106702, .3577423287, .3579688761, .3581904799, .3584073008, .3586194921, .3588272010, .3590305684, .3592297292, .3594248129, .3596159437, .3598032407, .3599868184, .3601667868, .3603432514, .3605163137, .3606860715, .3608526185, .3610160453, .3611764388, .3613338829, .3614884583, .3616402429, .3617893116, .3619357368, .3620795884, .3622209337, .3623598377, .3624963633, .3626305710, .3627625196, .3628922656, .3630198639, .3631453673, .3632688272, .3633902931, .3635098130, .3636274334, .3637431991, .3638571539, .3639693399, .3640797980, .3641885680, .3642956881, .3644011959, .3645051273, .3646075176, .3647084008, .3648078099, .3649057771, .3650023336, .3650975096, .3651913345, .3652838370, .3653750449, .3654649851, .3655536839, .3656411669, .3657274590, .3658125843, .3658965663, .3659794279, .3660611915, .3661418787, .3662215107, .3663001080, .3663776908, .3664542784, .3665298901, .3666045443, .3666782591, .3667510521, .3668229406, .3668939413, .3669640706, .3670333444, .3671017783, .3671693876, .3672361869, .3673021908, .3673674135, .3674318687, .3674955699, .3675585303, .3676207627, .3676822797, .3677430936, .3678032163, .3678626596, .3679214350, .3679795536, .3680370264, .3680938641, .3681500772, .3682056759, .3682606703, .3683150701, .3683688850, .3684221243, .3684747973, .3685269129, .3685784800, .3686295071, .3686800027, .3687299750, .3687794322, .3688283822, .3688768328, .3689247915, .3689722659, .3690192631, .3690657905, .3691118549, .3691574633, .3692026225, .3692473390, .3692916192, .3693354697, .3693788965, .3694219059, .3694645037, .3695066959, .3695484883, .3695898865, .3696308961, .3696715224, .3697117709, .3697516469, .3697911553, .3698303015, .3698690902, .3699075263, .3699456147, .3699833600, .3700207670, .3700578400, .3700945835, .3701310020, .3701670997, .3702028808, .3702383495, .3702735099, .3703083659, .3703429216, .3703771807, .3704111471, .3704448245, .3704782166, .3705113270, .3705441592, .3705767168, .3706090031, .3706410216, .3706727756, .3707042683, .3707355029, .3707664827, .3707972106, .3708276899, .3708579234, .3708879142, .3709176651, .3709471790, .3709764588, .3710055072, .3710343270, .3710629208, .3710912913, .3711194411, .3711473728, .3711750888, .3712025918, .3712298840, .3712569680, .3712838461, .3713105207, .3713369940, .3713632684, .3713893460, .3714152291, .3714409198, .3714664203, .3714917327, .3715168590, .3715418013, .3715665616, .3715911420, .3716155442, .3716397704, .3716638223, .3716877019, .3717114110, .3717349514, .3717583249, .3717815334, .3718045784, .3718274618, .3718501852, .3718727503, .3718951588, .3719174123, .3719395124, .3719614607, .3719832586, .3720049079, .3720264099, .3720477663, .3720689784, .3720900477, .3721109756, .3721317637, .3721524132, .3721729255, .3721933021, .3722135443, .3722336533, .3722536305, .3722734772, .3722931946, .3723127841, .3723322469, .3723515841, .3723707970, .3723898868, .3724088547, .3724277019, .3724464294, .3724650384, .3724835301, .3725019056, .3725201659, .3725383121, .3725563453, .3725742665, .3725920768, .3726097773, .3726273688, .3726448525, .3726622293, .3726795001, .3726966661, .3727137280, .3727306869, .3727475437, .3727642993, .3727809546, .3727975105, .3728139679, .3728303277, .3728465907, .3728627578, .3728788299, .3728948077, .3729106921, .3729264840, .3729421841, .3729577932, .3729733121, .3729887416, .3730040825, .3730193355, .3730345014, .3730495809, .3730645748, .3730794838, .3730943085, .3731090498, .3731237083, .3731382847, .3731527797, .3731671941, .3731815283, .3731957832, .3732099594, .3732240575, .3732380781, .3732520220, .3732658897, .3732796819, .3732933992, .3733070421, .3733206113, .3733341074, .3733475310, .3733608827, .3733741629, .3733873724, .3734005116, .3734135812, .3734265817, .3734395135, .3734523774, .3734651737, .3734779031, .3734905661, .3735031631, .3735156947, .3735281614, .3735405637, .3735529021, .3735651771, .3735773892, .3735895388, .3736016265, .3736136527, .3736256179, .3736375225, .3736493670, .3736611519, .3736728776, .3736845445, .3736961531, .3737077039, .3737191972, .3737306335, .3737420132, .3737533368, .3737646045, .3737758170, .3737869745, .3737980774, .3738091263, .3738201214, .3738310631, .3738419519, .3738527881, .3738635721, .3738743042, .3738849849, .3738956146, .3739061935, .3739167221, .3739272007, .3739376296, .3739480092, .3739583400, .3739686221, .3739788559, .3739890419, .3739991803, .3740092714, .3740193156, .3740293132, .3740392646, .3740491700, .3740590298, .3740688443, .3740786138, .3740883386, .3740980190, .3741076553, .3741172478, .3741267969, .3741363027, .3741457657, .3741551861, .3741645641, .3741739001, .3741831943, .3741924471, .3742016587, .3742108294, .3742199594, .3742290490, .3742380985, .3742471082, .3742560782, .3742650090, .3742739007, .3742827535, .3742915679, .3743003439, .3743090818, .3743177820, .3743264445, .3743350698, .3743436580, .3743522093, .3743607240, .3743692024, .3743776446, .3743860509, .3743944215, .3744027567, .3744110566, .3744193215, .3744275517, .3744357473, .3744439085, .3744520356, .3744601288, .3744681883, .3744762142, .3744842069, .3744921665, .3745000933, .3745079873, .3745158489, .3745236782, .3745314755, .3745392408, .3745469745, .3745546767, .3745623476, .3745699874, .3745775963, .3745851744, .3745927220, .3746002392, .3746077263, .3746151834, .3746226106, .3746300082, .3746373764, .3746447152, .3746520250, .3746593058, .3746665579, .3746737813, .3746809764, .3746881431]

 

 

 


 

Download eqns.mw

@zdamasceno  For any value of the parameter  f_z  , you get a trigonometric equation for  s - variable, which has the infinite number of solutions. The condition   s= (1/4)*Pi-1/2*(b_u-y_f)  when f_z=0  allows us to choose some branch of solutions. But if we substitute  f_z=0  into the equation, we get an error (the divizion by 0). I guess that you have incorrectly set  Zf_z - variable must be in the numerator (not in the denominator). In this case we have  s= (1/4)*Pi-1/2*(b_u-y_f)=0.3783306793   for  f_z=0 :

restart;
eqns := {(1-sin(b_u)*sin(s)/(cos(b_u-y_f)*cos(s-y_f)))*(1/cos(s-y_f)^2-1/sin(s)^2) = -(cot(s)+tan(s-y_f)+Z)*sin(b_u)*(cos(s)/cos(s-y_f)+sin(s)*sin(s-y_f)/cos(s-y_f)^2)/cos(b_u-y_f)};
b_u := 1/tan(0.8);
Z := 892/27417000*f_z;
y_f := 9*Pi/180;
b:=fsolve(eval(eqns, f_z=0), s=0..1)[];
(1/4)*Pi-1/2*(b_u-y_f);  
# This equals b
S:=[seq(rhs(fsolve(eval(eqns, f_z=a), s=0..1)[]), a=0.00005..0.0005, 0.000001)];

 

@zdamasceno  If I understood correctly, then just add 1 point  [0, (1/4)*Pi-1/2*(b_u-y_f)]:

restart;
eqns := {(1-sin(b_u)*sin(s)/(cos(b_u-y_f)*cos(s-y_f)))*(1/cos(s-y_f)^2-1/sin(s)^2) = -(cot(s)+tan(s-y_f)+Z)*sin(b_u)*(cos(s)/cos(s-y_f)+sin(s)*sin(s-y_f)/cos(s-y_f)^2)/cos(b_u-y_f)};
b_u := 1/tan(0.8);
Z := 892/(27417000*f_z);
y_f := 9*Pi/180;
S:=[(1/4)*Pi-1/2*(b_u-y_f), seq(rhs(fsolve(eval(eqns, f_z=a), s)[]), a=0.00005..0.0005, 0.000001)];
plot([0,seq(a, a=0.00005..0.0005, 0.000001)], S);

 

@Muhammad Usman  The following code produces the desired result:

restart;

alpha := 1: k := 2: M := 3:
printlevel := 3;

for n from 1 while n <= 2^(k-1) do

for m from 0 while m <= M-1 do

for j from 0 while j <= M-1 do

Omega[m, j] := 2^((1/2)*k)*sqrt(GAMMA(j+1)*(j+alpha)*GAMMA(alpha)^2/(Pi*2^(1-2*alpha)*GAMMA(j+2*alpha)))*(sum((-1)^i*GAMMA(j-i+alpha)*2^(j-2*i)*(sum((1/2)*binomial(m, l)*(2*n-1)^(m-l)*(1+(-1)^(j-2*i+l))*GAMMA((1/2)*j-i+(1/2)*l+1/2)*GAMMA(alpha+1/2)/GAMMA(alpha+1+(1/2)*j-i+(1/2)*l), l = 0 .. m))/(GAMMA(alpha)*factorial(i)*factorial(j-2*i)), i = 0 .. floor((1/2)*j)))/2^(k*(m+1));
A[n]:=Matrix(3, (i,j)->Omega[i-1,j-1]/sqrt(2)/sqrt(Pi));
od;  od;  od;
A[1];
A[2];
<A[1], Matrix(3); Matrix(3), A[2]>;


Edit.

@waseem  Probably you have not read about what I wrote above: "Unfortunately, the developers did not provide an image of the points in the legends. This can be done manually, but rather cumbersome."

@waseem

Probably you have an older version of Maple, which does not have this option. Try this code:

restart;
h:=z->1-(delta2/2)*(1 + cos(2*(Pi/L1)*(z - d1 - L1))):
K1:=(4/h(z)^4)-(sin(alpha)/F)-h(z)^2+Nb*h(z)^4:
lambda:=(F,Nb,delta2)->Int(K1,z=0..1):

L1:=0.2:
d1:=0.2:
alpha:=Pi/6:
A:=plot( [seq(seq(lambda(F,Nb,delta2), Nb=[0.1,0.2,0.3]), F=[0.1,0.2,0.5])], delta2=0.02..0.1, style=line, linestyle = [solid,longdash,dashdot],     thickness = 2,color=[red$3,blue$3,black$3], legend=["Nb=0.1",""$2,"Nb=0.2",""$2,"Nb=0.3",""$2]):
          
B:=plot( [seq(seq(lambda(F,Nb,delta2), Nb=[0.1,0.2,0.3]), F=[0.1,0.2,0.5])], delta2=0.02..0.1, style=point, color=[red$3,blue$3,black$3],       symbol=[solidbox, solidcircle, soliddiamond], numpoints=9, adaptive=false):

C:=plots:-textplot([[0.05,-1,F=0.1],[0.05,1.5,F=0.2], [0.05,3,F=0.5]], font=[times, 14]):

plots:-display(A, B, C, size=[500,500]);

 

@vv  Formally, you are right. Because the velocity of motion in this model is equal to the gradient, we obtain a solution that is formally equal to  (0,0)  only for  t=infinity. But for  t=10  we get  (x,y) = (10*exp(-40),10*exp(-20)) = (4.248354255*10^(-17), 2.061153622*10^(-8)) , so that you are already at the top.

It is easy to write equations where the speed is constant, but this complicates the model.

@Muhammad Usman

I did not understand the meaning of this
                                     

 

@digerdiga  Do you want this output?

ex:=exp(-x^2/2*epsilon)*%sqrt((sqrt(x)/2/h)^2);
                                            

 

@MarcoFerro 

restart;
evalindets(x^2*y^3+alpha*x*y^5, `*`, p->lcoeff(p, [x,y])*m[degree(p,x),degree(p,y)]);

                                                      alpha*m[1, 5]+m[2, 3]

First 39 40 41 42 43 44 45 Last Page 41 of 127