New Student Forum

Tom 4's picture

Hello all ... FYI, we will be creating new forums specifically for Q&A geared towards undergraduate students. Our goal is to have a section of the forums that are more suited to the kinds of issues that younger users who have neither the computing or math experience, may have. We'll be uploading the test groups this week and the forums should be live by the end of the week. We'll also do subsequent refinements in the autumn once Will gets back. Tom 4.

Comments

Substitution

Hi
What command do I use to plug a value for x
into an expression and get an answer. I am
thinking here of a biggish expression with just
one variable x in it.

Curious

acer's picture

two-argument eval()

To evaluate an expression at an instance of a variable, use the eval() command in its two-argument form.

For example,

E := sin(x)+x;
eval(E,x=4.0);

That will evaluate E with 4.0 as the value for x.

acer

re: Substitution

FTR.

If you have Maple 11 just right click at the end of your biggish expression , get a long drop down menu, choose <Evaluate at a point>, plug in your point and get an exact answer.  If the answer is  not a single real number, right click again and choose <Approximate>, <5 digits>.

The Maple output is elegant and informative.

Here is an example that is not elegant nor informative,FWIW.

 E := sin(x)+x; @ x=4, = sin(4) + 4 = 3.2423, all done with right clicks but without the long arrows and informative superscripts.                                

List of points

BYC *

I am having trouble finding help in Help for making a list of points such as
[[a1, sin(a1)], [a2, sin(a2)], .. [an, sin(an)]],
where a1=0 and an=a10=Pi. That's a 20 degree interval.
I can get a column of points but not a row list of points.

asa

* Begging Your Compassion

Scott03's picture

seq command

You can use the seq command like the following:

[seq([an, sin(an)], an = 0 .. evalf(Pi), evalf((1/10)*Pi))];

this tells maple to loop through values of 0 to Pi at a step of Pi/10. The seq command needs to have numeric values for the range and step and that is why I have an evalf command where Pi is being used.

To get more information on the seq command, check the help page at
?seq

Scott

floats as loop index

I'm never wild about using a float as the index of a loop. If nothing else, the final value will be off slightly from what you want. Better, I feel, to do

[seq(evalf([k*Pi, sin(k*Pi)]), k = 0 .. 1, 1/10)]

Or use an integer index and divide in the list.

hELP w/o Help

Thanks, your point about float well taken.

Although your answer didn't help me on "Help" it
did give me the answer I was looking for.

I didn't know that you could put [ ] outside the command.

This could be a useful example in "Help" somewhere, don't
you think (rhetorically that is)?

Doug Meade's picture

help is helpful

I don't understand your request.

The help for seq (?seq) does include examples with both {} and [].

Moreover, both ?[] and ?list give information about forming lists.

You do have to have some idea of what you are trying to do before you would come up with any of these. I don't believe it's unreasonable to expect a user to come up with at least one of these.

You can't expect any system to provide a meaningful response to the question: Tell me what I need to know.

Doug

---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
Scott03's picture

Help

The help page for seq has a lot of information on it.

You can get to it by executing
?seq
in a Maple worksheet. Alternatively you can open the help system and look for seq.

The 4th and 6th examples at the bottom of the page shows the square brackets outside of the seq() call to make a list. The 7th example shows something like the one that you were asking for (as in a list of points). In the help page there is no example for a floating point as the step value, but the help page does indicate that the step value needs to be a numeric value (in the Parameter section).

If you believe the help page is missing something, could you be a bit more specific what it was that you were looking for, so that someone else reading this will know exactly what you mean?

Scott

Plotting Triangles

How do I plot a triangle with three points A, B, C and then additionally have text inserted at each point corresponding to those points so that they are marked A, B and C? How do I enter text anywhere else?

another way

You can use the geometry package to plot a triangle:

restart; with(geometry):
point(A, 0, 0): point(B, 3, 3): point(C, 0, 2):
triangle(T1, [A, B, C]):
draw(T1, printtext = true, axes = none, color = green, filled = true, title = "My triangle");

gkokovidis's picture

Triangle

There are many ways to do this, here is an example.

>restart:
>with(plots):
>triang:=polygonplot([[0,0],[3,3],[0,2]], thickness=2):
>a:=textplot([0,0,"A"],align={ABOVE,RIGHT}):
>b:=textplot([3,3,"B"],align={ABOVE,RIGHT}):
>c:=textplot([0,2,"C"],align={ABOVE,RIGHT}):
>display(triang,a,b,c);

For more help on each of the above commands, look at the help files for polygonplot and for textplot. At the command line, type a question mark followed by the command and hit the enter key:

>?textplot
>?polygonplot

Regards,
Georgios Kokovidis
Dräger Medical

It worked exactly as you

It worked exactly as you stated. Thank-you indeed - and also for the additional help. Now I know exactly where to come with questions re Maple coding. What a terrific thread.

- Olivier

Digits?

What is the Straight Dope on "digits"?

> evalf(Pi); digits := 4; evalf(Pi), "Not 4 digits?"; evalf(Pi, 5); digits, "So why is it still 10 digits?";
3.141592654
4
3.141592654, "Not 4 digits?"
3.1416
4, "So why is it still 10 digits?"

Digits, not digits

Try Digits.

Graphing an Equation in Two Variables; Evaluating Solutions

Thank-you djc for answering my first question here as well. I hope that in time I'll have Maple language down as well as I know so many who have come before me have it.

For now, please forgive these elementary questions. I am new to Maple and a beginning Math major, but I hope as time progresses (and I complete more classes) I will have some more complex questions to pose here, which I hope might be of use to others. Perhaps there are other beginning students who have the same questions I do and, if so, I hope my posing them here will help them. So, here goes:

I'm working on a simple precalculus equation, the graph of the equation y = x^3-2*sqrt(x). I'm plugging in certain coordinates to find if they satisfy the equation and are on the graph. I solved (x,y) for (1,-1) and the equation holds true, but when I use the graphing software to right-click on the equation to get a graph using Plot Builder (2-D Implicit Plot), it shows a curve of points only in quadrant I; however, when I use Evaluate and plug in (1,-1) the equation holds true. Why is (1,-1) not being expressed on the graph, in quadrant IV?

TIA,

Olivier

Scott03's picture

Please....

Olivier, would you be able to post new questions in a new forum topic in the future?

This way these forum topics don't get too many questions on them and this forum topic shows how diverse the questions can get. This also makes it harder for future beginners to make use of these tips if they are stuck in these long posts on different topics.

Scott

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}