Jump to content

Desmos/Equation question


Gargamel

Recommended Posts

Math is a science so I guess it’s as good here as anywhere else. 
 

I have a function ( f(x) ) that I need to return a value on, based on a range of input values, as in:
Y | X
0 | 0-99
1 | 100-599
2 | 600-1599
3 | 1600-3099
4 | 3100-5099

Looking to return Y based on X input  

 

How would I write this in Desmos?
Or…
There is a pattern.  The step to each level is 500 more points than the previous step.    And I assume the pattern would continue on for infinity, but anything bigger than this list just isn’t practical. I can’t figure out an equation to represent that, I know it’s fairly simple, but I’m not seeing it. 
 

Edited by Gargamel
Link to comment
Share on other sites

I've never actually heard of Desmos before, so I just pasted your question verbatim into ChatGPT,

1 hour ago, Gargamel said:

I have a function ( f(x) ) that I need to return a value on, based on a range of input values, as in:
Y | X
0 | 0-99
1 | 100-599
2 | 600-1599
3 | 1600-3099
4 | 3100-5099

Looking to return Y based on X input  

 

How would I write this in Desmos?

and here's what it produced:

Quote

In Desmos, you can define a piecewise function to map different ranges of input values to different output values. The syntax for a piecewise function in Desmos is:

f(x) = \begin{cases} y_1 & x \leq x_1 \ y_2 & x_1 < x \leq x_2 \ \vdots \ y_n & x_n < x \end{cases}

To use this syntax for your specific function, you could write:

f(x) = \begin{cases} 0 & x \leq 99 \ 1 & 100 \leq x \leq 599 \ 2 & 600 \leq x \leq 1599 \ 3 & 1600 \leq x \leq 3099 \ 4 & 3100 \leq x \leq 5099 \ \end{cases}

This piecewise function will return the appropriate value of Y based on the input value of X.

I have no knowledge to be able to comment on the correctness or otherwise of this answer. ;)  I merely present what the bot said.

I then asked it a follow-on question,

Quote

There is a pattern. The step to each level is 500 more points than the previous step, which in principle could continue on to infinity. Is there a way to write this in Desmos so that it could return Y values for arbitrarily large values of X?

...and here's what it said:

Quote

Yes, you can use the floor function and integer division to write a formula that returns Y values for arbitrarily large values of X.

Here's an example formula you can use:

f(x) = \left\lfloor \frac{x}{500} \right\rfloor

This formula takes the input value of x, divides it by 500 using integer division (which truncates any decimal values), and then uses the floor function to round down to the nearest integer. This integer represents the number of times x has increased by 500 over the starting value of 0.

For example, if x = 750, the formula calculates:

f(750) = \left\lfloor \frac{750}{500} \right\rfloor = \left\lfloor 1.5 \right\rfloor = 1

So the formula returns a Y value of 1 for this input value of X. Similarly, if x = 1600, the formula calculates:

f(1600) = \left\lfloor \frac{1600}{500} \right\rfloor = \left\lfloor 3.2 \right\rfloor = 3

So the formula returns a Y value of 3 for this input value of X.

This formula will work for any input value of X, no matter how large it is, as long as it is an integer.

 

Link to comment
Share on other sites

Huh.  
 

Well, I welcome our robot overlords then.  
 

 

I had done most of the second part by hand, but only to find out the sequence follows triangular numbers.    I can add -100 modifier before-ish the frac function (That’s a new one for me, but makes total sense, floor/ceilings I’m very comfortable with) and shift some stuff around to get the right output range. 
 

edit:   Wait, the second response is incorrect.    750 should return. Value of 2, not one.  But it’s a good start.     Int(x) is what I’m familiar with. 

Edited by Gargamel
Link to comment
Share on other sites

Desmos.com

its a graphing calculator.  I just need a function that spits out that answer.    Function as in mathematical function, not programming, although it would function as a functioning programming function. 

12 minutes ago, grawl said:

Would you please, @Gargamel, explain a bit the purpose of the Desmos language and the constructions used in the example ?

 

Link to comment
Share on other sites

It's two patterns. I've done this before but can't think of how to do it.

It's first +100. then a second pattern of +500 from the base. And if you aren't adding the 1-99 then it has to be counted as the way to treat 100 as 0-99... (i'm real helpful. 8))(ignore this. Unless there is another way to treat it this way. I think there might be but can't remember.)

Or you treat 100 as 1 and divide/multiply. Then use decimals and convert back...? Although the one 0-9 logic still might be useful. I can't remember what I'm thinking of.

Yea, I'm helping. ;d (This is sarcasm.)

Y = x^y + previous math... I was just doing this in a game.

(This! (5^y)) 5^1+5^0 is 6 Not sure which way you are representing it. 0-ininity or ininity-0. Or is that what you are already working form. Not sure what triangular means... (Or is this what you were already doing?) Isn't there a function for this using an irrational value or something? I think it's the golden ratio. Where something about it devided by something = itself or 1 where it normally doesn't. (ignore me if this is too stupid.)

Combined with the range: Range of units is ((X/2)+0.5)*X for total of iterations. In some circumstances this simplifies things down to straight extra multipliers.

Not sure how to do that fully though. Or translate it in a useful manner.

(y/2+.5)xY

1/2+.5=1x1=1.

2/2+.5=1.5x2=3 (NVM, wrong thing.)

I know you can add 5 in somehow. Might need to do it backwards. I can't think it out.

I was doing it manually, but there is a function for it.

Then again: ((Y/2+.5)xY)-1?

0/2+.5=.5x0=0-1+-1

1/2+.5=1x1=1-1 = 0= Y-1?... That doesn't help does it?! 8D Or would that add or subtract to or from 500 or 5...

2/2+.5=1.5x2=3-1=2=Y

3/2+.5=2x3=6-1=5

OK, I looked it up. That is how you represent triangular logic iterations. But I have no idea if that is how you apply it(although I assume with enough twists and turns you can't avoid applying it.) Or if it's what I'm thinking of fully or helpful.

Edited by Arugela
Link to comment
Share on other sites

18 hours ago, Gargamel said:

Math is a science so I guess it’s as good here as anywhere else. 
 

I have a function ( f(x) ) that I need to return a value on, based on a range of input values, as in:
Y | X
0 | 0-99
1 | 100-599
2 | 600-1599
3 | 1600-3099
4 | 3100-5099

Looking to return Y based on X input  

 

How would I write this in Desmos?
Or…
There is a pattern.  The step to each level is 500 more points than the previous step.    And I assume the pattern would continue on for infinity, but anything bigger than this list just isn’t practical. I can’t figure out an equation to represent that, I know it’s fairly simple, but I’m not seeing it. 
 

Desmos can do piecewise functions with the following format: f(x) = {condition : output, condition : output, condition : output, etc...}

From the description, I believe that this is what you're looking for: https://www.desmos.com/calculator/n0rx0hi3nj

Link to comment
Share on other sites

Just now, Silavite said:

Desmos can do piecewise functions with the following format: f(x) = {condition : output, condition : output, condition : output, etc...}

From the description, I believe that this is what you're looking for: https://www.desmos.com/calculator/n0rx0hi3nj

Yes that was exactly what I’m going with, thank you.    I hadn’t dealt with piecewise functions in maybe 30 years, and so I knew they existed, I just didn’t know enough, even their name, to look them up.   

@Arugela, I had torn apart the pattern enough to find the underlying triangular sequence, but I really don’t know what I want to do with that info.   The issue arises from the fact that even though this pattern extends to infinity, it will be nearly impossible in any practical sense to reach beyond the scope of that simple chart.   
 

Here’s the overall problem:     There’s a stupid mobile game that has some duels, but they’re scoring it like capture points in TF2.   So if I score x points in a single player game, I will receive Y moves towards the opponents base.  If I click a multiplier button, I can gain upto triple the score, and more moves.  But that involves watching an ad.   
 

So I’m trying to identify specific threshold points and zero’s where it is more beneficial to skip the multiplier and just play the next game as fast as possible or try for a higher score, based on the Expected value of the multiplier roll, and the assumed times for the ads and the next game, blended with the odds of scoring at least one move in that next game. 

Link to comment
Share on other sites

Not sure if this helps as I don't play TF2, But the game I'm playing we do 24 hours of points rolling out from PVP matches. It has 14 days of the tournament. You aren't playing book of yog are you?

So, I take (((14/2)+.5)*2)*points(3-7)*iterations(3tripple points match)*3(times a dayfree ticket combined with diamond ticket reduction.)Time(24 hours) to get total point.

(14 days/iterations)=105(triangularvalue)*7*3*3*24 = 158,760 points every two week to buy stuff. For 5400 diamonds.. Only worth it to get a sword real quick.

105x7xx24=17,640 for free. I guess that simplifies down to 9x less. 8)

Or I do the addition version for non simple values.

Points*Iterations*24 Plus next version.

If it's applicable the first formula can quickly get values with simple multipliers like above for total time to compare. But it's still manual.

If you can find the limits of the game you can compare values. Assuming it's relevant. (I'm assuming not.)

How far does the game go? Which game is it? Does it have a wiki showing how the rules work. That might help.

Ok, Maybe I'm thinking it out wrong.

There is something where you multiple the iteration by 5... And there is a base formula. I don't think it's triangular technically... Or is it. I used to do this in another game for something. I can't remember how I did it. You could take the base formula and have a separate value that gave the increase.

You have to add the increase into the iteration. And the plus 1 into it.

I don't know what I'm thinking. I'll break it down more. I'm bored enough. 8) I know I've done this before though.

This is what I was thinking. Not sure if it applies enough. Although there was more to add into the game I was playing. But I can't remember it. Or how to apply past this.

(100+((((Y/2)+0.5)*Y)*500))-1 This gives total point per level. What is needed after that? I'm not sure what is being compared.

I think you can take away 1 from the entire thing to be more accurate. Depending on which way you look at it for max points. Also Y-1 also gives the base points I think.

100+(((((Y-1)/2)+0.5)*(Y-1))*500)= Base point. (100+((((Y/2)+0.5)*Y)*500))-1 = max points.

Except for level 0. Range >0?

Or is this what was already said? I think that is technically X based on input Y though.

Edited by Arugela
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...