Find equation of a function from another describing its slope: s(x) = 2((2x)^e)/((2x)^e + (1-2x)^e) for x<0.5, ...

CyroPaws

New member
Joined
May 31, 2024
Messages
5
Screenshot 2024-05-31 at 6.17.17 AM.png
I have this equation, where s(x) describes the slope of another line f(x). I want to find f(x) using s(x). I’ve also attached a simple graph that shows s(x) in grey, and what f(x) should look like in black. ( s(x) is scaled separately from f(x) in the y axis ). I’ve been trying to solve this for a few days so if anyone was able to solve it I’d be so grateful haha.
Screenshot 2024-05-31 at 6.18.22 AM.png
Each axis is from 0 to 1.
I already used integration to generate the points for the graph above, but I need to find the equation of f(x) not find the points. I need an equation, not a bunch of points.
 
View attachment 38021
I have this equation, where s(x) describes the slope of another line f(x). I want to find f(x) using s(x). I’ve also attached a simple graph that shows s(x) in grey, and what f(x) should look like in black. ( s(x) is scaled separately from f(x) in the y axis ). I’ve been trying to solve this for a few days so if anyone was able to solve it I’d be so grateful haha.
View attachment 38022
Each axis is from 0 to 1.
I already used integration to generate the points for the graph above, but I need to find the equation of f(x) not find the points. I need an equation, not a bunch of points.
How did you use integration to generate points? I'd expect it to generate an equation! Please show what you did in detail, so we can suggest ways to extend it.
 
View attachment 38021
I have this equation, where s(x) describes the slope of another line f(x).
You have this function f(x), which is a line (you stated this). The slope of the line is therefore a constant.
If s(x) describes the slope of f(x), then s(x) would be some constant. The s(x) you posted above is doesn't seem to be a constant.

Did you write something wrong?
 
You have this function f(x), which is a line (you stated this). The slope of the line is therefore a constant.
If s(x) describes the slope of f(x), then s(x) would be some constant. The s(x) you posted above is doesn't seem to be a constant.

Did you write something wrong?
The word "line" can also be used of a curved line (and the term was so used by Euclid). See definitions 7 and 8 here.

When we want to emphasize that we mean a straight line, we can say that, without redundancy.

Of course, in math we more often surprise students by calling a (straight) line a "curve"!
 
How did you get your points?
How did you use integration to generate points? I'd expect it to generate an equation! Please show what you did in detail, so we can suggest ways to extend it.
I wrote a program in JavaScript to find the points! If you understand JavaScript, then I hope this helps!

Code:
let e = 2.718281828459045;
function s(x) { // This is the slope equation
    if (x < 0.5) {
        return 2 * Math.pow(2 * x, e) / (Math.pow(2 * x, e) + Math.pow(1 - 2 * x, e));
    } else if (x > 0.5) {
        return 2 * Math.pow(2 * (x - 0.5), -e) / (Math.pow(2 * (x - 0.5), -e) + Math.pow(1 - 2 * (x - 0.5), -e));
    } else {
        return 0.5;
    }
}
function integrate(x, n) {
    const h = x / n; // 0.0005
    let sum = 0.5 * s(x);
    for (let i = 1; i < n; i++) {
        const x = i * h;
        sum += s(x);
    }
    return sum * h;
}
const n = 1000;
function findLine(n) { // This compiles the new line!
    const result = [];
    for (let i = 0; i <= n; i++) {
        const x = (i / n);
        const y = integrate(x, n);
        result.push({ x: x, y: y });
    }
    return result;
}
const line = findLine(n);
 
Last edited:
You have this function f(x), which is a line (you stated this). The slope of the line is therefore a constant.
If s(x) describes the slope of f(x), then s(x) would be some constant. The s(x) you posted above is doesn't seem to be a constant.

Did you write something wrong?
Sorry f(x) is not a straight line, it's a function that curves. It should look like the black curvy line in the graph.
 
Last edited:
I wrote a program in JavaScript to find the points! If you understand JavaScript, then I hope this helps!

Code:
let e = 2.718281828459045;
function s(x) { // This is the slope equation
    if (x < 0.5) {
        return 2 * Math.pow(2 * x, e) / (Math.pow(2 * x, e) + Math.pow(1 - 2 * x, e));
    } else if (x > 0.5) {
        return 2 * Math.pow(2 * (x - 0.5), -e) / (Math.pow(2 * (x - 0.5), -e) + Math.pow(1 - 2 * (x - 0.5), -e));
    } else {
        return 0.5;
    }
}
function integrate(x, n) {
    const h = x / n; // 0.0005
    let sum = 0.5 * s(x);
    for (let i = 1; i < n; i++) {
        const x = i * h;
        sum += s(x);
    }
    return sum * h;
}
const n = 1000;
function findLine(n) { // This compiles the new line!
    const result = [];
    for (let i = 0; i <= n; i++) {
        const x = (i / n);
        const y = integrate(x, n);
        result.push({ x: x, y: y });
    }
    return result;
}
const line = findLine(n);
So you used approximate numerical integration. Okay.

I did something similar (which I thought could be what you did) by asking Desmos to do it:

1717266634753.png
I presume what you have done to try to find an equation is to integrate the functions by hand; can you show us your attempt?

Also, can you tell us the context of your question? Is there any reason to expect that this can be integrated in closed form? Wolfram Alpha didn't seem to think so:

In that case, numerical integration may be the best you can do.
 
So you used approximate numerical integration. Okay.

I did something similar (which I thought could be what you did) by asking Desmos to do it:

I presume what you have done to try to find an equation is to integrate the functions by hand; can you show us your attempt?

Also, can you tell us the context of your question? Is there any reason to expect that this can be integrated in closed form? Wolfram Alpha didn't seem to think so:

In that case, numerical integration may be the best you can do.
This is for a final project where I'm making a financial tracking API with PHP haha, I stumbled upon this math problem while writing an algorithm for the API. I really just need to be able to give any x... and get the perfect y for f(x). If you don't think that it's possible to do that, then I believe you! And I'll probobly have to change how I'm approaching this in the API haha. I've never taken a calculus class before XD
 
Last edited:
This is for a final project where I'm making a financial tracking API with PHP haha, I stumbled upon this math problem while writing an algorithm for the API. I really just need to be able to give any x... and get the perfect y for f(x). If you don't think that it's possible to do that, then I believe you! And I'll probobly have to change how I'm approaching this in the API haha. I've never taken a calculus class before XD
Is there a reason you don't think your numerical integration (or a better one, if you need more precision) is adequate? It gives you a y for any x, right?

If it's too slow, it might be sufficient to make a table of values initially, and interpolate at run time.
 
Is there a reason you don't think your numerical integration (or a better one, if you need more precision) is adequate? It gives you a y for any x, right?

If it's too slow, it might be sufficient to make a table of values initially, and interpolate at run time.
I was thinking about doing that! But sadly the responses aren't exact! And since it's for a financial tracker, It's pretty important to make sure it's as close to exact as possible! I'm not sure what adequate means o3o
 
I was thinking about doing that! But sadly the responses aren't exact! And since it's for a financial tracker, It's pretty important to make sure it's as close to exact as possible! I'm not sure what adequate means o3o
No number you get from a calculator is exact, either! And though I have no idea what the formula does, I suspect that nothing financial is really exact, but is an idealization of the reality in some way.

The question will be, how much precision is sufficient. If you don't know how to determine that, then perhaps you should not be doing this. (Ask your teacher?)
 
Top