# Thread: Calculus for computers question

1. ## Calculus for computers question

Hi, i have an assignment of 2 questions - both of which i cant do. Im asking for help for the first question to try and get the ball rolling as i have no idea...

We are given a formula, its just something random from a science book:

U(r) = A/r^12 - B/r^6

Where A and B are constants and r is the distance separating atoms (not important information). It doesnt say what U is, im assuming its like f(x) but U(r)...

i) Calculate r = rs, such that U(rs) is a minimum
(the "rs" is r(subscript)s).

Now, we are using the program mathematica to do this assignment, and i have attempted this question in a similar way to how the tut was done, that is to input the function and then find the 2nd derivative, which is:
156a/r^14 - 42b/r^8

and that is as far as i can get, i would appreciate any help!

2. Originally Posted by Siddy
Hi, i have an assignment of 2 questions - both of which i cant do. Im asking for help for the first question to try and get the ball rolling as i have no idea...

We are given a formula, its just something random from a science book:

U(r) = A/r^12 - B/r^6

Where A and B are constants and r is the distance separating atoms (not important information). It doesnt say what U is, im assuming its like f(x) but U(r)...

i) Calculate r = rs, such that U(rs) is a minimum
(the "rs" is r(subscript)s).

Now, we are using the program mathematica to do this assignment, and i have attempted this question in a similar way to how the tut was done, that is to input the function and then find the 2nd derivative, which is:
156a/r^14 - 42b/r^8

and that is as far as i can get, i would appreciate any help!
Get the value of r at the stationary points by solving

1st derivative of U with respect to r = 0.

Use the second derivative test to determine the nature of these solutions:

Substitute each solution to 1st derivative = 0 into the 2nd derivative and see whether the result is greater than zero or less than zero.

This will depend on the value of A and B but if you can assume that A > 0 and B > 0 then it's clear cut.

I'll leave it to you to write the appropriate code.

3. Originally Posted by Siddy
Hi, i have an assignment of 2 questions - both of which i cant do. Im asking for help for the first question to try and get the ball rolling as i have no idea...

We are given a formula, its just something random from a science book:

U(r) = A/r^12 - B/r^6

Where A and B are constants and r is the distance separating atoms (not important information). It doesnt say what U is, im assuming its like f(x) but U(r)...

i) Calculate r = rs, such that U(rs) is a minimum
(the "rs" is r(subscript)s).

Now, we are using the program mathematica to do this assignment, and i have attempted this question in a similar way to how the tut was done, that is to input the function and then find the 2nd derivative, which is:
156a/r^14 - 42b/r^8

and that is as far as i can get, i would appreciate any help!
It's a long time since I used Mathematica so I don't recall the syntax, but you need to do something like:

You need to define a function

U(r):=A/r^12 - B/r^6

then another function containing the derivative:

dU(r):=diff(U(r),r)

then solve the equation dU(r)=0, something like:

solve(dU(r)=0,r)

I believe this will have only one positive real solution (the negative and complex solutions are non-physical and so we can ignore them). This is a local maximum or minimum (or possibly a point of inflelection) depending on the values of A and B.

RonL

4. Originally Posted by Siddy
[snip]
r is the distance separating atoms (not important information).
[snip]
Originally Posted by CaptainBlack
[snip]I believe this will have only one positive real solution (the negative and complex solutions are non-physical and so we can ignore them).

RonL
Not important information .....

(There's a moral to the story somewhere here ....)

5. Originally Posted by mr fantastic
Not important information .....

(There's a moral to the story somewhere here ....)
The question is who decided that the domain of U was unimportant, and was that what was meant rather than that the origin of the problem was unimportant.

RonL

6. Thanks for the help guys,

Mr Frantic, this is what i have done so far based on what you said:

Now im up to "Substitute each solution to 1st derivative = 0 into the 2nd derivative and see whether the result is greater than zero or less than zero."
Could you explain this a little? What is each solution? Is it the individual groups in the brackets? And where in the f'' do they go?

7. Originally Posted by Siddy
Thanks for the help guys,

Mr Frantic, this is what i have done so far based on what you said:

Now im up to "Substitute each solution to 1st derivative = 0 into the 2nd derivative and see whether the result is greater than zero or less than zero."
Could you explain this a little? What is each solution? Is it the individual groups in the brackets? And where in the f'' do they go?
The solutions are the values of r given in Out[10]. You substitute these values of r into the expression given in Out[11].

You should make sure you're familiar with the double derivative test and what it tells you.

8. Originally Posted by mr fantastic
The solutions are the values of r given in Out[10]. You substitute these values of r into the expression given in Out[11].

You should make sure you're familiar with the double derivative test and what it tells you.
Thanks again,
Out of the 6 solutions only the first two are real, so i am ignoring the last four.

Now, i did exactly what you said, sub'ed in the solutions from Out[10] into Out[11] but i get the SAME answer for both!!!! I know the minimum i am looking for should be > 1 but both answers are > 1.

9. Originally Posted by Siddy
Thanks again,
Out of the 6 solutions only the first two are real, so i am ignoring the last four.

Now, i did exactly what you said, sub'ed in the solutions from Out[10] into Out[11] but i get the SAME answer for both!!!! I know the minimum i am looking for should be > 1 but both answers are > 1.

If they're both local maxima, just find out which one is greater (substitute into the original function).

But I have a feeling you've made a mistake with the second derivative test.

If the second derivative > 0 at the critical point, you have a minimum.

If the second derivative = 0 at the critical point, you may or may not have a stationary point of inflexion.

If the second derivative < 0 at the critical point, you have a maximum.

10. Ok, so i sub'ed into the original equation and i get the same answer for both again!

Here is a complete explanation of what i have done and in RED i wrote the thought process based on your guys input and what i looked up about 2nd derivative test:

11. Originally Posted by Siddy
Ok, so i sub'ed into the original equation and i get the same answer for both again!

Here is a complete explanation of what i have done and in RED i wrote the thought process based on your guys input and what i looked up about 2nd derivative test:

Actually, look at your question again, it's asking you to find the minima, not the maxima.

You've done everything right, and have proven that the stationary points are minima because the second derivative is positive at the critical points.

So the question is finished

12. Originally Posted by Siddy
Ok, so i sub'ed into the original equation and i get the same answer for both again!

Here is a complete explanation of what i have done and in RED i wrote the thought process based on your guys input and what i looked up about 2nd derivative test:

That is because the original function is symmetic, they are mirror images of one another and both minima (or maxima), and U takes the same value at both.

(have you declared a and b to be positive?)

RonL

13. for 2 days ive been racking my brain over why i get the same answers, i cant believe i was actually doing it right...

Can i ask, as the original question does, "Calculate rs when U(rs) is a min", do i write "rs equals both (14.12a^1/6)/b^1/2 and -(14.12a^1/6)/b^1/2 (because function is symmetrical)

and, "Calculate Ds = -U(rs)", do i write "Ds = -(0.25b^2/a)"

(nb. those solutions are from my image above)

14. Originally Posted by Siddy
for 2 days ive been racking my brain over why i get the same answers, i cant believe i was actually doing it right...

Can i ask, as the original question does, "Calculate rs when U(rs) is a min", do i write "rs equals both (14.12a^1/6)/b^1/2 and -(14.12a^1/6)/b^1/2 (because function is symmetrical)

and, "Calculate Ds = -U(rs)", do i write "Ds = -(0.25b^2/a)"

(nb. those solutions are from my image above)
Yes (assuming a and b are positive).

By the way, if you plot a graph of U versus r (substitute some positive values for a and b) its very clear what's going on.

15. Thanks for the confirmation frantic.

Yes, i would have loved to graph the function before i started then i would have known what i was dealing with - but i cant because i cant factories it so i cant set x values!

Page 1 of 2 12 Last