math

What are some useful examples of extension methods dealing with mathematics and calculations?

My very often used extension method is public static double Pi(double this x) { return Math.PI*x; } in order to have access to 2.0.Pi() or 0.5.Pi() .. etc What are some other examples of mathematics related extension methods the people use often? PS. Just curious. ...

Backwards Calculation of variable

Given a level starts at 1 And the points to the next level is calculated as (C2 = Level) (C2*100)+((C2-1)*100) What is the formula to get the current level if I supply the points e.g. 810 Points = Level ? I need the formula in C# or Excel. Brain frazzled, I am sure the answer is easy. ...

Reordering python list based on an algorithm or pattern

Here is a stumper for you math geeks out there. I have a python list that is just a sequence that looks like this: myList=[1,2,3,4,5,6,7,8,9,10,11,12,13,(...etc...),43] Unfortunately, the data from which the list was generated was not zero-padded, and it should have been. So in reality: 1==1 2==10 3==11 4==12 5==13 6==14 7==15 8=...

Generating and then using a taylor polynomial in C#

I've written a simple graphing implementation in C#, and I can graph things by comparing each pixel to the position on the graph it represents and plugging that position into the function I have to see if it is on the curve. That's all well and good. The problem I'm having is USING a generated taylor polynomial. For example, I am able t...

To Compute log(a+b)

I want the complete expansion of log(a+b)=? for ex log(a*b)=log a + log b; log(a/b)=lob a - log b; Similar to this, is there any expansion for log(a+b)??? Thanks in advance... ...

C# XNA Ball Moving

I have the ball in the very right bottom side. When I click somewhere, I want to be able to figure out the direction I clicked and once the user starts to drag, I will calculate the distance. Once the user lets go of the mouse, I want to give the ball some velocity and have it move towards the direction it was first clicked. I don't kn...

Plotting evolution of 2D vector in 3D as a ribbon in MATLAB

I would like to plot how the amplitude and orientation of a 2D vector evolves over time. To do this I would like to create a graph reminiscent of the canonical E & B field graphs you may recall from an introductory electricity and magnetism class. Specifically, I would like to connect my 2D vector points with a ribbon, so that they ...

Assistance with Lua Cosine, wrong results returned

Ok, first up, this is NOT for a class, test, or other student type activity. I'm a scripter for a game, and am trying to implement the math library for all to use, and unfortunately, all I have available to me is very basic lua. The implemented version cannot be changed, and does not include any libraries. For those wondering, its for ...

Difference of sums

I take no credit for this challenge at all. It's Project Euler problem 6: The sum of the squares of the first ten natural numbers is, 1^(2) + 2^(2) + ... + 10^(2) = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^(2) = 55^(2) = 3025 Hence the difference between the sum of the squares of the first ten ...

How to represent a 4x4 matrix rotation?

Given the following definitions for x,y,z rotation matrices, how do I represent this as one complete matrix? Simply multiply x, y, & matrices? X Rotation: [1 0 0 0] [0 cos(-X Angle) -sin(-X Angle) 0] [0 sin(-X Angle) cos(-X Angle) 0] [0 0 0 1] Y Rotation: [cos(-Y Angle) 0 sin(-Y Angle) 0] [0 1 0 0] [-sin(-Y Angle) 0 cos(-Y Ang...

probability in javascript help?

Sorry, I'm new to JS and can't seem to figure this out: how would I do probability? I have absolutely no idea, but I'd like to do something: out of 100% chance, maybe 0.7% chance to execute function e(); and 30% chance to execute function d(); and so on - they will add up to 100% exactly with a different function for each, but I haven't...

Power Set and Union

Following set is given: X := {Horse, Dog} Y := {Cat} I define the set: M := Pow(X) u {Y} u for union The resulting set of the power set operation is: Px := {0, {Horse}, {Dog}, {Horse, Dog}} 0 for empty set My question is referenced to the unio operation. How do I unite 0 and Y? M := {{Horse, Cat}, {Dog, Cat}, {Horse, Dog, Ca...

Casting float inf to integer

What do you get in C from casting float +INF,-INF,NAN to integer? Does any standard specifies what should be the output? For example this code: #include <stdio.h> #include <math.h> int main(int argc, char** argv) { float a = INFINITY; float b = -INFINITY; float c = NAN; printf("float %f %f %f\n", a, b, c); printf("int %d %...

how to round to higher 10's place in python

Hi, I have a bunch of floats and I want to round them up to the next highest multiple of 10. For example: 10.2 should be 20 10.0 should be 10 16.7 should be 20 94.9 should be 100 I only need it to go from the range 0-100. I tried math.ceil() but that only rounds up to the nearest integer. Thanks in advance. ...

Help me with my backprop implementation in Python

EDIT2: New training set... Inputs: [ [0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0], [0.0, 4.0], [1.0, 0.0], [1.0, 1.0], [1.0, 2.0], [1.0, 3.0], [1.0, 4.0], [2.0, 0.0], [2.0, 1.0], [2.0, 2.0], [2.0, 3.0], [2.0, 4.0], [3.0, 0.0], [3.0, 1.0], [3.0, 2.0], [3.0, 3.0], [3.0, 4.0], [4.0, 0.0], [4.0,...

Find out which combinations of numbers in a set add up to a given total

I've been tasked with helping some accountants solve a common problem they have - given a list of transactions and a total deposit, which transactions are part of the deposit? For example, say I have this list of numbers: 1.00 2.50 3.75 8.00 And I know that my total deposit is 10.50, I can easily see that it's made up of the 8.00 and ...

Testing divisibility of Ints by 11

I'm struggling with this code right now. I want to determine whether an integer is divsible by 11. From what I have read, an integer is divisible to 11 when the sum (one time +, one time -) of its digits is divisible by 11. For example: 56518 is divisible by 11, because 8-1+5-6+5 = 11, and 11 is divisible by 11. How can i write this ...

Display word count / tag cloud in proportion

This is weird, so be patient while I try to explain. Basic problem: I have a massive string -- it can be of varying lengths depending on the user. My job is to acquire this massive string depending on the user, then send it off to the other piece of software to make a tag cloud. If life were easy for me, I could simply send the whole t...

Converting a formula into PHP

Hi there, I'm trying to convert this adaptive bayesian rating formula into PHP code.. http://cl.ly/cabd3372e2860b52e3db Here are the details of the various parts of the formula.. nvotes : total number of votes so far nlinks : total number of links nvotes(k) : number of votes cast to rth link. deltarank(k, m) : rank increment caused b...

Simple math library for the web

I'm looking for a math JavaScript API to show formulas on a web site and allow users to input formulas too (for instance, using a <textarea/>). The API should be able to parse text strings, such as 3x^2+2 or sqrt(x/(x+5)) building "automagically" fractional layouts, integral symbols and so on. Thanks. ...