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

In summary, the conversation discusses the creation of a function to graph a capital "B" with multiple y values for some x values. The use of "±" signs is mentioned to achieve this. The issue of a vertical line is brought up and the use of a Fourier series is suggested. The equation for the series is given and the question of whether it plots what is intended is posed. The use of a floor function is also discussed to manipulate the function and create a vertical line at x=0. The question of whether this would affect the vertical line created by the Fourier series is asked. Different solutions are suggested, including using a rotation matrix or a function with absolute values. The conversation also delves into a detailed explanation of how to
  • #1
sgfw
15
0
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:

StM8D9G.gif


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:

eq5FIbI.gif


In case you can't see the picture:

floor(e^(-abs(x)))

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:
Mathematics news on Phys.org
  • #2
What's wrong with X=c ? Where c is the location of of your vertical line.
 
  • #3
sgfw said:
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.
Why not simply use a straight line which is very steep in relation to the horizontal extent of the "B"?
 
  • #4
kith said:
Why not simply use a straight line which is very steep in relation to the horizontal extent of the "B"?

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.
 
  • #5
Integral said:
What's wrong with X=c ? Where c is the location of of your vertical line.

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:
  • #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?
 
  • #7
Number Nine said:
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?

B on it's back would have three vertical lines.
 
  • #8
It would also be easy to use a parametric representation of the figure with piecewise defined functions ##\langle x(t),y(t)\rangle##.
 
  • #9
LCKurtz said:
It would also be easy to use a parametric representation of the figure with piecewise defined functions ##\langle x(t),y(t)\rangle##.

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:

kjjZ6ux.gif

(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:

vPwxt7D.gif


(http://i.imgur.com/vPwxt7D.gif)

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:

hwJ7n44.gif


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.
 
  • #10
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)}} =
\begin{cases}
1, & y\in(a,b) \\
i, & y\notin[a,b] \\
\text{undefined}, & y = a,b
\end{cases}$$

So for example,
$$x+0.5\sqrt{\frac{|(y-2)(2-y)|}{(y-2)(2-y)}}=0$$
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
$$(x+0.5)^2+(y-1)^2=1$$
and the circle with centre ##(-0.5,-1)## and radius 1 is
$$(x+0.5)^2+(-y-1)^2=1$$
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
$$(x+0.5)^2+(|y|-1)^2=1$$
And if we solve for x we get
$$x=-0.5\pm\sqrt{1-(|y|-1)^2}$$
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
$$x+0.5-\sqrt{1-(|y|-1)^2}=0$$

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

$$\left(x+0.5\sqrt{\frac{|(y-2)(2-y)|}{(y-2)(2-y)}}\right)\left(x+0.5-\sqrt{1-(|y|-1)^2}\right)=0$$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!
 
  • #11
@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.
 
  • #12
@mentallic

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.
 
  • #13
I'm about to head to sleep now, but before I go

sgfw said:
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.

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) =
\begin{cases}
0, & x>0 \\
1, & x<0 \\
\text{undefined}, & x=0
\end{cases}$$
 
Last edited:
  • #14
LCKurtz said:
@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.

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?

oferGKl.gif
 
  • #15
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.
 
  • #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.
 
  • #17
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.
 
  • Like
Likes 1 person
  • #18
jackmell said:
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.

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?
 
  • #19
LCKurtz said:
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?

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.
 

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

1. How do I create a function to graph a capital B?

To create a function that graphs a capital B, you will need to use a programming language such as Python or JavaScript. First, define the function and specify the parameters for the capital B. Then, use mathematical equations and plotting techniques to create a visual representation of the letter.

2. What programming language should I use to create this function?

You can use any programming language that supports mathematical equations and graphing capabilities. Some popular options include Python, JavaScript, and MATLAB.

3. Can I use pre-existing libraries or functions to graph a capital B?

Yes, there are many pre-existing libraries and functions available for different programming languages that can help you graph a capital B. These libraries often have built-in functions specifically for creating graphs and plots.

4. What are some important factors to consider when creating a function to graph a capital B?

Some important factors to consider include the size and scale of the graph, the coordinate system to use, and the specific parameters of the capital B (such as its height and width). It is also important to test your function and make sure it accurately represents the letter.

5. Are there any online resources or tutorials available to help me create this function?

Yes, there are many online resources and tutorials available that can guide you through the process of creating a function to graph a capital B. These resources can provide step-by-step instructions, sample code, and helpful tips and tricks to make the process easier.

Similar threads

Replies
12
Views
1K
  • General Math
Replies
2
Views
736
Replies
17
Views
2K
Replies
2
Views
691
Replies
5
Views
1K
Replies
5
Views
854
Replies
4
Views
448
Replies
37
Views
3K
Replies
8
Views
947
Replies
2
Views
1K
Back
Top