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

I'm trying to create a function that graphs a capital B

  1. Jun 18, 2013 #1
    I'm trying to create a function that graphs a capital "B"

    So it's not really a function, it has multiple y values for some x values, but I'm achieving that by using "±" signs when appropriate. My problem, however is the vertical line. I thought for a long time how to come up with a equation that could graph a vertical line in one particular x value, but be a relatively normal function throughout the rest of its domain. I decided to use a fourier series, as shown below:


    In case you can't see the picture:

    y = sum_(k = 1)^∞ ((sin(2*pi*(2k-1))*x)/(2k-1))

    You may or may not know that that graphs a square wave, (which has vertical lines) both according to wikipedia and a short python program I made, but according to wolframalpha, it does not. So, do you know whether or not this plots what I think it does?

    Also, to manipulate the function to make it a vertical line at x = 0, but y = 0 when x ≠ 0, I multiplied it by this function of x:


    In case you can't see the picture:


    which is equal to 0 when x ≠ 0, but equals 1 when x = 0. The question I have about this is, because it would zero out the function at every x value except for exactly one, would a vertical line created by the former function at that exact point be unaffected?

    Thank you, and sorry if this is a little wordy, or posted in the wrong place.
    Last edited: Jun 18, 2013
  2. jcsd
  3. Jun 18, 2013 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    What's wrong with X=c ? Where c is the location of of your vertical line.
  4. Jun 18, 2013 #3


    User Avatar
    Science Advisor

    Why not simply use a straight line wich is very steep in relation to the horizontal extent of the "B"?
  5. Jun 18, 2013 #4
    I thought about doing that, but I would rather avoid it because it would complicate the rest of the letter.

    As I have it, all I need to do is add "± (1/2±1/2)", then multiply that by something similar to the floor(e^-abs(x)) to make it zero out over the rest of it's domain for the three horizontal lines, and that would be severely complicated if they didn't all start and end at the same x values, which would be the case if the line weren't completely vertical.
  6. Jun 18, 2013 #5
    I need the function to be defined over the rest of the set of real numbers. x = c would create a vertical line, but the domain would be limited to c. In addition, I'm trying to limit the vertical line to an arbitrary range.
    Last edited: Jun 18, 2013
  7. Jun 18, 2013 #6
    Why not write a function that graphs a B on its back (much easier), and then apply a rotation matrix to its graph in R2 to put it upright?
  8. Jun 18, 2013 #7
    B on it's back would have three vertical lines.
  9. Jun 18, 2013 #8


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    It would also be easy to use a parametric representation of the figure with piecewise defined functions ##\langle x(t),y(t)\rangle##.
  10. Jun 18, 2013 #9
    I'm trying to keep it to a single y = f(x) function, and the way I have been separating the different section of the functions so far is this:

    Say I want a function that looks like this when graphed:

    (can be seen at http://i.imgur.com/kjjZ6ux.gif if the you can not see the image)

    between x = -0.5 and x = 0.5 the function is y = x^2, and for the rest of the domain, the function is y = 0.25.

    The way this can be achieved is this:

    x^2(abs(x)-x) will be equal to zero when x is positive, but not when x is negative. When x is negative it will not, however be equal to x^2 because it is being multiplied by a function of x that is not 1. To make that function equal to 1 when x is negative, I raised (abs(x)-x) to the power of (abs(x)+x), which is zero when x is negative.

    so, the expression (abs(x)-x)^(abs(x)+x) is equal to 0 when x is positive, and 1 when x is negative, so I can multiply it by a function, and make that function only apply when x is negative.

    y = x^2(abs(x)-x)^(abs(x)+x)

    now, I have the function x^2 limited to an upper bound but no lower bound. To achieve this, I can replace x with a function of x that is only negative where I want x^2 to be the function, such as abs(x) - 1/2

    y = x^2(abs(abs(x)-1/2)-abs(x)-1/2)^(abs(abs(x)-1/2)+abs(x)-1/2)

    Now it plots something like this:



    to make x = 0.25 outside of the -0.5 to 0.5 range, I add 0.25 multiplied by a similar function, with a negative version of the sub-function of x mentioned earlier, making the entire finished equation come out to be:


    y = x^2(abs(x)-1/2 - abs(abs(x) - 1/2))^abs(abs(x)-1/2 + abs(abs(x) - 1/2)) + 0.25(abs(x)-1/2 + abs(abs(x) - 1/2))^abs(abs(x)-1/2 - abs(abs(x) - 1/2))

    This was wordy, and somewhat beside the point. I may have explained it in a way that makes more sense in my head than it actually does. Tell me if you need clarification.
  11. Jun 18, 2013 #10


    User Avatar
    Homework Helper

    Or what about using a single equation that describes your graph but instead involves absolute values?

    The vertical line ##x=k## with ##k\neq 0## can have its range restricted to ##y\in(a,b)## by using the fact that
    $$\sqrt{\frac{|(y-a)(b-y)|}{(y-a)(b-y)}} =
    1, & y\in(a,b) \\
    i, & y\notin[a,b] \\
    \text{undefined}, & y = a,b

    So for example,
    to graph the line ##x=-0.5## with ##-2<y<2##

    I'm not exactly sure how you want the curly sections of the letter B to look, but if you wanted to use truncated circles, then we could use a similar idea to the above.

    The circle with centre ##(-0.5,1)## and radius 1 is
    and the circle with centre ##(-0.5,-1)## and radius 1 is
    now, since all we've changed is the sign of the y variable to get the second circle, we can get those two circles with simply
    And if we solve for x we get
    Which, if we discard the negative of the ##\pm## symbol, we will only get the right half of the two circles, so we have the equation

    And finally, since if we have an expression of the form ##a\cdot b=0## which is satisfied when either ##a=0## or ##b=0##, then the letter B can be described in a way by


    Sadly, I couldn't get it to work on maple, so it could possibly be all wrong, or maybe I just don't know how to use the software properly, or possibly both!
  12. Jun 18, 2013 #11


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    @sgfw: Whatever floats your boat. A simple parametric representation of 4 straight line segments and 2 semicircles would be simpler than what you have already written, wouldn't require rotation, and would look more like a B when it was finished.
  13. Jun 18, 2013 #12

    Well, the reason I am making these letters is so I can plot words by adding the different letter functions together, which works because any x value not occupied by another letter is equal to zero, so adding a letter to that function shifted to the right will work well. The reason I am looking for y = f(x)-type functions is that I'm worried that having y on both sides may complicate that. Although your thought process has an appealingly simple outcome, I am worried that because the equation is not defined throughout the entire domain, it will be impossible to create a word or sentence out of a single function.
  14. Jun 18, 2013 #13


    User Avatar
    Homework Helper

    I'm about to head to sleep now, but before I go

    If you're ok with an undefined point (just a little more undefined than ##0^0## :wink:) then just divide by ##-2x## to achieve the same result:
    $$\frac{|x|-x}{-2x} = \frac{1}{2}\left(1-\frac{|x|}{x}\right) =
    0, & x>0 \\
    1, & x<0 \\
    \text{undefined}, & x=0
    Last edited: Jun 18, 2013
  15. Jun 18, 2013 #14
    I may be overcomplicating your idea, but I opened MS word (sorry in advance for the quality) and drew what I understand to be the functions of t that define both x and y on a graph. I don't know how I would write an equation for those. Were you thinking of something more simple that I'm not understanding, or is this what you had in mind?

  16. Jun 18, 2013 #15


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    A vertical line from ##(0,0)## to ##(0,3)## would be ##\langle x(t),y(t)\rangle =
    \langle 0,t\rangle,\, t = 0..3##. A circle centered at ##(a,b)## with radius ##r## would be ##\langle x(t),y(t)\rangle = \langle a + r cos(t), b + r sin(t)\rangle,\, t = 0..2\pi##. That's what parametric representations look like. Whether that will be useful to you given your design constraints, I don't know. On a calculator you would use "parametric plot" to see the graphs.
  17. Jun 18, 2013 #16
    That's an interesting problem from a Fourier analysis perspective: Where do you start on the B such that you track a nice one like LCKurtz suggested without going over your path more than once? I'd say start at the T-junction. Then we can write sectionally-continuous functions:

    [tex]x(t)=\sum_{j=1}^J x_j(t)[/tex]
    [tex]y(t)=\sum_{j=1}^J y_j(t)[/tex]

    for some interval [itex](0,T)[/itex] which tracts the B. Then we could expand each set of functions in terms of it's Fourier series. For example,

    [tex]x(t)=1/2 A_0+\sum_{n=1}^{\infty} \left(A_n\cos(n t)+B_n\sin(nx)\right)[/tex]

    with I think:

    [tex]A_n=\frac{1}{T}\int_0^T x(t)\cos(nt) dt[/tex]
    [tex]B_n=\frac{1}{T}\int_0^T x(t)\sin(nt) dt[/tex]

    Then the B would materialize as a continuous and analytic function of t as [itex]n\to \infty[/itex].

    Really I think some new aspiring member of PF outa' tackle this problem and show us how an (almost) perfect B materializes as we increase n.
  18. Jun 18, 2013 #17


    User Avatar
    Science Advisor

    To the OP: You should take a look at the specification for fonts in applications like Windows and Adobe.

    They solved this problem already and make use of appropriate parameterized curves.
  19. Jun 18, 2013 #18


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    I don't get the Fourier series idea. You have the parametric equations for x(t) and y(t). Why would you want to use a FS approximation to them instead of using them in the first place?
  20. Jun 19, 2013 #19
    Yes, to solve the problem, we don't need the FS. But doing the FS would be interesting and if I had the time, I'd work on it just for fun and also don't forget that if you do math, just doing math for fun gives you experience in various techniques that will inevitably become handy in the future when you run into problems which require a certain technique that you did for fun in the past.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: I'm trying to create a function that graphs a capital B
  1. Function of the graph. (Replies: 2)