Ask Your Question

Jerry Caveney's profile - activity

2024-03-26 16:50:07 +0200 received badge  Famous Question (source)
2023-07-21 15:33:29 +0200 received badge  Popular Question (source)
2023-05-23 16:17:48 +0200 received badge  Notable Question (source)
2023-05-10 01:22:12 +0200 received badge  Popular Question (source)
2022-12-29 21:18:05 +0200 received badge  Popular Question (source)
2022-05-01 19:06:48 +0200 received badge  Popular Question (source)
2021-08-20 01:37:45 +0200 commented answer How to reduce a list of fractions

Forgot about that. Done. Thank you.

2021-08-20 01:37:06 +0200 marked best answer How to reduce a list of fractions

I have a list of integers. I want to divide (n+1) by n. I can do this with no problem, but I can't get the resulting fractions in reduced form. My list has 50 items, but I'll only do a list of 5 here to avoid spamming.

sage: a = [6198089008491993412800, 3099044504245996706400, 2066029669497331137600, 2324283378184497529800, 1239617801698398682560]

sage: c = [(n + 1)/n for n in a]

sage: print (c)

[6198089008491993412801/6198089008491993412800, 3099044504245996706401/3099044504245996706400, 2066029669497331137601/2066029669497331137600, 2324283378184497529801/2324283378184497529800, 1239617801698398682561/1239617801698398682560]

I don't know why Sage doesn't automatically reduce these fractions, but since it doesn't, I've tried multiplying by 1 and using reduce() and simplify(), and have searched everywhere I could think of for an answer, but nothing works. I apologize in advance for asking such a rudimentary question.

2021-08-18 23:20:32 +0200 commented answer How to reduce a list of fractions

Corrected, and once more thanks. If you see anything else that should be fixed, please let me know. I've learned a lot f

2021-08-18 23:19:12 +0200 commented answer How to reduce a list of fractions

Thanks also for the Sage method using zip. Just noticed now that you had added that to your answer.

2021-08-18 23:18:59 +0200 commented answer How to reduce a list of fractions

Thanks also for the Sage method using zip. Just noticed now that you had added that to your answer.

2021-08-18 23:13:09 +0200 edited answer How to reduce a list of fractions

Note: I added this answer before I saw that FrédéricC had provided an answer using Sage, which is perfect. I have not de

2021-08-18 23:10:39 +0200 edited question How to reduce a list of fractions

How to reduce a list of fractions I have a list of integers. I want to divide (n+1) by n. I can do this with no problem,

2021-08-18 17:12:18 +0200 commented answer How to reduce a list of fractions

I've tried to edit all my mistakes (though I'm not sure, should Sage output be treated as code? I'm guessing no). If mis

2021-08-18 17:11:59 +0200 commented answer How to reduce a list of fractions

I've tried to edit all my mistakes (though I'm not sure, should Sage output be treated as code? I'm guessing no). If mis

2021-08-18 17:10:17 +0200 edited answer How to reduce a list of fractions

Note: I added this answer before I saw that FrédéricC had provided an answer using Sage, which is perfect. I have not de

2021-08-18 17:09:47 +0200 edited answer How to reduce a list of fractions

Note: I added this answer before I saw that FrédéricC had provided an answer using Sage, which is perfect. I have not de

2021-08-18 17:07:45 +0200 edited question How to reduce a list of fractions

How to reduce a list of fractions I have a list of integers. I want to divide (n+1) by n. I can do this with no problem,

2021-08-18 17:03:47 +0200 edited answer How to reduce a list of fractions

Note: I added this answer before I saw that FrédéricC had provided an answer using Sage, which is perfect. I have not de

2021-08-18 17:02:24 +0200 commented question How to reduce a list of fractions

Thank you! I didn't pay attention to the output of Sage. I'm trying to divide each term in the list by the term before i

2021-08-18 17:01:58 +0200 received badge  Commentator
2021-08-18 17:01:58 +0200 commented question How to reduce a list of fractions

Oops! thank you.

2021-08-18 14:50:42 +0200 received badge  Self-Learner (source)
2021-08-18 14:50:42 +0200 received badge  Teacher (source)
2021-08-18 02:18:34 +0200 edited answer How to reduce a list of fractions

Note: I added this answer before I saw that FrédéricC had provided an answer using SM, which is perfect. I have not dele

2021-08-18 02:14:51 +0200 commented answer How to reduce a list of fractions

Thank you! (I added my answer before I saw that you had answered.)

2021-08-18 02:06:46 +0200 answered a question How to reduce a list of fractions

The answer is to use Python: import fractions a = [insert list, deleting last item] b = [insert list deleting first

2021-08-18 02:02:39 +0200 commented question How to reduce a list of fractions

Thank you, FrédéricC. I went to Python, which I have been studying, slowly, and (of course) with some help from the Stac

2021-08-17 20:20:33 +0200 commented question How to reduce a list of fractions

Thank you! I didn't pay attention to the output of SM. I'm trying to divide each term in the list by the term before it,

2021-08-17 20:16:39 +0200 commented question How to reduce a list of fractions

Thank you! I didn't pay attention to the output of SM. I'm trying to divide each term in the list by the term before it,

2021-08-17 19:01:08 +0200 asked a question How to reduce a list of fractions

How to reduce a list of fractions I have a list of integers. I want to divide (n+1) by n. I can do this with no problem,

2021-07-14 17:36:14 +0200 commented answer How to multiply a list by an integer?

thank you.

2021-07-13 21:47:56 +0200 commented answer How to multiply a list by an integer?

Thank you! Do you know of a site where I can learn why this works, and how similar problems have to be programmed to wor

2021-07-13 21:46:44 +0200 marked best answer How to multiply a list by an integer?

This is so basic I'm embarrassed to even ask the question, but I've tried all the possibilities I can think of, and searched two SM guides (SM Tutorial and SM for Undergrads), and I can't find out how to do this. I want to multiply a list of rational numbers (fractions) by an integer. I've tried with lists and sets (although sets wouldn't really work, because the list of fractions contains repetitions), and I've tried with the single integer as simply a number and as a list. But I always get an error message, saying "unsupported operand type(s)" or something similar. Here is an example of what I'm trying to do:

a = [1, 1/2, 1/3, 3/8, 1/5, 1/3, 3/14, 1/4, 1/6, 1/4,]

b = 840

print (a ^ b)

Help for a clueless newbie would be greatly appreciated. (Also, if anyone can recommend a tutorial or guide that will explain how to do these sorts of things in SM, that would be even better!)

2021-07-13 20:31:24 +0200 edited question How to multiply a list by an integer?

How to multiply a list by an integer? This is so basic I'm embarrassed to even ask the question, but I've tried all the

2021-07-13 18:14:40 +0200 asked a question How to multiply a list by an integer?

How to multiply a list by an integer? This is so basic I'm embarrassed to even ask the question, but I've tried all the

2021-06-18 02:39:51 +0200 marked best answer How to return only the denominators of a sequence of fractions created by a formula

With essential help from slelievre, I managed to achieve coding to return the fractional 'density' (if that is the right term) of primes between n^2 and (n+1)^2:

for n in range(1, 51):
    a = n^2 + 1
    b = (n + 1)^2 + 1
    c = 2*n
    nprimes = sum(1 for p in prime_range(a, b))
    d = f"{nprimes}/{c}"
    print(d)

Now I want to extract just the denominators of this sequence so that I can find the LCM of all those denominators and then convert all the fractions to have the same LCM denominator. (I cannot just use 2n to find the LCM because the fractions need to be reduced.) I found the command x.denominator(), but it seems to work for only a single fraction of integers. At least that's what I understand the error message to mean when I try d.denominator() or print(d.denominator()), the error message reading "AttributeError: 'str' object has no attribute 'denominator'".

Any help in showing me how to do this would be greatly appreciated.

2021-06-18 02:39:43 +0200 commented answer How to return only the denominators of a sequence of fractions created by a formula

Thank you, everything works beautifully now. I'm learning Python syntax mostly by trial and error. I've worked on the SM

2021-06-18 01:26:13 +0200 commented answer How to return only the denominators of a sequence of fractions created by a formula

Thank you so much. This certainly looks like what I need, but I can't get it to work. I apologize for my ignorance. I fi

2021-06-18 00:00:37 +0200 commented question How to return only the denominators of a sequence of fractions created by a formula

I have now worked out the LCM by hand (but I still want to be able to do it through SageMath), and the value is a bit ov

2021-06-17 22:33:58 +0200 asked a question How to return only the denominators of a sequence of fractions created by a formula

How to return only the denominators of a sequence of fractions created by a formula With essential help from slelievre,