Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Combining and normalizing functions in a plot

  1. Jan 3, 2012 #1
    I have the following formulae that I found:

    Code (Text):

    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?
  2. jcsd
  3. Jan 4, 2012 #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]?
  4. Jan 4, 2012 #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 [Broken]

    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 [Broken]

    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 [Broken]

    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: May 5, 2017
  5. Jan 5, 2012 #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.
  6. Jan 5, 2012 #5
    So...my equations are wrong?
  7. Jan 5, 2012 #6
    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.
  8. Jan 5, 2012 #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 (Text):

    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: Jan 5, 2012
  9. Jan 5, 2012 #8
    I am away at the moment and cannot test this, so you need to verify and correct any errors.

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

    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.
  10. Jan 5, 2012 #9
    Thanks, that worked perfectly!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook