Reflecting light ray between two curves in Mathematica

Click For Summary

Discussion Overview

The discussion revolves around modeling the behavior of a bouncing light ray between two parabolic curves using Mathematica. Participants explore the syntax and coding techniques necessary to simulate the reflection of light, including finding intersections, slopes, and normals at the points of contact.

Discussion Character

  • Technical explanation
  • Exploratory
  • Homework-related

Main Points Raised

  • One participant seeks guidance on how to code the reflection of a light ray between two parabolic curves in Mathematica, expressing difficulty in finding relevant examples and syntax.
  • Another participant suggests that finding the intersection of a line with a parabolic surface involves solving a quadratic equation, and outlines a method to determine the slope of the parabola and the normal at the intersection point.
  • A participant indicates familiarity with finding slopes but requests help specifically with Mathematica syntax for using values obtained from NSolve in subsequent calculations.
  • One participant provides a basic example of how to plot two parabolas in Mathematica and suggests practicing drawing points and lines to understand graphics commands better.
  • Another participant shares a method for dereferencing values obtained from NSolve to use them in further calculations, providing an example for clarity.

Areas of Agreement / Disagreement

Participants generally agree on the methods for finding slopes and intersections, but there is no consensus on the specific syntax or coding techniques in Mathematica, as some participants express uncertainty and seek further clarification.

Contextual Notes

Participants mention specific functions and commands in Mathematica, but there are unresolved issues regarding the correct syntax for using outputs from NSolve in further computations. The discussion does not resolve these technical challenges.

Who May Find This Useful

This discussion may be useful for individuals interested in computational modeling, particularly those working with Mathematica for graphical simulations in physics or mathematics.

interference
Messages
6
Reaction score
0
Hello everyone,

I am working on trying to model a bouncing light ray between two curves, and I would like to model it in Mathematica. However, I do not know what syntax or how to go about typing the code in. I tried to find examples on the Mathematica Documentation Centre but the examples there are not to relevant.

For example, I have two curves, let's say two parabolic curves one above the other. I want to simulate these as mirror and bounce a light ray between the two curves. Can anyone give me an idea on what Syntax to do it?

I understand people draw lines using the Line command, but I do not know how to proceed from there, such as how to program the line to reflect and calculate the slope and normal at the point where the light ray hits one curve and so on.

Thanks very much :)
 
Physics news on Phys.org
I don't know Mathematica, however:

If you have the equation of the line, you can find it's intersection with a parabolic surface. It's just solving a quadratic equation.

Once you have the intersection, you can find the slope of the parabola, and from that the slope of the normal at that point (taking the negative reciprocal).

Finally, since slope is the tangent of the angle of the line or normal, you can use the law of reflection to get the angle or slope of the reflected line. Since you have that slope, and a point on the reflected line, you can get its equation and find where i intersects the other surface.

Hope that helps. Feel free to ask more specific questions about the procedure I outlined here.
 
Last edited:
Hi Redbelly98, yes I do know how to find the slope and all but I need help with the syntax with which to write a code so that Mathematica and do it.

Now for example, if I use NSolve to solve for a slope at a particular place, it gives me for example x-> 0.2. Does anyone know how I can use this value to be placed into another equation? Because if I put the NSolve function into a new function to solve, Mathematica cannot do that because it reads the value not as "0.2" but as "x->0.2".

Thanks!
 
You need to get familiar with drawing lines and curves and just graphics in general in Mathematica.

First just draw two parabolas. Say for example:

y1=x^2+2x-1

y2=-3x^2-x+4

Then to draw those, I'd code:

myplot=Plot[{x^2+2x-1,-3x^2-x+2},{x,-5,5},PlotRange->{{-5,5},{-5,5},PlotStyle->{Red,Blue}]

That's a good start. Get a print-out of that. Now just practice drawing dots on the parabolas. Say for example, draw a green dot at the point (1,2) on the first one:

mydot1=Graphics[{PointSize[0.008],Green,Point[{1,2}]}];

Show[{myplot,mydot1}]

Draw a dot on the second one:

mydot2=Graphics[{PointSize[0.008],Green,Point[{1,0}]}];

Now draw a straight line between the two points:

myline1=Graphics[{Yellow,Line[{{1,2},{1,0}}];

Now show everything:

Show[{myplot,mydot1,mydot2,myline1}]

Or if you wanted to draw a line with just the function, use:

Plot[m x+b,{x,b1,b2}]

and to dereference that x->2, try this example and then apply it to yours:

myroots = NSolve[(x - 2) (x + 2) == 0, x]
theroots = x /. myroots
firstone = theroots[[1]]
 
Last edited:

Similar threads

  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 58 ·
2
Replies
58
Views
7K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 4 ·
Replies
4
Views
1K
Replies
3
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 34 ·
2
Replies
34
Views
4K