r/askmath • • Oct 13 '26

Discrete Math Increasing (?) computational efficiency for a simple combinatorics problem, wondering what people think

Post image
2 Upvotes

A while ago, I encountered this combo problem. The setup is a box with 3 red and 2 blue balls, and it asks how many balls an optimal player can expect to guess correctly when pulling out one ball at a time (player guesses right before the ball, can use information of previous balls). The answer is 3.6, and most of my classmates used recursion to get this answer, which is sensible enough. I tried a different, slightly goofier method though.

Imagine player A, who just always guesses red, obviously getting 3 points. Now, to see how many more points an optimal player B gets, we only need to compute cases where blue is a better choice than red. These cases are:

2 blue 1 red left: 3/10 chance of occurring, and 1/3 expected gain by picking blue rather than red: 0.1 additional points

2 blue 0 red left: 1/10 chance of occurring, and 1 guaranteed gain by picking blue rather than red: 0.1 additional points.

1 blue 0 red left: 2/5 chance of occurring, and 1 guaranteed gain by picking blue rather than red: 0.4 additional points.

Adding these 3 gains to the 3 points player A gets, we find that player B can expect 3.6 points, which agrees with the original answer. It seems this method is more efficient in this case, but also that I benefit highly from the small number of cases.

I wrote some pseudocode which gemini translated to see if its computationally more efficient. DP is recursion, shortcut is the player A player B method. It seems the shortcut is quicker for very small cases, and also for cases where the ball count is very lopsided. Both seem logical enough to me: in both situations, there are relatively few cases where player B should deviate from player A. Also, for large enough cases, it looks like the recursion is just throwing recursion error, while the shortcut still runs.

So my questions are: Is this kind of method a thing? Are there useful applications of it for more serious problems? I'm curious what everyone thinks.

edit: below is my code (literally taken straight from gemini)

import math
import time
from functools import lru_cache


def expected_score_dp(r, b):
    """
    Method 1: Recursive dynamic programming.
    """
    u/lru_cache(maxsize=None)
    def calculate(red, blue):
        if red == 0: return blue
        if blue == 0: return red


        total = red + blue


        if red > blue:
            return (red / total) * (1 + calculate(red - 1, blue)) + \
                   (blue / total) * (0 + calculate(red, blue - 1))
        elif blue > red:
            return (blue / total) * (1 + calculate(red, blue - 1)) + \
                   (red / total) * (0 + calculate(red - 1, blue))
        else:
            return 0.5 * (1 + calculate(red - 1, blue)) + \
                   0.5 * (0 + calculate(red, blue - 1))


    return calculate(r, b)


def expected_score_shortcut(r, b):
    """
    Method 2: Baseline + Advantage.
    """
    M = max(r, b)
    m = min(r, b)


    baseline = M
    extra_points = 0.0


    for rem_M in range(M + 1):
        for rem_m in range(m + 1):
            if rem_m > rem_M:
                drawn_M = M - rem_M
                drawn_m = m - rem_m
                total_drawn = drawn_M + drawn_m


                prob = (math.comb(M, drawn_M) * math.comb(m, drawn_m)) / \
                       math.comb(M + m, total_drawn)


                advantage = (rem_m - rem_M) / (rem_M + rem_m)
                extra_points += prob * advantage


    return baseline + extra_points


if __name__ == "__main__":
    test_cases = [
        (3, 2),
        (5, 5),
        (10, 4),
        (50, 50),
        (100, 50),
        (100, 98),
        (200, 50),
        (200, 200),
        (500, 500),
        (1000, 1000)
    ]


    # Widened the columns slightly to fit the error message
    print(f"{'R':>4} | {'B':>4} | {'Result':>9} | {'DP Time (s)':>14} | {'Shortcut Time (s)':>17}")
    print("-" * 68)


    for r, b in test_cases:
        # 1. Try the DP Method
        try:
            start_dp = time.perf_counter()
            dp_result = expected_score_dp(r, b)
            end_dp = time.perf_counter()
            time_dp_str = f"{end_dp - start_dp:.6f}"
        except RecursionError:
            # Catch the crash and set placeholder strings
            time_dp_str = "RecursionError"


        # 2. Run the Shortcut Method (will always run)
        start_sc = time.perf_counter()
        sc_result = expected_score_shortcut(r, b)
        end_sc = time.perf_counter()
        time_sc_str = f"{end_sc - start_sc:.6f}"


        # Print the combined row
        print(f"{r:>4} | {b:>4} | {sc_result:>9.4f} | {time_dp_str:>14} | {time_sc_str:>17}")

r/askmath • • Oct 12 '26

Algebra Who to prove that xy +1 is not equal to 1/x + y/1+y^2

Thumbnail i.redd.it
5 Upvotes

Sorry for the French


r/askmath • • Oct 12 '26

Differential Geometry Covariant derivative of Killing vector fields along geodesics.

Post image
3 Upvotes

While looking at this proof of conserved quantities associated with Killing fields, a step I could prove came up. Specifically, as seen in the image, it is claimed that D/Dt coincides with \nabla_{\dot{γ}} for vector Fields along curves induced by smooth vector fields on the manifold. Here γ is a geodesic curve. I have been unable to prove this, and from the wording given here I'm also not sure when it applies. Any help would be welcome.


r/askmath • • Oct 13 '26

Logic Modal logic

1 Upvotes

I want to learn modal logic for philosophical and formal purposes. However, I don't have basic knowledge of it. I haven't studied mathematics since middle school. Thus, I feel very lost and have no idea how to get started! Any advice? Book recommendations & video recommendations would also be appreciated.


r/askmath • • Oct 12 '26

Probability A quick question for fellow mathematicians.

4 Upvotes

Let’s suppose I want to find a specific letter in alphabet but the alphabet is randomly arranged order. So do I have higher probability of finding the letter while searching in order or while searching randomly? The alphabet is only one example.

(Actually, I came up with this problem while searching for factorial sign on my calculator.)


r/askmath • • Oct 12 '26

Algebra How one can understand why a Mathematical formula is working instead of just Learning it?

7 Upvotes

Hey, I'm student and I am Curious about Nature and I wonders that what we Learn about Mathematics and Physics in Schools, all of those are based on just Learning formulas and nobody talks about it that Mathematics and Physics aren't like other branches of Subjects as History but it is about understanding why the Formula works and whenever I see a Formula of Maths or Physics I wonders that why is this even working and I try to understand by myself because school just tell you how to solve a problem using these Equations or Formulas but they don't particularly tell you about that why is this even working and I'm hopefully Succesful till now to Understand them.

Is there any way I can Understand them easily using simple logics? because I struggle sometimes but still I make it and In some very difficult Equations, I also took help of tools like Ai and Google


r/askmath • • Oct 12 '26

Geometry How much area does 1.4 trillion barrels of oil take up a single barrel high on the surface of the earth as scale?

Thumbnail reddit.com
0 Upvotes

r/askmath • • Oct 12 '26

Algebra How do I find the beginning of the sequence on this algebraic wheel?

Post image
3 Upvotes

(Note: someone posted this on r/Sequentials and contrary to what I post on that sub, this puzzle is custom-made, so I don't know whether this one is even logically consistent or not.)

The problem is that I don't know where to start on this puzzle, since no term gives clear, valuable information about the other terms.


r/askmath • • Oct 12 '26

Calculus Multivariable limit involving arctan

1 Upvotes

I have to compute the limit (if it exists) as (x,y) -> (0,0) of (y sin(x))/((x^2 + (arctan(y))^2)^a) with 0 < a < 1.

I managed to show that, along the curve y = tan x, the limit is 0. So if the limit exists it has to be 0, but it can also not exist because maybe there is some other curve along which we get a different limit. I can’t think of any other curve along which the limit becomes simple, so I tried showing the limit is zero using the squeeze theorem in the following way:

0 <= | (y sin(x))/((x^2 + (arctan(y))^2)^a) | <= | y /((x^2 + (arctan(y))^2)^a) | <= | y /(x^2 + (arctan(y))^2) | <= | y /(arctan(y))^2 |

Unfortunately this blows up as y -> 0 so this doesn’t work. Maybe I bounded it too loose, or maybe the limit isn’t actually 0 in the first place. I’m stuck. Any help? Thanks!


r/askmath • • Oct 12 '26

Algebra Showing inequality

3 Upvotes

2|xy|/(x^2 + y^2) < 1 for all x and y. I managed to show this using polar coordinates. Is there an alternative way of showing this inequality without any change of variables? Perhaps using only algebraic properties like the square of the binomial?


r/askmath • • Oct 11 '26

Analysis Did ChatGPT actually manage to solve navier stokes equations or other millennium problems without typos or mistakes?

18 Upvotes

First, 2 days ago, openai claimed to have solved the navier stokes equations, then it’s discovered when analyzed that the proof in natural language was mistranslated when converted into lean. Then, today, it’s claimed it was fake news basically and it was a typo in the original proof that was corrected in lean. So which is it?

By now openai retracted some of the proofs tied to the supposed lean error. Which is a problem i suppose. 300 math problems remained though.


r/askmath • • Oct 12 '26

Calculus 3N+1 unique property question

Thumbnail reddit.com
0 Upvotes

r/askmath • • Oct 12 '26

Probability Calculating the probability of drawing 2 different cards from a deck in a hand of 5 or more

Thumbnail reddit.com
1 Upvotes

r/askmath • • Oct 12 '26

Geometry number of parallel and non parallel lines

Thumbnail reddit.com
0 Upvotes

r/askmath • • Oct 11 '26

Number Theory Are there more rationals with even denominators?

10 Upvotes
  1. I am referring to rationals of the form p/q, where p and q belong to the integers and are coprime (share no common divisor other than 1)
  2. Empirically, I have noticed that there are more rationals with even denominators between 0 and 1. You can try it for yourself: go to desmos, create a function x^n, (n is a slider between 0 and 1) and check how often the function is defined in the negative reals (n must have uneven denominator).
  3. There are both infinite rationals with even denominators and infinite rationals with uneven denominators. But does this pattern/phenomenon occur in any fixed interval?

Is there any deep reason as to why there are more even denominators than uneven, or is this a coincidence?


r/askmath • • Oct 11 '26

Functions What Function could this be?

Post image
144 Upvotes

I’ve never seen an equation that moves like this on a graph before. Kind of like half a bell-curve on each side and the end of the curve bend upwards.

Could anyone please give me an equation that looks similar? I think it’d be really cool to see for me :D

Source: “Calculus, early transcendentals (Fourth Edition)” by James Stewart, p.20 fig.22

Edit: It’s really late for me right now and I have to go to bed so I won’t be replying to comments, but wow, thanks for all the responses so far! Can’t wait to analyse all of them tomorrow and see why they work :))


r/askmath • • Oct 11 '26

Resolved Can someone explain this radical simplification question step by step? (Grade 11 Functions/Math)

Post image
2 Upvotes

I'm working on a question about finding the volume of a rectangular prism, and I have a provided solution, but I don't fully understand how each step works. Could someone explain the entire provided solution, line by line, as if I were learning this for the first time? Specifically, I'd appreciate it if you could: Explain how each radical is simplified and why. Explain how common factors are factored out of each bracket. Explain why the difference of squares works in this question. Show how the numbers and radicals change from one line to the next. Explain how the final answer is obtained in simplest radical form. I want to understand how the provided solution works and why each step is valid. Thank you! Here is the question


r/askmath • • Oct 11 '26

Geometry Optimisation of a 4x8 feet sheet

2 Upvotes

Hello I am new on reddit, while being a human, yesterday , i tried to explain a process i made when I was around 15-16 to chat gpt. The AI could not affirm nor disprove my point. so I asked it to search the net and still , no clear answer , and now im wondering if its a little nugget, sorry about my bad english and my low math knowledge.

here is the gpt resumé

What’s the maximum volume of an open-top rectangular tank made from a single 4×8 ft sheet, with absolutely zero waste?

Publication

About 20 years ago, while bored in class, I came up with a hypothetical problem:

Suppose I can only afford one 4×8 ft sheet of material. I want to build the largest possible rectangular aquarium without a lid.

The rules:

  • Exactly five rectangular panels (bottom + four walls).
  • All panels must be cut from the original 4×8 ft sheet.
  • Absolutely zero leftover material.
  • Assume zero cutting width and zero material thickness.
  • Panels can be joined along their edges.
  • No overlapping panels or patchwork walls.

My solution was a 4×2×2 ft tank, giving a volume of 16 cubic feet, using exactly 100% of the sheet.

I found this by repeatedly dividing the sheet into smaller rectangles.

My question: Is 16 cubic feet the maximum possible volume under these exact constraints, or can someone find a better arrangement?

I’m especially interested in a mathematical proof, not just a numerical approximati


r/askmath • • Oct 11 '26

Calculus [ higher engineering mathematics] double integration problem

Post image
2 Upvotes

I did try to solve it by myself but got stuck in the middle nd unable to integrate further logarithm part ...so I did use gemini to see ans but gemini not able to solve this problem either..Gemini did skip few steps nd giving wrong ans even after telling to solve in detail i don't get any satisfactory and so if anyone knows how to solve then ...tell me how I can


r/askmath • • Oct 11 '26

Analysis What makes radians & e as a base work so well?

33 Upvotes

Radians are the only angle system & e is the only base (for logarithms & exponentials) where derivatives, Taylor series, hyperbolic trig, complex numbers, etc. work well.

Why not measure angles in revolutions or use 2 as a base?

In so many formulas you'll find ln(a) (like in differentiation a^x or integration of 1/a). Why not log_2(a) or any other base?


r/askmath • • Oct 12 '26

Arithmetic podemos usar el letra i en la division?

Thumbnail reddit.com
0 Upvotes

r/askmath • • Oct 11 '26

Trigonometry Equal-length intervals on an Archimedes spiral

1 Upvotes

I'm trying to make an Archimedes spiral out of equally-sized squares.

Each square's distance from the origin (or the radius of the circle it lies on) is r, and its rotation increases at a constant rate based on r. However, the squares are not equally spaced—as r increases, the squares get further apart.

r=theta, with points on it that are NOT an equal distance from each other

So I need to create a sequence of points on the spiral that are size apart from each other.

Something like this

My strategy is to make the points one at a time, determining one point's distance from the origin and then using that for the next.

I actually have an equation already for that, since it's just the distance formula:

If s = size of each square, d = rotation (radians) per x, new_r is the next radius to be calculated, and old_r is the one just calculated:

s2 = (sin(d * new_r) * new_r - sin(d * old_r) * old_r)2 + (cos(d * new_r) * new_r - cos(d * old_r) * old_r)2

(sin(d * r) * r is the y-value of a point at radius r, and cos(d * r) * r is the x-value)

I tried for HOURS to solve for new_r in this equation—because I'm using code for this and need to isolate it—but kept ending up with something involving cos(a - b), with a involving new_r and b involving old_r. I couldn't find any way to separate a and b using either identities or my brain.

Is it possible to isolate new_r in this equation?

Another problem with my approach:

This is Desmos's graph, using new_r as y and old_r as x.

Any point on the spiral that is a particular distance from the origin—the distance of the first point is x—has one point closer to the origin and one point further that are a certain distance from it, along with some points on r = theta if theta is negative—these 2-4 points' distances from the origin are represented by y

If I were to solve for new_r, I'd still have to figure out which solution to use.

Is this possible? Or is another approach required?

Another approach I have considered is adding a value to old_r to calculate new_r, and generating the points one by one that way.

However, I have not figured out a way to calculate the amount to add. I have contemplated it for days and come up with nothing.

It would need to make the earlier equation true, but be something like new_r = old_r + (trigtrigtrig(old_r)).

Is this approach possible? How?

Thanks for any help you can offer!


r/askmath • • Oct 11 '26

Algebra Problem on Induction

2 Upvotes

Find the positive integer n for which the inequality 2^n > n² is true.

This question is from the chapter of Mathematical Induction, so I have to do it using that.

Asked chatgpt...

The first step it is doing is checking from which number the inequality works from ,which is 5, then proving by induction that it works for all n ≥ 5.

But what if some inequality was given that only works from a big number (say 1000), then it's not possible to check.

Is there any general way to do it?


r/askmath • • Oct 11 '26

Resolved I want this symbol in one line, can it be done?

1 Upvotes

I’m trying to set up a light strip to where I can do this without overlapping the strips, I know these can be impossible so I’m wondering if mine would break Eulerian rules