Is there an equation that, given the two points of a line segment, will result, when graphed for x on a real graph, in a line segment?
$\endgroup$ 38 Answers
$\begingroup$Around a year or so ago I came up with an equation that, when graphed on a real graph, graphs a line segment. It does so by making the numbers which are not a part of the segment imaginary, thus unable to be graphed on a real graph. The equation is as follows: $$y=\frac{(B-D)\left(\sqrt{x-A}\sqrt{|x-A|}-\sqrt{C-x}\sqrt{|C-x|}-x\right)+AB-CD}{A-C}$$ where (A,B) is the left-most point and (C,D) is the right-most point (that is, where $C > A$.) $$y \in \begin{cases} \ \mathbb{R} & \iff A \le x \le C,\\ \ \mathbb{I} & \text{otherwise} \end{cases}$$ So, in English, $y$ will be real if and only if $x$ is between $A$ and $C$; otherwise, it will be imaginary. Say for example I wanted to graph a segment from (-4,3) to (5,6). In that case, the equation becomes $$y=\frac{(3-6)\left(\sqrt{x+4}\sqrt{|x+4|}-\sqrt{5-x}\sqrt{|5-x|}-x\right)-(-4\bullet3)-(5\bullet6)}{-4-6}$$ which results in the following: $$\text{when}\; x=-5,\; y=3+\frac{1}{3}i;\; x=-4,\; y=3;\; x=5,\; y=6;\; x=6,\; y=6-\frac{1}{3}i$$ I have no clue for what, if anything, this could be used. I just thought I would share it since it was doing me no good. Anyway, thank you in advance for any positive feedback or constructive criticism.
$\endgroup$ 7 $\begingroup$Thinking in another way from the answer from Steven Fontaine, you can use any function that is only defined for some $x\in\Bbb R$ but not other $x$'s.
For example, since $\arcsin x$ is only defined for $[-1,1]$, you can write
$$y = mx + c + \arcsin x - \arcsin x$$
to "capture" the piece of straight line between $[-1,1]$. By adjusting the domain of $\arcsin (m'x+c')$ using $m'$ and $c'$, you can then "capture" any non-vertical finite segment.
Similarly, you may use $\sqrt{x}$ or $\ln{x}$ to graph a ray, the former includes the starting point and the latter does not.
$\endgroup$ $\begingroup$An expression I found that works very well is
$$\frac{-(x-b_1)(x-b_2)}{\sqrt{-(x-b_1)(x-b_2)}^2}$$
This works well as it is equal to 1 and can be inserted into any function in the form $y=mx+b.
The way that I constructed this expression was by realizing that a square root function is only real for x values where $\sqrt{x}$ is positive.
Then I realized that since a quadratic has 2 zeroes that I could use a binomial to insert the values where I want the limits to be.
$\endgroup$ $\begingroup$Or you can just use vectors. $(x,y,z)+t\langle a,b,c\rangle$.
That is to say, for a line going from point $(1,1,1)$ to the point $(21,21,21)$, the equation would be $r(t)=(1,1,1)+t\langle 1,1,1\rangle$ such that $0<t<21$
$\endgroup$ $\begingroup$Let me explain how this works. First ill explain what does, what is going on is that if x is less than a x-a will always be negative so the square root of x-a when it is negative would be undefined so it can't be graphed.multiplying the square root of x-a by
just makes x, x again after it finds out if it is undefined or not. The plus b is just so the line starts at b as y instead of 0 as y. The
is so that if x is greater than the set ending point of c it will be negative then be undefined meaning that point can't be graphed.The
is just the slope of the line using
(y2-y1)/(x2-x1).
A very simple way to do this would be to add and then subtract the square roots of an expression to define the domain. For example:
Given $(3,34)$ and $ (5, 52)$, first find the equation for the line that goes between the two points:
$(52-34)/(5-3)x + b = y$
$y = 9x + b$
$34 = 9(3) + b$
$b = 7$
Therefore, the equation of the line is: $y = 9x + 7$
To restrict the domain to $[3, 5]$ start by adding and subtracting $\sqrt(x-3)$. The equation becomes:
$y = 9x + 7 + \sqrt{x-3}- \sqrt{x-3}$
To restrict the upper part of the domain, add and subtract √(-x+5). The final equation becomes:
$y = 9x + 7 + \sqrt{x-3} - \sqrt{x-3} + \sqrt{-x+5} - \sqrt{-x+5}$
Hope this helps!
$\endgroup$ $\begingroup$I got a rather simple answer here.
I've recently been playing around with shapes on a graphing calculator using this technique I came up with. It has a similar concept with what Harish Chandra Rajpoot posted above but I think I should share this.
Let's just take the equation x=y on a plane, and we want to cut that line to make it a line segment from (-1,-1) to (2,2).
First we remove everything from x=-1 and below by multiplying any side of the equation by √(x+1)/√(x+1). This just multiplies the equation by one and also makes the equation indeterminate whenever x < -1.
Now we got x = y * √(x+1)/√(x+1)
Next step is to remove everything from x=2 and above by multiplying any of the sides by √(-x+2)/√(-x+2). It does the same thing but makes the equation indeterminate whenever x > 2.
Finally, we have x = y * √(x+1)/√(x+1) * √(-x+2)/√(-x+2)
I hope I helped out someone out there.
$\endgroup$ $\begingroup$I made a pretty simple and straightforward equation that can be used to limit any function:
For example:
here sqrt(2) is the lower bound of the function f(x)=x²+4 and 2 is the upper bound.
Keep in mind that sqrt(2) and 2 are not in the domain of f(x)
If you do want them in the domain of your function you can simply do:
$\endgroup$