Use Variables to Create Function

  • Context: MHB 
  • Thread starter Thread starter Silva1
  • Start date Start date
  • Tags Tags
    Function Variables
Click For Summary

Discussion Overview

The discussion revolves around creating a mathematical function based on several variables (a, b, m, p, s, x) with specific relational constraints. Participants explore how to express x as a function of these variables, considering various mathematical forms and their implications. The context includes theoretical exploration and practical application within a game engine.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant expresses difficulty in forming a function from defined variables and seeks guidance on the feasibility of their approach.
  • Another participant suggests that the type of function (polynomial, exponential, etc.) may depend on the specific goals of the problem.
  • A participant proposes that as the parameter p increases relative to s, the value of x should increase, with specific conditions for when p and s are equal or at their maximum values.
  • A later reply introduces a quadratic regression formula as a potential solution but notes uncertainty about whether it consistently meets all defined rules.
  • Another participant suggests defining the function in terms of normalized variables P and S, leading to a polynomial expression, but acknowledges that this may impose undesired restrictions on a and b.
  • Concerns are raised about the derived equations not consistently satisfying the condition a ≥ x ≥ b > 0 under certain circumstances, prompting a request for further refinement or alternative solutions.

Areas of Agreement / Disagreement

Participants express differing views on the effectiveness of proposed solutions, with some solutions meeting specific conditions while failing others. There is no consensus on a definitive function that satisfies all constraints under all conditions.

Contextual Notes

Participants note limitations in their solutions, particularly regarding the conditions that must be satisfied for the function to be valid. There are unresolved mathematical steps and dependencies on the definitions of the variables.

Who May Find This Useful

This discussion may be of interest to those involved in mathematical modeling, game development, or anyone exploring the formulation of functions based on variable relationships in a theoretical or applied context.

Silva1
Messages
5
Reaction score
0
Hi everyone.

I'm currently trying to create a function/expression based on several variables. I've so far figured out the rules that the variables should follow but I'm struggling to put them together into a formula. I'm hoping that someone here might tell me if this is even possible, and give me some advice or direct me somewhere specific I can read about my problem (I haven't studied any maths in some time and I don't recall an exact name for what I'm trying to do).

To give my variables names I'll be using: a, b, m, p, s, x
The relations I'd like to have are:

Code:
a ≥ x ≥ b > 0
a ≥ 1 ≥ b > 0
m ≥ s ≥ 0
m ≥ p ≥ 0
when s = p then x = 1
when p = m and s = 0 then x = a
when s = m and p = 0 then x = b

I'd like to show x as a function using these variables.

Thanks in advance for any help. :D
 
Last edited:
Mathematics news on Phys.org
Silva said:
Hi everyone.

I'm currently trying to create a function/expression based on several variables. I've so far figured out the rules that the variables should follow but I'm struggling to put them together into a formula. I'm hoping that someone here might tell me if this is even possible, and give me some advice or direct me somewhere specific I can read about my problem (I haven't studied any maths in some time and I don't recall an exact name for what I'm trying to do).

To give my variables names I'll be using: a, b, m, p, s, x
The relations I'd like to have are:

Code:
a ≥ x ≥ b > 0
a ≥ 1 ≥ b > 0
m ≥ s ≥ 0
m ≥ p ≥ 0
when s = p then x = 1
when p = m and s = 0 then x = a
when s = m and p = 0 then x = b

I'd like to show x as a function using these variables.

Thanks in advance for any help. :D
It might be possible to do it from here but it might be easier if we knew what we were trying to achieve. Would this be some kind of polynomial? An exponential? A sinusoidal? Can you tell us the whole problem?

-Dan
 
Hi Dan, thanks for your response. I'll try my best to explain what I'm doing. I'm extending a game engine to implement a system where the players character has a particular parameter, while other characters have a similar parameter. These parameter influences the effect of a skill/ability.

x will determine the multiplier that's applied to the skill/ability.
a is the maximum the multiplier can be (maximum for x)
b is the minimum the multiplier can be (minimum for x)
s is one of the character's parameter value
p is the other character's parameter value
m is the maximum the parameter value can be
As p increases relative to s, x should increase. If p > s, x > 1. If p < s, x < 1. If p = s, m = 1.

I think an exponential best suits this, rate of change for p-s (I think).
 
I've managed to solve this by creating a new variable, x, and defining it as m+s-p, thank you, Dan, for helping me see that I could do this. I created a quadratic regression formula using the variables to calculate known values, ran them together as simultaneous equations to find an expression for the first "constant", substituted this into one of the original formulas to find an expression for the second constant. I'm not sure it consistently meets all the rules I'd defined but from the tests I've done it seems to be fine.

The end result should anyone be interested:

View attachment 8910
 

Attachments

  • TheSolve.gif
    TheSolve.gif
    1.6 KB · Views: 127
Hi Silva, welcome to MHB!

Let's define $P=\frac p m$ and $S=\frac s m$ to simplify the relations.
And let's call our function $x(P,S)$.
Then we have:
\begin{cases}x(1,0)=a\\ x(0,1)=b\\ x(q,q)=1&\text{for any }q
\end{cases}

The simplest relation would be a linear relation in $P$ and $S$, but we can see that it won't work, since it will put a restriction on $a$ and $b$ that is undesired.

Let's try a polynomial of degree 2:
$$x(P,S)=AP^2+BS^2+CPS +DP+ES+F$$
Then we have:
$$\begin{cases}x(1,0)=A+D+F=a\\
x(0,1)=B+E+F=b\\
x(q,q)=(A+B+C)q^2+(D+E)q+F=1
\end{cases}\implies
\begin{cases}A+D+F=a\\
B+E+F=b\\
A+B+C=0\\
D+E=0\\
F=1
\end{cases}$$
If we pick $D=E=0$, we get:
$$
\begin{cases}A=a-1\\
B=b-1\\
C=2-a-b\\
D=E=0\\
F=1
\end{cases}\implies
x(P,S)=(a-1)P^2+(b-1)S^2+(2-a-b)PS+1
$$

So we can use:
$$x(p,s)=(a-1)\left(\frac pm\right)^2+(b-1)\left(\frac sm\right)^2+(2-a-b)\frac{ps}{m^2}+1$$

EDIT: I was writing this before I saw you posted again.
 
Silva said:
I've managed to solve this by creating a new variable, x, and defining it as m+s-p, thank you, Dan, for helping me see that I could do this.
Ummmm... You're welcome? I'm glad you got it, but I doubt I did any thing. (Yes)

-Dan
 
Hi Klaas van Aarsen, glad to be here.

Thanks for finding a solution for this. I've tested your solution and it's not quite functioning as I'd intended (nor is mine after testing that further). It works correctly when s = p, when s = 0 and p = m, when p = 0 and s = m. The issue I have with both mine and your solution is that when s = m and p is slightly more than 0 then the result doesn't always meet this condition:

a ≥ x ≥ b > 0

As x < b. Using your equation this condition is only satisfied when:

1 - b ≥ a - 1
so, a = 1.7, b = 0.3 is okay but a = 1.8, b = 0.3 is not.

Similarly for my equation this condition is only satisfied when:

(1 - b) * 3 ≥ a - 1

Can you think of any way we can solve so that the condition a ≥ x ≥ b ≥ 0 is always met, or is this not possible?

Dan, had you not asked what kind of equation I wanted I wouldn't have known what my options were for solving it. Credit where credit's due. :)
 

Similar threads

  • · Replies 0 ·
Replies
0
Views
620
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K