#### Archived

This topic is now archived and is closed to further replies.

# Cubic Formula

This topic is 5939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m trying to write a function which will look up a value on a certain type of curve, for use in camera movement and whatnot. The curve is cubic, and negative (moves down towards x-positive). It has a minimum, at the origin (0,0), and a maximum at the point (t, A). At both of those points the gradient is zero. I know that the equation for a cubic curve is in the form y = ax^3 + bx^2 + cx + d but I can''t figure out how to calculate a, b, c, and d, when given t and A. I''ve tried differentiating: dy/dx = 3ax^2 + 2bx + c and because dy/dx = 0 when x = 0, I believe c must = 0. But that''s as far as I can get. Can anyone help? Superpig - saving pigs from untimely fates - sleeps in a ham-mock at www.thebinaryrefinery.cjb.net

##### Share on other sites
You are on the right path. Just write all the conditions.
P(x) := ax^3 + bx^2 + cx + d
P''(x) = 3ax^2 + 2bx + c

P(0) = 0 => d = 0
P''(0) = 0 => c = 0

P(t) = A => at^3 + bt^2 = A
P''(t) = 0 => 3at^2 + 2bt = 0

From the last two, you solve the 2-variables 2-equations system. I think the result is a = 2A/t^3, b = -3A/t^2, but check it yourself.

##### Share on other sites
quote:
Original post by alvaro
You are on the right path. Just write all the conditions.
P(x) := ax^3 + bx^2 + cx + d
P''(x) = 3ax^2 + 2bx + c

P(0) = 0 => d = 0
P''(0) = 0 => c = 0

P(t) = A => at^3 + bt^2 = A
P''(t) = 0 => 3at^2 + 2bt = 0

correct...
quote:

From the last two, you solve the 2-variables 2-equations system. I think the result is a = 2A/t^3, b = -3A/t^2, but check it yourself.

I''ve the opposite, a = -2A/t³ and b = 3A/t². Surely a small oversight on your side.
By the way, this result can also be prooved because A and t are > 0, and a must be < 0. So a negative value is necessary.

##### Share on other sites
misterX is right. I probably forgot a ''-'' somewhere in my notes.

##### Share on other sites
You are both wonderful, wonderful people, and I will love you eternally. This has been bothering me for two days.

Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net

1. 1
2. 2
Rutin
18
3. 3
khawk
15
4. 4
A4L
14
5. 5

• 10
• 13
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633745
• Total Posts
3013667
×