Solution: Plotting Mathematica Homework w/ Recursion Limit Error

Click For Summary
SUMMARY

The forum discussion addresses a recursion limit error encountered while plotting a Mathematica homework problem involving electric field equations. The user attempted to define variables x, y, and z in a way that caused confusion in their definitions, leading to the recursion limit issue. A solution was provided by suggesting the renaming of variables to avoid conflicts, such as changing 'x' to 'x1' in the function definitions. This adjustment resolved the error and produced the expected output.

PREREQUISITES
  • Understanding of electric field equations, specifically E= kq/r^2 * r-hat.
  • Familiarity with Mathematica syntax and functions, particularly ContourPlot3D.
  • Knowledge of variable scope and naming conventions in programming.
  • Basic principles of recursion and its limitations in programming environments.
NEXT STEPS
  • Explore advanced Mathematica plotting techniques, including 3D visualizations.
  • Learn about variable scoping and naming conventions in programming to avoid recursion issues.
  • Study the principles of recursion in programming and how to manage recursion limits effectively.
  • Investigate electric field calculations and their applications in computational physics.
USEFUL FOR

Students and educators in physics and mathematics, Mathematica users facing recursion issues, and anyone involved in computational modeling of electric fields.

Ashley1nOnly
Messages
132
Reaction score
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: 746
  • upload_2018-9-12_15-48-59.png
    upload_2018-9-12_15-48-59.png
    5.1 KB · Views: 393
Physics news on Phys.org
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.
 
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: 496

Similar threads

  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 3 ·
Replies
3
Views
9K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
9K
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K