Transform a straight line into a curve

2.7k Views Asked by At

I have an equation which is a straight-line with negative slope from (0, y_intercept) to (x_intercept, 0). Is there a mathematical transformation I can use to "curve" this line?

Stated another way, how would you create a graph which looks similar to y = 1/x, but has an explicit x and y intercepts?

Note, it doesn't matter what the function does outside the range of 0 to x_intercept.

Apologies for not knowing much math jargon, I'm translating to code. Any help or tips or correction of my thinking would be greatly appreciated.

3

There are 3 best solutions below

1
On BEST ANSWER

$$y=\dfrac2{x+1}-1=\dfrac{1-x}{1+x}$$ defines a curve that has $y$-intercept $1$ and $x$-intercept $1$ .


(I started with $y=\dfrac1x$ and added $1$ in the denominator to make the $y$-intercept $1$.

But that has no $x$-intercept, so I multiplied by $2$ and subtracted $1,$

to get $x$-intercept $1$ while maintaining $y$-intercept $1.)$

1
On

Update: suppose you want to create a curve from $(0,a)$ to $(b,0)$. Then the following will do: $$ \varphi_{a,b}(x) := \frac{a}{b} \frac{b - x}{1 + ax} $$ for all $a,b > 0$.


To expand on @J.W. Tanner's answer: For any $a > 0$ $$ f_a(x) := \frac{a(1 - x)}{a + x} $$ fulfills the condition: We have

  1. $f_{a}(1) = \frac{a(1 - 1)}{a + 1} = \frac{0}{a + 1} = 0$ and
  2. $f_{a}(x) = 1 \iff a + x = a - ax \iff x + ax = 0 \implies x = \frac{0}{a + 1} = 0$.

Here's a plot for $a \in \{1,1.5, 2,3\}$ (for $x \in (0,1)$ we have $f_a < f_b$ for $a < b$): enter image description here

If fact, the function $$ f_{a,b}(x) := \frac{a(1 - x)}{ax + b} $$ will also do for all $a,b > 0$ as you can check like I did above.

0
On

I did a lot of experiments to find the following general solution:

m = (y2 - y1) / (x2 - x1)

y(x) = y1 + (m (x - x1) / xslope)

Where:

  • y1 is the start y point desired;
  • y2 is the end y point desired;
  • x1 is the start x point desired;
  • x2 is the end x point desired;
  • slope is the curvature desired. 0 for straight, 0 to 1.25 for positive curvature, -100 to 0 for negative curvature

Some curves generated with the values:

  • y1 = 0.5;
  • y2 = 1.0;
  • x1 = 0.2;
  • x2 = 1.0;
  • slope: -10, 0, and 1.25;

plot examples

With a few changes in the formula, you can create a decreasing sloped too:

y(x) = y2 - (m (x - x1) / xslope)

Some curves generated with the formula above:

decreasing curves examples