Solution: Plotting Mathematica Homework w/ Recursion Limit Error

In summary, the conversation discussed a problem involving equations and an attempt at a solution using ContourPlot3D. The error encountered was a recursion limit error, which was fixed by changing the names of the variables used.
  • #1
Ashley1nOnly
132
3

Homework Statement


upload_2018-9-12_15-48-13.png


Homework Equations


E= kq/r^2 * r-hat

where q= +/-(1.6*10^-19)

The Attempt at a Solution


x=

(1.6*10^-19)*x/(x^2+y^2+(z+1)^2)^(3/2) - (1.6*10^-19)*x/(x^2+y^2+(z-1)^2)^(3/2)y=

(1.6*10^-19)*y/(x^2+y^2+(z+1)^2)^(3/2) - (1.6*10^-19)*y/(x^2+y^2+(z-1)^2)^(3/2)

z=

(1.6*10^-19)*(z+1)/(x^2+y^2+(z+1)^2)^(3/2) - (1.6*10^-19)*(z-1)/(x^2+y^2+(z-1)^2)^(3/2)ContourPlot3D[{x,y,z},{x,-5,5},{y,-5,5},{z,-5,5}]

This should work but it is giving me a recursion limit error. I know that the math (well at least I think) is correct.

Any suggestions on how to fix the error?
 

Attachments

  • upload_2018-9-12_15-48-13.png
    upload_2018-9-12_15-48-13.png
    1.5 KB · Views: 605
  • upload_2018-9-12_15-48-59.png
    upload_2018-9-12_15-48-59.png
    5.1 KB · Views: 319
Physics news on Phys.org
  • #2
Ashley1nOnly said:

Homework Statement


View attachment 230602

Homework Equations


E= kq/r^2 * r-hat

where q= +/-(1.6*10^-19)

The Attempt at a Solution


x=

(1.6*10^-19)*x/(x^2+y^2+(z+1)^2)^(3/2) - (1.6*10^-19)*x/(x^2+y^2+(z-1)^2)^(3/2)y=

(1.6*10^-19)*y/(x^2+y^2+(z+1)^2)^(3/2) - (1.6*10^-19)*y/(x^2+y^2+(z-1)^2)^(3/2)

z=

(1.6*10^-19)*(z+1)/(x^2+y^2+(z+1)^2)^(3/2) - (1.6*10^-19)*(z-1)/(x^2+y^2+(z-1)^2)^(3/2)ContourPlot3D[{x,y,z},{x,-5,5},{y,-5,5},{z,-5,5}]

This should work but it is giving me a recursion limit error. I know that the math (well at least I think) is correct.

Any suggestions on how to fix the error?

I haven't checked your physics; the rest of this reply is solely involving the recursion limit error.

You are using your x, y, and z variables for different things in different places. Try changing the names of your variables appropriately.

For example, right now you have
x = a function of x (and also y and z).

Try changing that to

x1 = a function of x (and also y and z)

or some other variable name that makes more sense.
 
  • #3
Thanks, that worked. It gave me an answer with the expected lines but it does look funny.

upload_2018-9-12_18-15-33.png
 

Attachments

  • upload_2018-9-12_18-15-33.png
    upload_2018-9-12_18-15-33.png
    31.8 KB · Views: 379

What is a recursion limit error in Mathematica?

A recursion limit error in Mathematica occurs when a recursive function reaches the maximum number of iterations allowed by the software. This can happen when the function is being evaluated and calls itself too many times, resulting in the error.

How can I fix a recursion limit error in Mathematica?

One way to fix a recursion limit error is to increase the maximum number of iterations allowed by the software using the $RecursionLimit command. Another way is to rewrite the recursive function to use an iterative approach instead.

Why is it important to set a recursion limit in Mathematica?

Setting a recursion limit in Mathematica is important because it prevents the software from getting stuck in an endless loop when evaluating recursive functions. It also helps avoid potential memory issues and keeps the program running efficiently.

Can I change the recursion limit in just one function in Mathematica?

Yes, you can change the recursion limit for a specific function in Mathematica by using the $RecursionLimit command within that function. This allows you to have different recursion limits for different functions in your code.

Is there a recommended recursion limit setting for Mathematica?

There is no universally recommended recursion limit setting for Mathematica, as it depends on the specific function being evaluated and the amount of memory available on your computer. It is best to experiment with different recursion limit values to find the optimal setting for your particular situation.

Similar threads

  • Introductory Physics Homework Help
Replies
9
Views
2K
  • Introductory Physics Homework Help
Replies
14
Views
1K
  • Introductory Physics Homework Help
Replies
2
Views
873
  • Introductory Physics Homework Help
Replies
25
Views
282
  • Introductory Physics Homework Help
Replies
3
Views
8K
  • Introductory Physics Homework Help
Replies
1
Views
999
  • Introductory Physics Homework Help
Replies
1
Views
900
  • Introductory Physics Homework Help
Replies
2
Views
8K
  • Introductory Physics Homework Help
Replies
7
Views
1K
  • Introductory Physics Homework Help
Replies
10
Views
1K
Back
Top