[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I need a function that will solve me a for quadratic functio
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /adv/ - Advice

Thread replies: 12
Thread images: 1
File: r2h irl.gif (1 MB, 300x184) Image search: [Google]
r2h irl.gif
1 MB, 300x184
I need a function that will solve me a for quadratic function (y=ax^2+bx+c) from three points.

First point is always 0,0
Second point's x can be anything, y will always be 0.
Third point's x is half of second point's x, y will be equal to second point's x.

Example: A(0, 0), B(5, 0), C(2.5, 5)

Giving above values to a calculator I found, linked below, solves the issue. Could anyone write a function for me that solves this?

I believe solving a of the quadratic equation is sufficient. Any help appreciated, I have been struggling to find a solution for a few days, haven't found anyone able to help. Picture not related

http://www.analyzemath.com/parabola/three_points_para_calc.html
>>
Seriously... do your own high school homework. This is very basic stuff, you need to understand this if you want to pass.

You have 3 points. Plug each of them into the quadratic equation. Substitute, reduce, solve. You have (0,0),(x,0),(x/2,x) to plug in as (x,y).
>>
>>17211109
>I have been struggling to find a solution for a few days
kekd
>>
>>17211136
This isn't my homework, I'm not a student. Need this for a programming project.

I am aware solving similar issues is fairly straightforward but is anyone capable of creating a function for this?
>>
>>17211283
if one point is always 0,0 then c always = 0 so the function is reduced to f(x) = a(x^2) + bx

2nd point. 0 = a(x^2) + bx
3rd point. stopped here because your english is bad and i cant be bothered spending 10 minutes trying to understand it to do your homework.

you will have 2 equations with 2 unknowns so solving it is done trivially with simultaneous equations
>>
Sorry for my English, I'll write pseudo code of what I need:

draw(objectX, calculateY(objectX));

function returns double calculateY(float x) {
//Parabola's points:
A: 0, 0
B: x, 0
C: x/2, x
// return variable 'a' of ax^2+bx
}
>>
>>17211364
a should be -4x
>>
Now that I think of it The function should obviously not return a, but y instead. Though I believe solving a is necessary, right?

>>17211369
Still I need a function, not just an answer
>>
>>17211109
Given the constraints you've stated, the function only requires one argument: the second point's X value (x2). The other five "arguments" are either hard-coded as zero (x1, y1, y2) or can be calculated from the second point's x value (x3, y3).

This is a hint.
>>
>>17211391
I'm curious why you believe you only need to solve for a. Obviously c is a constant equal to 0. What happened to b?

Do you think it's simply unimportant to solve for it, or do you believe that b is also a constant, and if so, do you know what that constant is?

I get the feeling that you're just too fucking lazy to do some basic algebra. I mean shit, you already know that you can write all three points in terms of x, how fucking hard is this for you?

And you wrote in the OP that you need a function that will return the a variable for your quadratic equation. No fucking clue what >>17211364 is supposed to mean except that you seem like a terrible programmer.
>>
What I am calculating here is object jumped forward in a shape of parabola. The vertexes are known beforehand, them being 0,0 and the total distance that will be moved forward.

So - I will actually need to give two arguments to the function: Total distance and current distance.

/**
* Calcultes object's current y-coordinate when jumping it forward given distance. At halfway, object's height will peak at total distance
*x - current distance jumped
totalDistance - length from 0 to target x coordinate
return y coordinate at given time
*/
float calculateY(float x, float totalDistance) {
// Three known points:
// (0, 0)
// (totalDistance, 0)
// (totalDistance/2, totalDistance)

// Here, coefficient 'a' should be solved based on totalDistance.
// a: unknown
// b: 2
// c: 0

return a * (pow(x, 2)) + 2 * x;
}
Does that make sense?
>>
>>17211927
Why are you having an object "jump" so that its maximum height is equal to the maximum distance? Is this supposed to be simulating something? What jumps like that?

>b=2
Is that a wild guess or are you just really bad at basic algebra?

Call your total distance "d". So your points are (0,0), (d,0), and (.5d,d)

Now plug that shit into the quadratic equation
y = a(x^2) + b(x) + c
to get three equations with variables a, b, c, and d.

Putting in (0,0) is going to give you that c = 0

The other two equations you can manipulate to solve the constant b, which is not 2.

All you have left are equations with variables a and d. So solve to get a in terms of d.
Thread replies: 12
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.