473,322 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Any math wizards out there (VB.NET)???

Hello;

I am working in VB.NET and am trying to come up with an equation. I think
my math skills have degraded due to lack of use!

Here is my problem.

I have, say Z amount of credits to assign a user. Lets say Z = 500 credits.

I want to assign those credits over a span of, say, 10 days.

I would like the number of daily credits assigned to represent a sine
function, where the first day Joe would get a large number of credits, fewer
the second day, even fewer the third until on the 10th day the credit amount
is zero. I could represent this as X = Y(2), however that is too linear for
what I am looking to accomplish.

What I have tried to do is create 1/4 of a circle. The circumference of
this segment is Z, or 500 in this case. This is as far as I get. Knowing
X - say day 2, how can I determine my credit amount to assign?

Hopefully this makes sense, I have been beating my head off my desk for some
time over this and I may have shaken something loose!

Brad

Jul 21 '05 #1
4 1464
Hey Brad,

Here's one idea. It takes a quadratic function that uses the square of the
number of days to reduce the amount of the credit. So day 1, the effect is
only reducing by 1, but by day 4, it's reducing by 16.

int intTotalWeight = 615; // sum of 100 - days squared over the 10 day
range
int[] aintDailyCredits = new int[9];
for (int intCntr = 0; intCntr < 10; intCntr++)
{
aintDailyCredits[intCntr] = (100 - intCntr^2) / intTotalWeight
}

It leaves you with an array of multipliers indicating16.1% percent to be
given out on day 1, 15.6% on day 2, 14.8% on day 3...

HTH,

John

"Brad Brening" <Br*********@gmail.com> wrote in message
news:eC**************@tk2msftngp13.phx.gbl...
Hello;

I am working in VB.NET and am trying to come up with an equation. I think
my math skills have degraded due to lack of use!

Here is my problem.

I have, say Z amount of credits to assign a user. Lets say Z = 500 credits.
I want to assign those credits over a span of, say, 10 days.

I would like the number of daily credits assigned to represent a sine
function, where the first day Joe would get a large number of credits, fewer the second day, even fewer the third until on the 10th day the credit amount is zero. I could represent this as X = Y(2), however that is too linear for what I am looking to accomplish.

What I have tried to do is create 1/4 of a circle. The circumference of
this segment is Z, or 500 in this case. This is as far as I get. Knowing
X - say day 2, how can I determine my credit amount to assign?

Hopefully this makes sense, I have been beating my head off my desk for some time over this and I may have shaken something loose!

Brad

Jul 21 '05 #2
Thanks John! That helped a bunch! I was taking the wrong approach - your
solution is great.

Brad
"John Spiegel" <js******@YETANOTHERSPAMHATERc-comld.com> wrote in message
news:Ow****************@TK2MSFTNGP10.phx.gbl...
Hey Brad,

Here's one idea. It takes a quadratic function that uses the square of the number of days to reduce the amount of the credit. So day 1, the effect is only reducing by 1, but by day 4, it's reducing by 16.

int intTotalWeight = 615; // sum of 100 - days squared over the 10 day range
int[] aintDailyCredits = new int[9];
for (int intCntr = 0; intCntr < 10; intCntr++)
{
aintDailyCredits[intCntr] = (100 - intCntr^2) / intTotalWeight
}

It leaves you with an array of multipliers indicating16.1% percent to be
given out on day 1, 15.6% on day 2, 14.8% on day 3...

HTH,

John

"Brad Brening" <Br*********@gmail.com> wrote in message
news:eC**************@tk2msftngp13.phx.gbl...
Hello;

I am working in VB.NET and am trying to come up with an equation. I think my math skills have degraded due to lack of use!

Here is my problem.

I have, say Z amount of credits to assign a user. Lets say Z = 500

credits.

I want to assign those credits over a span of, say, 10 days.

I would like the number of daily credits assigned to represent a sine
function, where the first day Joe would get a large number of credits,

fewer
the second day, even fewer the third until on the 10th day the credit

amount
is zero. I could represent this as X = Y(2), however that is too linear

for
what I am looking to accomplish.

What I have tried to do is create 1/4 of a circle. The circumference of
this segment is Z, or 500 in this case. This is as far as I get. Knowing X - say day 2, how can I determine my credit amount to assign?

Hopefully this makes sense, I have been beating my head off my desk for

some
time over this and I may have shaken something loose!

Brad


Jul 21 '05 #3
Hi Brad,

An easy way to do this would be to use the exponential equation

y = p / 2^ x --> (y equals p on 2 to the x
power)

where

p = principal amount
x = the day you want the amount for
y = the amount to be paid

this can be achieved using the following code snippet

//C#

public double calculateDailyCredit(int day, float principal)
{
double returnCredit ;
double denom ;

denom = Math.Pow(2, day) ;
returnCredit = (principal / denom) ;

return returnCredit ;
}

//VISUAL BASIC
Public Function CalculateDailyCredit(ByVal Day as Integer, BYVal Principal
as Double)

Dim ReturnCredit as Double
Dim Denominator as Double

Denominator = Math.Pow(2,day)
ReturnCredit = (Principal / Denominator)

Return ReturnCredit
End Function

Note that this is not quite complete - as for the second final day to make
the balance = 0 you need to pay out any remaining as this function will never
actually touch the X axis on a graph.

Hope this helps,
Steve.
"Brad Brening" wrote:
Hello;

I am working in VB.NET and am trying to come up with an equation. I think
my math skills have degraded due to lack of use!

Here is my problem.

I have, say Z amount of credits to assign a user. Lets say Z = 500 credits.

I want to assign those credits over a span of, say, 10 days.

I would like the number of daily credits assigned to represent a sine
function, where the first day Joe would get a large number of credits, fewer
the second day, even fewer the third until on the 10th day the credit amount
is zero. I could represent this as X = Y(2), however that is too linear for
what I am looking to accomplish.

What I have tried to do is create 1/4 of a circle. The circumference of
this segment is Z, or 500 in this case. This is as far as I get. Knowing
X - say day 2, how can I determine my credit amount to assign?

Hopefully this makes sense, I have been beating my head off my desk for some
time over this and I may have shaken something loose!

Brad

Jul 21 '05 #4
Best thing for you to do is use the function of a circle. Using the x axis
as your number of days, and y axis as the credit, the amount of credit (y
axis) would reduce progressively for every increase int the value of the
day(x axis).
Just in case you didn't know, the equation of a circle is (x - a)^2 + (y -
b)^2 = r^2, where the co-ordinates (a, b) represent the center of the circle,
and r represents the radius of the circle. The radius of the circle should
correspond to the total number of days for which the credit is supposed to
last plus 1 day(in your case, 11). That way, on the day after the last day,
the credit is zero. Good luck with your program and please email me a copy
of your source code when you're done, that is of course, if it's not a
commercial product. I'd like to see what you were trying to
code.(wa****@mindless.com) Good luck.

"Brad Brening" wrote:
Hello;

I am working in VB.NET and am trying to come up with an equation. I think
my math skills have degraded due to lack of use!

Here is my problem.

I have, say Z amount of credits to assign a user. Lets say Z = 500 credits.

I want to assign those credits over a span of, say, 10 days.

I would like the number of daily credits assigned to represent a sine
function, where the first day Joe would get a large number of credits, fewer
the second day, even fewer the third until on the 10th day the credit amount
is zero. I could represent this as X = Y(2), however that is too linear for
what I am looking to accomplish.

What I have tried to do is create 1/4 of a circle. The circumference of
this segment is Z, or 500 in this case. This is as far as I get. Knowing
X - say day 2, how can I determine my credit amount to assign?

Hopefully this makes sense, I have been beating my head off my desk for some
time over this and I may have shaken something loose!

Brad

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sehri | last post by:
Hi all, I have just started developing a math companion tool with VS2005 and I just ran into a problem when trying to add the description of a formula. Doed anyone know how can I add math...
2
by: Squeeze | last post by:
Hi there, We're in the process of converting our .NET 2002 apps into 2005 and have run into a security issue. We are trying to attach to an assembly using a UNC path. We sorted the issue out...
17
by: kiplring | last post by:
float sum = (float)Math.Sqrt( floatA*floatA + floatB*floatB); I'm using DirectX with c#. But the Math class in .net framework has a problem. It is "double" base! So I'm doing type casting...
6
by: Mitchell Vincent | last post by:
Just making sure I'm not missing the boat here, but are there any special routines for doing currency math (fixed precision stuff) in .NET? The wonderful problems of doing math on decimals tend...
4
by: Brad Brening | last post by:
Hello; I am working in VB.NET and am trying to come up with an equation. I think my math skills have degraded due to lack of use! Here is my problem. I have, say Z amount of credits to...
5
by: Milton | last post by:
I am having trouble in finding the propoer way to find the Inverse Log of a number in VB.Net Express edition. Can anyone tell me how it is done. Thanks!
7
by: shaun roe | last post by:
Hi, I am using an XSLT to generate an SVG client-side in Firefox. The user opens an XML file in Firefox and sees a display. In doing so, I have to convert from cartesian to polar coordinates, so...
1
by: merarajesh | last post by:
hi, I am developing intensity of wave in physics. I am using system.math in c#. every thing is fine. but the result of Intensity is not well. my formula is:- I=4*a2*cos2(delta/2);...
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi, I have a C++ unmanaged application that controls a MODEM using the Remote Access Service (RAS) APIs to manipulate PhoneBook entires and control the dial-up connection. I would like to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.