Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.8K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Function fit / equation solving for given values

Posted 10 years ago

Hello all,

I'm brand new to Wolfram, so I thank you in advance for your patience. I am helping to document a game and would like to use Wolfram to help generate some values based on functions used in the game. Here's the type of problem that I'm looking to solve:

Solve: y(x) = m * (x + shift)^power + b + add, for m and b

Where: y(in1) = out1, y(in2) = out2

And: shift, power, add are givens

For example: Given shift = 0, add = 0, power = 0.5, y(1) = 5, y(5) = 10

Result is: m = 4.045, b = 0.955 -> y(x) = 4.045 * x^0.5 + 0.955

Thank you in advance! -J. Thomas

POSTED BY: Joshua Thomas

One way is this:

power = 1/2; shift = 0; add = 0;
genericEquation = (y == m (x + shift)^power + b + add)
instances = equation /. {{x -> 1, y -> 5}, {x -> 5, y -> 10}}
solutions = NSolve[instances]
finalEquation = genericEquation /. First[solutions]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard