AmirHosein Sadeghimanesh

225 Reputation

7 Badges

7 years, 121 days

Social Networks and Content at Maplesoft.com

Finished Ph.D. in Applied Algebraic Geometry in Biology and did postdoc in Mathematics of Chemical Reaction Networks, University of Copenhagen. Another postdoc in Nonlinear Dynamics in the Mathematical Models of Cell Biology at University of Szeged. Currently a research fellow at Coventry University. Main interests; Applied and Computational Algebraic Geometry, Computer Algebra, Mathematical Biology, Chemical Reaction Network Theory, Population Dynamics. I'm also a language lover!

MaplePrimes Activity


These are answers submitted by AmirHosein Sadeghimanesh

Another possibility other than using op with the careful details mentioned in answer of @Adri van der Meer and @Stephen Forrest is to use coeffs command.

numelems( [ coeffs( expand( f ) ) ] );

What it does is that it expands f first, because coeffs needs it (alternatively you can use collect with the option distributed as recommended in the help page of coeffs. Then it extracts all nonzero coefficients (if your polynomial has parameters, you can explicitly give the list of variables alone to coeffs as its second argument). We put them in a list and then numelems counts them.

Have you looked at Maple packages with the word student in their title? For example try

?student:-Basic;

it will open the help page of the Basic subpackage of the student package. For example you can use the command SolveSteps command from this package to see the steps of one approach to solve the equation 4th line.

Student:-Basics:-SolveSteps( 2*x^2-x-10, x );

New text after your comment:

I think you should edit your sentence as "but" does not make sense in your sentence: "i have go through this command but it is mot working for all like to view step of solution of quadratic equation", did you want to say that you are happy with my answer and it works for most of your need or you wanted to say that it does not cover some of your needs?

 

Anyway, let's look at other lines in your codes in your question. Some of them are already covered with this package. For example:

Student:-Basics:-ExpandSteps( (3*x^2-5*x) * (4*x^2+7*x+4) );
Student:-Basics:-FactorSteps( 2*x^2-x-10 );
Student:-Basics:-SolveSteps( sqrt( x-4 ) = 4, x );
Student:-Basics:-SimplifySteps( (x^2-9) / (x^2-2*x-15) );

But for example the following ends up with error message or the one which is substraction of two polynomials does not provide much information (I'm using Maple 2022.1).

Student:-Basics:-SolveSteps( { x+2*y=4, 3*x+4*y=6 }, { x, y } ); # this commend only solve for one variable
Student:-Basics:-SolveSteps( abs( 3*x+3 ) = 12, x );
Student:-Basics:-ExpandSteps( x^6+2*x^5-3*x+2 - (-2*x^2+4*x-8) ); # This just shows the last result, whereas I suppose you want Maple to put the terms with same monomial next to each other, shows something like their coefficients get simplified in a paranthesis behind the monomial etc.

So what to do? Well, you can design your own step-by-step explainer and then share it with your students. Just write a procedure (see Maple's programming documentation (https://www.maplesoft.com/documentation_center/Maple2021/ProgrammingGuide.pdf) and look at the help page of Student:-Basics:-OutputStepsRecord.

@yangtheary I don't see what exactly you want to do with Maple for this question. But I follow my guess. Since you didn't specify which two edges of your triangle are equal, I check all three possibilities.

1- AC=BC: In this case D=C and we have ABD=ABC and since ABC=BAC, the answer is 20 degrees.

2- AB=BC: Since AD=BC, the triangle ADB also becomes isosceles. Then 2(?)+20=180 which implies ABD=?=80.

3- AB=AC: In this case, note that the triangle ABC can be uniquely determined by the assumptions of your question plus length of AD. And two cases for two different values of AD are geometrically similar (one is a scaled version of the other). Therefore the angles are the same and only size of edges are changed (by a multiplying to a fixed ratio). Now I fixed AD=1. Without loss of generality (at most with a geometric translation and rotation which none of them change the size of angles and edges) assume that A=(0,0) and AC is on the positive side of the x-axis. Then it's trivial that D=(1,0) and the AB edge is on the line y=tan(20)*x. The point C is (xC,0) which we yet don't know the value of xC. The line which BC is on it, is y=-tan(80)*(x-xC). The point B is the unique point on the intersection of the two lines and with the distance 1 from C. Therefore we need to solve the following system of equations. Here I use Maple. Just note that B is on these two lines, by considering one of them, say the first one, we have B=(xB,tan(20)*xB). Therefore we have two equations and two unknowns.

solve({tan(20*Pi/180)*xB=-tan(80*Pi/180)*(xB-xC),(xC-xB)^2+(tan(20*Pi/180)*xB-0)^2=1,xB>0,xC>0},{xB,xC});

Now we have the coordinates of both B and C. But knowing B is enough for us. Again using Maple we compute the arctan of ABD. To this end, just choose an arbitrary point on one of the two edges of this angle, say D from BD, then project it on the other edge. Call this new point M. Then tan(ABD)=(distance of M and D)/(distance of M and AB). The wollowing Maple computations is related to all these steps. To find M, we first found distance of M from the line of AB. Then solved an equation determining the unique point on line of AB with the found distance from M.

pointA:=[0,0]:
pointD:=[1,0]:
sol1:=solve({tan(20*Pi/180)*xB=-tan(80*Pi/180)*(xB-xC),(xB-xC)^2+(tan(20*Pi/180)*xB-0)^2=1,xB>0,xC>0},{xB,xC});
pointB:=eval([xB,tan(20*Pi/180)*xB],sol1);
pointC:=eval([xC,0],sol1);
d:=abs((-tan(20*Pi/180))*pointD[1]+(1)*pointD[2])/sqrt((-tan(20*Pi/180))^2+(1)^2);
sol2:=solve({(xM-pointD[1])^2+(tan(20*Pi/180)*xM-pointD[2])^2=d^2,xM>0},xM);
pointM:=eval([xM,tan(20*Pi/180)*xM],sol2);
theta:=arctan(d/sqrt((pointM[2]-pointB[2])^2+(pointM[1]-pointB[1])^2))*180/Pi;
evalf(theta);
P1:=plots:-pointplot([pointA,pointB,pointC,pointD,pointM],color=black,symbol=solidcircle,symbolsize=20):
P2:=plots:-textplot([[op(pointA),"A"],[op(pointB),"B"],[op(pointC),"C"],[op(pointD),"D"],[op(pointM),"M"]],align={above,right},color=red,font=["times",20,bold]):
P3:=plot([pointA,pointB,pointC,pointA],color=blue,thickness=8):
P4:=plot([pointB,pointD],color=blue,thickness=8):
P5:=plot([pointD,pointM],color=blue,thickness=8):
plots:-display(P3,P4,P5,P1,P2,view=[0..3,0..1.2],size=[700,280],scaling=constrained);

So the answer in the case of AC=AB is (almost) 10 degrees.

I also put the plot of my above code below.

If you are looking at your integrand function as a complex-valued function, then the others already had answered your question. Now, if you are thinking about your integrand expression as a real-valued function on its domain, then see the following. (maybe that is the reason that you didn't upvote the other answer, just as a guess)

The plot of the integrand expression is as the folloeing.

plot(sqrt(5-4*cos(x)-4*sin(x)),x=0..Pi/2);

To make it possible to calculate the area below the diagram of the expression on the area it is defined, just modify the integrand so that it is zero wherever the original expression is undefined. Here the problem is when below the radical becomes negative. So let's add a max(0,...) under the radical.

int(sqrt(max(0,5-4*cos(x)-4*sin(x))),x=0..Pi/2,numeric);

Or remove "numerc" option and add "evalf" at the beginning. Anyway, then the answer is 0.3815374557.

The others answered what you explained in the body of your question. But for someone who comes to this page because of the title of your question (which I believe is not a super suitable title for yout question), I'm writing the following.

 

So assume you have a 1 dimensional array and want to append an element at the end of the array. You can use info about number of elements in your array or just use the ArrayTools:-Append. Let's make it more clear by an example, say you already have an array called myArray. You may know that it has n elements, then use the following line to add your new element, say newElement;

myArray(n+1):=newElement;

You don't rememeber the number of elements in myArray or it may change in a loop etc, then use numelems which counts it for you.

myArray(numelems(myArray)+1):=newElements;

But I don't think it is a very good idea to count the number of elemetns each time. I suppose the predefined codes of Maple are optimized so I would go for ArrayTools:-Append. As in below.

ArrayTools:-Append(myArray,newElement);

One more thing. In a comment to another answer you said that when you ask a range of elements of your array to be printed you see something that doesn't look like what you expect. You tried something like myArray[2..4]. Try myArray(2..4) which shows the result as a brackets containing the elements you want without the word Array etc. So just use paranthesis instead of brackets for the porpuse of just seeing some elements of the Array.

 

Now going back to your question, you want to add an element at the end and delete an element at the beginning. For deleting an element from a 1 dimensional array which is currently located at the i-th position from left to right, you can use ArrayTools:-Remove. Let's pick up our previous example, other than adding newElement at the end of the array, we want to delete the first element at the beginning of the array as well. So you can type the following.

ArrayTools:-Append(ArrayTools:-Remove(myArray,1),newElement);

I don't know if changing the order of adding and removing will make any difference in the efficiency of the code.

Since you're working with a monomial it's easy.

F:=[0,1,3,4,6,10,11,15]:
ans:=0:
for i in F do
 ans:=ans+i*degree(f,j[i]):
end do:
ans;

As an example ans for f:=j[0]^4*j[11]*j[15]^2 will be 41.

Page 1 of 1