My Math Forum  

Go Back   My Math Forum > High School Math Forum > Algebra

Algebra Pre-Algebra and Basic Algebra Math Forum


Reply
 
LinkBack Thread Tools Display Modes
May 20th, 2008, 12:36 AM   #1
Newbie
 
Joined: May 2008

Posts: 10
Thanks: 0

equation needed

hi, i am a programmer and an equation has stop proceeding my code, i dont know what to call this equation but i will represent it here with an example :

consider i gave u the following parameters :
maximum number : 37
block size : 10
sample values : 13, 24, 32

now, i want to put each sample value between a lower and an upper bound values where the condition is the lower/upper boundaries should be related to the block size, so in our case it will be :
13 : lower is 10 and upper is 20.
24 : lower is 20 and upper is 30
32 : lower is 30 and upper is 40

now the equations i want is to calculate the lower/upper bounds, lets call them LB and UB, so we can calculate them as follows :
LB = (Floor(sample value / block size) * block size)
UB = (Ceil(sample value / block size) * block size)

now where is my problem with these equations?? it is when we want to set a maximum number which is in our case is 37, what i want with this number is to be the upper bound for the values that come between 30 to 37 so the bounds should be like :
13 : lower is 10 and upper is 20.
24 : lower is 20 and upper is 30
32 : lower is 30 and upper is 37 (not 40 as the maximum is 37)

so LB equation it seems it neednt to be modified but the UB needs to bcuz it should manage the maximum number case, i hope u understood my case and if more info needed then plz ask me so, thnx anyway .
akkad is offline  
 
May 20th, 2008, 04:43 AM   #2
Global Moderator
 
CRGreathouse's Avatar
 
Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 933

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Min(37, X) where X is the upper bound above.
CRGreathouse is offline  
May 20th, 2008, 05:08 AM   #3
Newbie
 
Joined: May 2008

Posts: 10
Thanks: 0

so how to represent min in math ??
akkad is offline  
May 20th, 2008, 05:27 AM   #4
Global Moderator
 
CRGreathouse's Avatar
 
Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 933

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Quote:
Originally Posted by akkad
so how to represent min in math ??
I guess that depends on what you mean by "in math".

If I was in a math classroom and needed the max function for something, I'd write just what I did: "min".

If I was asked to construct the min functions from basic functions, I would define it as such:

min(a, b) := (|a + b| - |a - b|) / 2

If I couldn't use the absolute value bars, I could write

min(a, b) := (sqrt((a + b)^2) - sqrt((a - b)^2)) / 2

If I was programming in C#:

Math.Min(a, b)

In JavaScript:

Math.min(a, b)

In Forth:

a b min

In C++ (STL):

#include <algorithm>
. . .
min(a, b)

etc.
CRGreathouse is offline  
May 20th, 2008, 05:55 AM   #5
Newbie
 
Joined: May 2008

Posts: 10
Thanks: 0

u r a real joker , thnx anyway ....
akkad is offline  
May 20th, 2008, 07:26 AM   #6
Global Moderator
 
CRGreathouse's Avatar
 
Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 933

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Did you need something else?
CRGreathouse is offline  
May 20th, 2008, 07:27 AM   #7
Newbie
 
Joined: May 2008

Posts: 10
Thanks: 0

nope, but sure i'll get back to u with more equations .
akkad is offline  
May 20th, 2008, 07:38 AM   #8
Global Moderator
 
Joined: Dec 2006

Posts: 17,919
Thanks: 1383

In pseudocode (adapt for whatever language you are using), having first calculated UB as described originally,

if (UB > maximum number)
* *{UB := maximum number}

Of course, you might also wish to detect awkard possibilities, such as LB being greater than maximum number as well.
skipjack is offline  
Reply

  My Math Forum > High School Math Forum > Algebra

Tags
equation, needed



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forgot how to solve an equation needed for a logistic model petkiri Applied Math 2 January 31st, 2012 08:41 PM
A formula needed from an equation soorajth Applied Math 8 April 15th, 2009 04:54 AM
Equation Needed web wheeler Calculus 5 October 21st, 2008 10:22 AM
HELP needed with quadratic equation wild_child Algebra 1 June 20th, 2008 09:32 AM
HELP needed with quadratic equation wild_child Abstract Algebra 1 December 31st, 1969 04:00 PM





Copyright © 2017 My Math Forum. All rights reserved.