Combining and normalizing functions in a plot

In summary: I've put in a call to a friend who is a mathematician and I'm hoping he can help me with that. In summary, I have the following formulae that I found:h[D1_,L_] := (S*H)/D1;alpha[L_,D1_] := ArcTan[L/D1];b[D_1,L_]:= (S*B)/((D1^2 + L^2)^0.5);c[D1_,L_]:=(S*Tan[ArcCos[((D1 - B/2)^2 + (D1 + B/2
  • #1
SoggyBottoms
59
0
I have the following formulae that I found:

Code:
h[S_, H_, D1_] := (S*H)/D1;
α[L_, D1_] := ArcTan[L/D1];
b[S_, B_, D1_, L_] := (S*B)/((D1^2 + L^2)^0.5);
c[S_, B_, D1_, L_] := 
  S*Tan[ArcCos[((D1 - B/2)^2 + (D1 + B/2)^2 + 2 L^2 - B^2)/(
     2 Sqrt[(D1 - B/2)^2 + L^2] Sqrt[(D1 + B/2)^2 + L^2])]];
a = b*c;

I have to plot these functions for values of D1 between 20 and 400 cm at a height of L = 160 cm. S and H are not given, so I'm not sure what to do with those.

To compare these functions I have to normalize them by multiplying them by a constant so that their values are all 1 at D1 = 20 cm. Then I have to plot them all in the same figure. Does anyone know how I could do this?
 
Physics news on Phys.org
  • #2
If L and D1 are fixed then you can find your scale factor for α[L, D1]==1.

You have one α==Alpha, is that a typo and should be a?

You have a=b*c, are you multiplying unknown free variables or perhaps functions a,b,c?

Is there a chance you can substantially simplify the definition of c[S,B,D1,L]?
 
  • #3
The alpha is not a typo, it's a different function from a. The b and c in a = b*c are not unknown variables, but the functions b[S_, B_, D1_, L_] and c[S_, B_, D1_, L_].

I've tried simplifying c[S_, B_, D1_, L_], but Mathematica doesn't return anything simpler and I have no clue how I could do it myself.

I probably should give some more info: These functions are so called metric cues, that give information about the distance of an object. These cues have certain values, like the projected size of an image on the retina. The first function, h, I calculated from this sideview image:

http://img861.imageshack.us/img861/208/50703749.jpg

I changed D to D1 and L to L1 in my functions, because Mathematica was giving me issues. The second one, alpha, I calculated from this sideview image:

http://img233.imageshack.us/img233/761/68221672.jpg

The width b of the projected image on the retina of the tile (the square with sides B), the height c of the projected image on the retina of the same tile and the area of the projected image on the retina of the tile I calculated from this sideview image:

http://img715.imageshack.us/img715/1009/35292241.jpg

The curvature of the retina did not have to be taken into account and instead should be treated as a flat vertical plane. I'm not sure all the functions I calculated are even correct, but this gives you an idea where they come from.

So now I have to plot them all in the same figure, with D1 between 20 and 400 cm, L1 fixed at 160 cm and all functions normalized to return a value of 1 at D1 = 20. No values were given for S or H. This is where I'm stuck.
 
Last edited by a moderator:
  • #4
I recommend putting Mathematica aside for the moment and use your diagrams and algebra until you clearly understand the problem, the equations you need and exactly what you want. Then you can ask for a plot.
 
  • #5
So...my equations are wrong?
 
  • #6
SoggyBottoms said:
So...my equations are wrong?

You have Five different functions, five different variables, have said you aren't sure what to do with some of these, are saying a=b*c is multiplying functions, but that isn't at all how functions are multiplied in Mathematica, and you don't seem to be clear on how to go about scaling these so they all agree at a point.

Any one or two of those would be enough reason for me to pause and figure out exactly what I really wanted before going back to Mathematica.

Mathematica seems at times to make it too easy to
1. type a bunch of stuff in.
2. get a bunch of stuff
2A. not know what it means or
2B. get an error and not know what that means or
2C. assume whatever came out is correct or
2D. notice it must be wrong
and finally
3. not know what to do about any of this.
 
  • #7
Okay, forgetting about the last two equations for a second, because I'm pretty sure the first three are correct. I think I may set S to say 2.5 cm and H and B to say 10 cm, to make the functions only depend on D (D1 for me) and L (which will be a fixed number), because we are only interested in seeing how the functions depend on the distance. Then we have:

Code:
h[D1_] := 25/D1;
α[D1_,L_] := ArcTan[L/D1];
b[D_1,L_]:= 25/((D1^2 + L^2)^0.5);

The next step is to scale them so they all return a value of 1 at D1 = 20 and L fixed at 160 cm. I could calculate this manually and just multiply the functions by whatever value I find, but I think it would look nicer to do this with mathematica...
 
Last edited:
  • #8
SoggyBottoms said:
The next step is to scale them so they all return a value of 1 at D1 = 20 and L fixed at 160 cm. I could calculate this manually and just multiply the functions by whatever value I find, but I think it would look nicer to do this with mathematica...

I am away at the moment and cannot test this, so you need to verify and correct any errors.

D1=20;L=160;
h[D1_] := 25/D1;
α[D1_,L_] := ArcTan[L/D1];
b[D_1,L_]:= 25/((D1^2 + L^2)^0.5);
Plot[{h[d1]/h[D1],α[d1,L]/α[D1,L],b[d1,L]/b[D1,L]},{d1,20,400}]

so when d1==D1==20 each of the three expressions will == 1
and when d1 varies from 20 to 400 it should plot your three functions correctly scaled.

Note: This is a terrible programming style and makes it easy to misunderstand what is a parameter and what is a free variable.
 
  • #9
Thanks, that worked perfectly!
 

Related to Combining and normalizing functions in a plot

1. How do I combine multiple functions in a single plot?

To combine multiple functions in a single plot, you can simply add each function to the same graph by using the "plot" function in your chosen programming language. Alternatively, you can also use the "hold on" or "hold all" commands to overlay multiple plots on the same graph.

2. What is the purpose of normalizing functions in a plot?

Normalizing functions in a plot allows for better comparison and understanding of the data. By scaling the functions to the same range, it becomes easier to see the differences and patterns between them.

3. How can I normalize a function in a plot?

To normalize a function in a plot, you can divide each data point by the maximum value of the function. This will scale the data to a range of 0 to 1. Alternatively, you can also use other normalization techniques such as z-score or min-max normalization.

4. What is the difference between combining and normalizing functions in a plot?

Combining functions in a plot refers to overlaying multiple functions on the same graph, while normalizing functions refers to scaling the functions to the same range. Combining functions allows for comparison of different functions, while normalizing allows for better comparison of the data within each function.

5. Can I combine and normalize functions at the same time in a plot?

Yes, you can combine and normalize functions at the same time in a plot. In fact, normalizing the functions before combining them can make it easier to compare and understand the data. You can do this by normalizing each function separately before adding them to the same plot.

Similar threads

  • Calculus and Beyond Homework Help
Replies
2
Views
770
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
858
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • Special and General Relativity
5
Replies
146
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
750
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Replies
13
Views
930
Back
Top