Alec Mihailovs

Dr. Aleksandrs Mihailovs

4495 Reputation

21 Badges

20 years, 335 days
Mihailovs, Inc.
Owner, President, and CEO
Tyngsboro, Massachusetts, United States

Social Networks and Content at Maplesoft.com

Maple Application Center

I received my Ph.D. from the University of Pennsylvania in 1998 and I have been teaching since then at SUNY Oneonta for 1 year, at Shepherd University for 5 years, at Tennessee Tech for 2 years, at Lane College for 1 year, and this year I taught at the University of Massachusetts Lowell. My research interests include Representation Theory and Combinatorics.

MaplePrimes Activity


These are replies submitted by Alec Mihailovs

You can do that drawing a legend manually. For example,
a:=plot(x^2,x=-1..1):
b:=plottools[line]([1.2,0.4],[1.6,0.4],color=red):
c:=plots[textplot]([1.7,0.4,"t"],font=[SYMBOL,12]):
plots[display](a,b,c,view=[-1..1.7,0..1]);
plots[display] displays few plots, in this case surface b and 3D curve with coordinates c. Now take a detailed look on c. map applies the function x->... to every element of the list op([1,1],a) which is the list of 2D coordinates of 25 points on curve a. What this function x->... is doing? x is a typical point on a curve, something like [.871886166666666629e-1, .190046371906173596e-2]. It transforms to a list of length 3 (coordinates of the corresponding point in space), first 2 elements of which are op(x), i.e. coordinates of that point, and the 3rd coordinate should put it on the surface b. The surface b is determined by 25×25 array op([1,3],b) of z-coordinates. To determine a place in the array where to look for corresponding z-coordinate, I do round(x[1]*12)+1 for the first index. For example, if x[1]=0, that gives 1, the first row, and if x[1]=2, that gives 25 - the last row, with other coordinates distributed proportionally between them. round is needed to make index integer. Similarly for 2nd index. round(x[2]*24)+1 gives 1st column for x[2]=0, the last column for x[2]=1 with other coordinates distributed proportionally between them. Now, the COLOUR(RGB,1.,0.,0.) makes the curve red. Also, plots[pointplot3d](c,connect=true,color=red) could be used instead of PLOT3D(CURVES(c),COLOUR(RGB,1.,0.,0.)) - it does exactly the same thing. I should be adding this comment in the previous comment, but there were no time for that (between classes).
plots[display] displays few plots, in this case surface b and 3D curve with coordinates c. Now take a detailed look on c. map applies the function x->... to every element of the list op([1,1],a) which is the list of 2D coordinates of 25 points on curve a. What this function x->... is doing? x is a typical point on a curve, something like [.871886166666666629e-1, .190046371906173596e-2]. It transforms to a list of length 3 (coordinates of the corresponding point in space), first 2 elements of which are op(x), i.e. coordinates of that point, and the 3rd coordinate should put it on the surface b. The surface b is determined by 25×25 array op([1,3],b) of z-coordinates. To determine a place in the array where to look for corresponding z-coordinate, I do round(x[1]*12)+1 for the first index. For example, if x[1]=0, that gives 1, the first row, and if x[1]=2, that gives 25 - the last row, with other coordinates distributed proportionally between them. round is needed to make index integer. Similarly for 2nd index. round(x[2]*24)+1 gives 1st column for x[2]=0, the last column for x[2]=1 with other coordinates distributed proportionally between them. Now, the COLOUR(RGB,1.,0.,0.) makes the curve red. Also, plots[pointplot3d](c,connect=true,color=red) could be used instead of PLOT3D(CURVES(c),COLOUR(RGB,1.,0.,0.)) - it does exactly the same thing. I should be adding this comment in the previous comment, but there were no time for that (between classes).
Another way is including function names in quotes, such as
Output_Curve_test:=plot3d([0,0,'iL_RMS_func_Ue_const'(Iatest,U_test)],
Iatest=0..2,U_test=0..1);
Another way is including function names in quotes, such as
Output_Curve_test:=plot3d([0,0,'iL_RMS_func_Ue_const'(Iatest,U_test)],
Iatest=0..2,U_test=0..1);
One doesn't need a semicolon at the end of a procedure - same as at the other ends - end if or end do. Yes, you can include the return values in a list - in that case the procedure will return a list instead of a sequence.
One doesn't need a semicolon at the end of a procedure - same as at the other ends - end if or end do. Yes, you can include the return values in a list - in that case the procedure will return a list instead of a sequence.
That's odd - usually it is faster. Certainly, you should use int in that case.
That's odd - usually it is faster. Certainly, you should use int in that case.
  1. A procedure always returns one value. In this example - it is a sequence of 2 numbers. I did that, because I thought that both of them need to be evaluated. Certainly, it could have the same ending as in your example.
  2. int in Maple is for symbolic integration. If one wants to get a numerical answer, then evalf(Int(... should be used so that Maple won't spend time trying to integrate function symbolically. Capitalized Int is an inert form of int - it is not evaluated.
  3. The return values can be accessed as iL_RMS_AVG(...)[1] and iL_RMS_AVG(...)[2], same way as for other sequences.
  4. return can be used when one wants to return from a procedure in the middle of the code. At the end it is not necessary, because without return Maple returns the result of last executed command. return can be used in any place of the procedure - including your example.
  1. A procedure always returns one value. In this example - it is a sequence of 2 numbers. I did that, because I thought that both of them need to be evaluated. Certainly, it could have the same ending as in your example.
  2. int in Maple is for symbolic integration. If one wants to get a numerical answer, then evalf(Int(... should be used so that Maple won't spend time trying to integrate function symbolically. Capitalized Int is an inert form of int - it is not evaluated.
  3. The return values can be accessed as iL_RMS_AVG(...)[1] and iL_RMS_AVG(...)[2], same way as for other sequences.
  4. return can be used when one wants to return from a procedure in the middle of the code. At the end it is not necessary, because without return Maple returns the result of last executed command. return can be used in any place of the procedure - including your example.
Yes, the program is working. Here is a slightly simplified version of it,
iL_RMS_AVG := proc(Ue, Ua, Ia, L, T)
local io, iL_increase, iL_decrease, iL, t;
    io := max(Ia - 1/2*(Ue - Ua)*Ua*T/(L*Ue), 0);
    iL_increase := io + (Ue - Ua)*t/L;
    iL_decrease :=
        io + (Ue*dutycycle(Ia, L, Ua, Ue, T)*T - Ua*t)/L;
    iL := piecewise(t < dutycycle(Ia, L, Ua, Ue, T)*T,
        iL_increase, max(iL_decrease, 0));
    evalf(sqrt(1/T*Int(iL^2, t = 0 .. T))),
        evalf(1/T*Int(iL, t = 0 .. T))
end proc;

iL_RMS, iL_AVG:=iL_RMS_AVG(Ue_input,Ua_input,Ia_input,L_input,T_input);

Yes, the program is working. Here is a slightly simplified version of it,
iL_RMS_AVG := proc(Ue, Ua, Ia, L, T)
local io, iL_increase, iL_decrease, iL, t;
    io := max(Ia - 1/2*(Ue - Ua)*Ua*T/(L*Ue), 0);
    iL_increase := io + (Ue - Ua)*t/L;
    iL_decrease :=
        io + (Ue*dutycycle(Ia, L, Ua, Ue, T)*T - Ua*t)/L;
    iL := piecewise(t < dutycycle(Ia, L, Ua, Ue, T)*T,
        iL_increase, max(iL_decrease, 0));
    evalf(sqrt(1/T*Int(iL^2, t = 0 .. T))),
        evalf(1/T*Int(iL, t = 0 .. T))
end proc;

iL_RMS, iL_AVG:=iL_RMS_AVG(Ue_input,Ua_input,Ia_input,L_input,T_input);

One way of doing that is to define
fit:=t->-1.15349559820136772*sin(6.31733026117843100*t-1.59937743196843218)
+0.632900021230384108e-1*t^2+0.375929994701278206e-1*t-.119784615843290448;
After that, the plot displays without problems,
plot([`if`(fit(t)>=0,fit(t),undefined),
`if`(fit(t)<0,fit(t),undefined)],t=0..2,color=[red,blue]);
Similarly in second example, if a is defined as
a:=[[-.374122749037187119,` `,t=0.425224494625509708],
[0.461103240716029206,` `,t=0.820482498682596706],
[-.487906594187588028,` `,t=1.17583430812675526],
[0.503703993961537533,` `,t=1.84141458338977282],
[-.474312798381622158,` `,t=2.07643642721967892],
[0.476619780954403438,` `,t=2.72771400858018609],
[-.515049152510467456,` `,t=3.04258962007499001],
[0.482156508938662298,` `,t=3.62966238621154691],
[-.510419166905392241,` `,t=3.96891650719314226],
[0.532900771914534110,` `,t=4.58094506098229282],
[-.501757304940609550,` `,t=4.90951214779941836],
[0.518180770062256490,` `,t=5.52701005492744635],
[-.530099569478209909,` `,t=5.83250364265300991],
[0.540629769765865187,` `,t=6.44116771591300185],
[-.491960954417340613,` `,t=6.73823102585208211],
[0.465372229604253230,` `,t=7.40040593094128774],
[-.526930099177685962,` `,t=7.73028609364419417],
[-.111278397610983224,` `,t=8.05654842673419758],
[-1.272671408+2.113115942*t,` `,0.425224494625509708< t and t< 0.820482498682596706],
[2.652300641-2.670620523*t,` `,0.820482498682596706< t and t< 1.17583430812675526],
[-2.239715945+1.489843713*t,` `,1.17583430812675526< t and t< 1.84141458338977282],
[8.166542278-4.161386770*t,` `,1.84141458338977282< t and t< 2.07643642721967892],
[-3.506124581+1.460103350*t,` `,2.07643642721967892< t and t< 2.72771400858018609],
[9.067279545-3.149398997*t,` `,2.72771400858018609< t and t< 3.04258962007499001],
[-5.683211892+1.698606577*t,` `,3.04258962007499001< t and t< 3.62966238621154691],
[11.10167260-2.925758640*t,` `,3.62966238621154691< t and t< 3.96891650719314226],
[-7.276197825+1.704691607*t,` `,3.96891650719314226< t and t< 4.58094506098229282],
[14.95830123-3.149000974*t,` `,4.58094506098229282< t and t< 4.90951214779941836],
[-8.610931946+1.651727177*t,` `,4.90951214779941836< t and t< 5.52701005492744635],
[19.48373752-3.431431562*t,` `,5.52701005492744635< t and t< 5.83250364265300991],
[-10.79032856+1.759146607*t,` `,5.83250364265300991< t and t< 6.44116771591300185],
[22.93009966-3.475995484*t,` `,6.44116771591300185< t and t< 6.73823102585208211],
[-10.23369553+1.445740660*t,` `,6.73823102585208211< t and t< 7.40040593094128774],
[22.72630472-3.008069111*t,` `,7.40040593094128774< t and t< 7.73028609364419417],
[-10.37516033+1.273980045*t,` `,7.73028609364419417< t and t< 8.05654842673419758]];
then fit can be defined as
fit:=unapply(piecewise(op(map(x->(x[3],x[1]),a))),t):
and plot again works without problems,
plot([`if`(fit(t)>=0,fit(t),undefined),
`if`(fit(t)< 0,fit(t),undefined)],t=0.4..8,color=[red,blue]);
The line starting from if in "Sorry,I forgot to mention" looks like that, both in IE and Firefox,
if Ia iL_increase:=io+(Ue-Ua)/L*t;
I don't think that it would work in Maple.
First 167 168 169 170 171 172 173 Last Page 169 of 180