Search Results - VBForums

# Search:

Type: Posts; User: jemidiah

Page 1 of 13 1

1. ## Thread: shellsort and selectionsort code help

by jemidiah
Replies
2
Views
464

### Re: shellsort and selectionsort code help

This isn't really a math question. It should be in one of the language-specific forums. There are also a zillion code examples of the zillion and one sorting algorithms out there, though they may not...
2. ## Thread: [RESOLVED] solving equation

by jemidiah
Replies
9
Views
472

### Re: [RESOLVED] solving equation

Minor thing: I noticed a typo in my second graph's equation from post #8. I had written y = −x² + 21x + 11 instead of y = −x² + 21x + 22. This didn't affect the default Wolfram Alpha view of the...
3. ## Thread: [RESOLVED] solving equation

by jemidiah
Replies
9
Views
472

### Re: solving equation

Well, y is 0 at the x-intercepts, since the x-intercepts are on the x-axis, and the x-axis is precisely the line consisting of points whose y-coordinate is 0.

Perhaps this will help? Consider the...
4. ## Thread: [RESOLVED] solving equation

by jemidiah
Replies
9
Views
472

### Re: solving equation

I think I'd have to see the question to know what you're trying to do. You again said you needed to "solve for x", and I've told you how to solve for x in terms of y. If you mean you need to solve...
5. ## Thread: [RESOLVED] solving equation

by jemidiah
Replies
9
Views
472

### Re: solving equation

You wrote an expression, not an equation, so what do you mean by it "seems insoluble without a value for y"?

To take a simpler example, start with y=x^2. Doing the same operation, i.e. saying x^2...
6. ## Thread: [RESOLVED] solving equation

by jemidiah
Replies
9
Views
472

### Re: solving equation

Well, if you want to solve your equation for x in terms of y, you'll have to use the quadratic formula, and there are two "branches" of solutions in general (the function is not invertible in...
7. ## Thread: [RESOLVED] Round-about way to get even distribution using Random functions.

by jemidiah
Replies
4
Views
1,047

### Re: Round-about way to get even distribution using Random functions.

Oh, I agree my solution is easy to implement with a for loop, it's just cleaner and (potentially) faster to use a linked list/queue style data structure, at least if there are often many unused spots...
8. ## Thread: [RESOLVED] Round-about way to get even distribution using Random functions.

by jemidiah
Replies
4
Views
1,047

### Re: Round-about way to get even distribution using Random functions.

Yeah, I'm not a big fan of the two methods you suggested either. The first would make earlier entities *much* more likely to be chosen than later ones, while the second would make the last entity...
9. ## Thread: radius of circumcircle from 3 points formula... can someone explain?

by jemidiah
Replies
8
Views
876

### Re: radius of circumcircle from 3 points formula... can someone explain?

That article is nice and brief, and it gives some notion of what the parts of Heron's formula individually "mean". It does something quite similar to what my proof does, but with the incircle rather...
10. ## Thread: radius of circumcircle from 3 points formula... can someone explain?

by jemidiah
Replies
8
Views
876

### Re: radius of circumcircle from 3 points formula... can someone explain?

@boops boops: for what it's worth, I made an effort to avoid Heron's formula since it seemed like its use just pushes the problem farther down the line--why is Heron's formula true? On the other hand...
11. ## Thread: radius of circumcircle from 3 points formula... can someone explain?

by jemidiah
Replies
8
Views
876

### Re: radius of circumcircle from 3 points formula... can someone explain?

First, here's why the circumcenter exists. Take two sides of a triangle and consider their perpendicular bisectors. Since the sides are not parallel, neither are the perpendicular bisectors, so they...
12. ## Thread: [RESOLVED] drawing random triangle

by jemidiah
Replies
10
Views
834

### Re: drawing random triangle

Just to be clear, my comment about precision was directed at how precisely you wanted to draw "the maximum sized scale triangle within the bounding rectangle [subject to some given angles]", rather...
13. ## Thread: [RESOLVED] drawing random triangle

by jemidiah
Replies
10
Views
834

### Re: drawing random triangle

The complexity of what you want depends a lot on how precise you want it all to be and what you're willing to say is "good enough". For instance, your "acute" case in post #1 allows non-acute...
14. ## Thread: [RESOLVED] Rotating 3d Object by Axis

by jemidiah
Replies
7
Views
1,320

### Re: Rotating 3d Object by Axis

@dday9: cool beans.

Totally understandable, though in this case there was a very easy check besides looking at the original source code. The matrix form of the operation needed to have...
15. ## Thread: [RESOLVED] Rotating 3d Object by Axis

by jemidiah
Replies
7
Views
1,320

### Re: Rotating 3d Object by Axis

I see one big mistake still in #3, namely the "- x" should be "+ x". That would produce extremely erratic results.

I disagree with passel in that I think the integer-based coordinates for your...
16. ## Thread: [RESOLVED] Gaussian Sigma and Pascal's Triangle

by jemidiah
Replies
2
Views
914

### Re: Gaussian Sigma and Pascal's Triangle

You seem to be referring to the fact that the rows of Pascal's triangle, when plotted after normalization, look very much like a normal distribution, especially as you take longer and longer rows....
17. ## Thread: [RESOLVED] Average from percentage?

by jemidiah
Replies
4
Views
518

### Re: [RESOLVED] Average from percentage?

Ah, my mistake. That makes the computation easier. Since 0 < N < 100, we may evidently assume every such sequence terminates, since a non-terminating sequence occurs with 0 probability. Each sequence...
18. ## Thread: [RESOLVED] Average from percentage?

by jemidiah
Replies
4
Views
518

### Re: [RESOLVED] Average from percentage?

Unless I'm really, really misunderstanding your question, it's not (N/100)M times. For instance, at N=100, this gives M, but as you say it should obviously give infinity. As I understand it, you...
19. ## Thread: Maximum Yards Returned

by jemidiah
Replies
8
Views
523

### Re: Maximum Yards Returned

x is a value between 0 and 1 (a float), but you're making it an int. You could also make x use percentages, I suppose.
20. ## Thread: Maximum Yards Returned

by jemidiah
Replies
8
Views
523

### Re: Maximum Yards Returned

You want what's called a "linear interpolation". If p and q are two numbers and x is a parameter between 0 and 1, you can get values in between p and q based on x using the standard formula F(x) =...
21. ## Thread: Three guys rent a room for \$30

by jemidiah
Replies
5
Views
1,083

### Re: Three guys rent a room for \$30

I agree with passel. The guys each have \$-9 at the end, the bellhop has \$2, and the manager has \$25. -9*3 = 27 = 2+25, which makes perfect sense. The "\$1 discrepancy" is just coming from confusing +...
22. ## Thread: [RESOLVED] Expression Evaluator - Parenthesis and Negatives

by jemidiah
Replies
17
Views
1,233

### Re: [RESOLVED] Expression Evaluator - Parenthesis and Negatives

I had a more iterative approach in mind for the lexer. That is, you run through the code character by character adding tokens to a queue as you go. It's fundamentally similar to what you're doing,...
23. ## Thread: [RESOLVED] Expression Evaluator - Parenthesis and Negatives

by jemidiah
Replies
17
Views
1,233

### Re: Expression Evaluator - Parenthesis and Negatives

RPN probably isn't an option here since that would force users to enter unusual syntax.

The shunting-yard algorithm is probably what you're after here. The example and description at the link are...
24. ## Thread: [RESOLVED] Expression Evaluator - Parenthesis and Negatives

by jemidiah
Replies
17
Views
1,233

### Re: Expression Evaluator - Parenthesis and Negatives

I feel I should have a disclaimer at the top of this post. Namely, you probably shouldn't have to write your own parser nowadays and should instead be able to use someone else's; if you do have to...
25. ## Thread: [RESOLVED] reliable decimal to fraction converter

by jemidiah
Replies
9
Views
860

### Re: [RESOLVED] reliable decimal to fraction converter

I don't work in VB anymore, though the Python translation of that code fails on the example I gave earlier, and the VB version should be similar. Specifically, given

def dec2frac(f):
u =...
26. ## Thread: [RESOLVED] reliable decimal to fraction converter

by jemidiah
Replies
9
Views
860

### Re: reliable decimal to fraction converter

The trouble is your code is assuming the decimal representation infinitely repeats. For instance, for 6/5 = 1.2, you're assuming it's really 1.2222222... = 11/9. But it's not, it's 1.200000.... I...

by jemidiah
Replies
3
Views
309

### Re: Logarithmic question

I can't really understand your revised version, sorry. What I know so far: if A (the random number) is > 0.9, compute N = ceil((1+log10(1-A))/log10(0.9)), which is the smallest N such that 0.1*0.9^N...

by jemidiah
Replies
3
Views
309

### Re: Logarithmic question

Say x is the random number. If x < 0.1, you want to know when 0.1*0.9^y = x (essentially); this occurs for y = log_(0.9) (x/0.1) = (1+log10(x))/log10(0.9). For instance, if x = 0.0324, this gives...
29. ## Thread: [RESOLVED] reliable decimal to fraction converter

by jemidiah
Replies
9
Views
860

### Re: reliable decimal to fraction converter

There's a nice StackOverflow post on this topic. Roughly, you want to pick a maximum denominator size and find the numerator-denominator pair which gets closest to your number, subject to the...
30. ## Thread: [RESOLVED] Normalized range

by jemidiah
Replies
8
Views
606

### Re: Normalized range

Sure, there's a lot of ways to tweak it as you wish. Divide (A-B) by a magic constant, replace (A-B) with sign(A-B)*|A-B|^x for some constant x (for x=3 this reduces to just (A-B)^3; for x=2 you need...
31. ## Thread: [RESOLVED] Normalized range

by jemidiah
Replies
8
Views
606

### Re: Normalized range

Glad it worked out. For your revised problem, I would probably have gone for arctan, something like arctan(A-B)*2/pi + 1. It's 1 at A=B, pi/2*2/pi + 1 = 2 at A >> B, and -pi/2*2/pi + 1 = 0 at A << B.
32. ## Thread: Looking for a small random function

by jemidiah
Replies
2
Views
294

### Re: Looking for a small random function

I have trouble understanding the question, eg. I don't really know what the following means: "Then will the second pair still be derived from the first pair. I'm looking for a math function on this,...
33. ## Thread: [RESOLVED] Normalized range

by jemidiah
Replies
8
Views
606

### Re: Normalized range

You put the negative inside the parens when it should be outside, i.e. 2 * EXP(-1*(A-B)^2). For instance, if A=1, B=0, you should get 2/e = 0.735.... Without the negative the function grows very...
34. ## Thread: [RESOLVED] Normalized range

by jemidiah
Replies
8
Views
606

### Re: Normalized range

Your question is a bit vague, but maybe 2exp(-(A-B)^2) is what you're after. It's 2 when A=B and is normally distributed in some sense. If you have more specific requirements, maybe those can be...
35. ## Thread: [RESOLVED] Circular segment height?

by jemidiah
Replies
3
Views
583

### Re: Circular segment height?

Yes, I understood your original post. I'm saying to find v or h requires solving a transcendental equation, which in general will have to be done numerically (or using a special function, though you...
36. ## Thread: [RESOLVED] Circular segment height?

by jemidiah
Replies
3
Views
583

### Re: Circular segment height?

Not sure why you wrote your formula in terms of v (which you didn't quite define) rather than h when you want to solve for h. Either way you have a transcendental equation, which will at best have an...
37. ## Thread: Get x value in relation to horizontal bar

by jemidiah
Replies
2
Views
688

### Re: Get x value in relation to horizontal bar

Yup, you're right. A little more formally, if pValue = min, you'll return 0, and if pValue = max, you'll return 1 * Me.Width, with values in between computed via linear interpolation. Roughly, the...
38. ## Thread: help with a formula to find lengths

by jemidiah
Replies
4
Views
2,092

### Re: help with a formula to find lengths

Your reply confuses me in several ways. (1) I showed you how to find the ADP corner, but you seem to have ignored this. (2) If you could do what I did in my response, why bother asking the question...
39. ## Thread: help with a formula to find lengths

by jemidiah
Replies
4
Views
2,092

### Re: help with a formula to find lengths

I'll assume angles that look like right angles are right angles.

Drop a perpendicular from C to the line AD, and call the point of intersection Y. This line intersects LP at one point, say Q, and...
40. ## Thread: Using a mathematical identity to speed up certain calculations.

by jemidiah
Replies
48
Views
13,175

### Re: Using a mathematical identity to speed up certain calculations.

Since the original topic is likely dead (after having been derailed twice, and having relatively little content to begin with), I'll make a few "meta" comments.

Boy, this was a painful thread to...
Results 1 to 40 of 500
Page 1 of 13 1

Featured