ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 16 Jun 2021 21:57:12 +0200How to use prime_range with a formula instead of an integerhttps://ask.sagemath.org/question/57590/how-to-use-prime_range-with-a-formula-instead-of-an-integer/Hi. First post here, so please tell me if I'm not doing this right. Thanks.
I want to find all the primes in a range defined by a formula rather than an integer. I tried:
1. a=n^2+1
2. b=(n+1)^2-1
3. 0 is less than n is less than 21 (I tried typing this here in help with just the symbols, but the preview only showed "0" if I did that.)
4. prime_range(a,b)
and got the error message:
TypeError Traceback (most recent call last)
<ipython-input-1-9910057c7272> in <module>
----> 1 a=n**Integer(2)+Integer(1)
2 b=(n+Integer(1))**Integer(2)-Integer(1)
3 Integer(0)<n<Integer(20)
4 prime_range(a,b)
/home/sc_serv/sage/local/lib/python3.9/site-packages/sage/rings/integer.pyx in sage.rings.integer.Integer.__pow__ (build/cythonized/sage/rings/integer.c:15218)()
2206 return coercion_model.bin_op(left, right, operator.pow)
2207 # left is a non-Element: do the powering with a Python int
-> 2208 return left ** int(right)
2209
2210 cpdef _pow_(self, other):
TypeError: unsupported operand type(s) for ** or pow(): 'function' and 'int'
Can you tell me how to get the result I am looking for? Thank you!Jerry CaveneyWed, 16 Jun 2021 21:57:12 +0200https://ask.sagemath.org/question/57590/What does SageMath use to create the pattern when planes overlap?https://ask.sagemath.org/question/57502/what-does-sagemath-use-to-create-the-pattern-when-planes-overlap/When two differently colored planes are plotted on (almost) the same plane, what is the formula that SageMath uses to create the pattern shown in the graph? Here one plane is slightly larger-- which makes SageMath show them both in a way that looks slightly similar to an animal print. Also, as you move/manipulate the graph with the mouse, the pattern changes. What formula or information does SageMath use to show the pattern?
I used the Sage Cell Server online to plot this:
sage: M = implicit_plot3d(lambda x,y,z: x, (-15,15), (-15,15), (-15,15), rgbcolor= (0.0, 1.0, 0.0), frame=true)
sage: N = implicit_plot3d(lambda x,y,z: x, (-15,15), (-15,15), (-15,15.5), rgbcolor= (0.0, 0.0, 1.0), frame=true)
sage: M+N
Thanks for any information you can provide!
lschafferWed, 09 Jun 2021 16:21:15 +0200https://ask.sagemath.org/question/57502/How can I calculate this sum? (accept both sage(cocalc) and by hand)https://ask.sagemath.org/question/43364/how-can-i-calculate-this-sum-accept-both-sagecocalc-and-by-hand/ How can I calculate this sum?
1/1-(x+x^2)^2
* This is the sum of infinity formula : a/1-r, while a=1 and r=(x+x^2)^2
Please also confirm if my formula is right.pizzaMon, 13 Aug 2018 18:24:41 +0200https://ask.sagemath.org/question/43364/Plot circle or ellipse with equation?https://ask.sagemath.org/question/10311/plot-circle-or-ellipse-with-equation/Given the standard equation of a circle:
x^2 + y^2 + 7*x - 2*y + 6 = 0 --Simplified-to--> (x+7/2)^2 + (y-1)^2 = 29/4
Standard formula of a circle: (x + (-h))^2 + (y + (-k))^2 = r^2
The center is represented by (h, k); radius by sqrt(r^2).
So my first question is, is there are way I could insert either of the 1st 2 equations and have Sage 5.9 generate the circle?
My second question similarly deals with an ellipse that has the simplified equation:
((x+2)^2)/9 + ((y-1)^2)/25 = 1
Its major axis is: (-2,-4) (-2,6)
Minor axis is: (-5,1) (1,1)
Standard form of an ellipse is: ((x - (-h))^2)/b^2 + ((y + (-k))^2)/a^2
Center is determined by analyzing the differences between the x2/x1, y2/y1 coordinates of the major or minor axis (i.e. midpoint formula).
Could I generate an ellipse baed on the simplified equation?
In case anyone's interested, the following thread has an unanswered question:
http://ask.sagemath.org/question/2764/graph-based-on-y-value-as-the-input-and-x-as-thebxdinTue, 02 Jul 2013 14:24:51 +0200https://ask.sagemath.org/question/10311/Human readable representation of formulashttps://ask.sagemath.org/question/10079/human-readable-representation-of-formulas/Hello,
i do have question regarding the representation of formulas in sage.
Is a formula typed into sage, the routines will transform the expression, which could be less human readable. How can I programm sage to use the typed in formula and still compute a solution?
Example:
f(h)=0.19+0.91*((h+140)/760)^2
will be transformed to
(1.57548476454294e-6)*(h + 140)^2 + 0.190000000000000
Sincerelyreb_rebMon, 29 Apr 2013 13:55:02 +0200https://ask.sagemath.org/question/10079/Connecting two previously defined propcalc formulas using ->https://ask.sagemath.org/question/9616/connecting-two-previously-defined-propcalc-formulas-using-/ import sage.logic.propcalc as propcalc
f = propcalc.formula("(a->b)&(b->c)")
g = propcalc.formula("a->c")
h = f -> g
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("aW1wb3J0IHNhZ2UubG9naWMucHJvcGNhbGMgYXMgcHJvcGNhbGMKZiA9IHByb3BjYWxjLmZvcm11bGEoIihhLT5iKSYoYi0+YykiKQpnID0gcHJvcGNhbGMuZm9ybXVsYSgiYS0+YyIpCmggPSBmIC0+IGc="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmp4YAIeP/___code___.py", line 5
h = f -> g
^
SyntaxError: invalid syntax
This looks like Python interpreter is interpreting the line before it goes to the propcalc. How do I make the formula f -> g? Is there some function like h = f.implies(g) or some such?
Thanks
matrimcSat, 08 Dec 2012 13:59:44 +0100https://ask.sagemath.org/question/9616/Recover general formula for fourier series?https://ask.sagemath.org/question/8600/recover-general-formula-for-fourier-series/Hi,
Is there a way to recover the general formula for a fourier series? That is, f.fourier_series_sine_coefficient(9,pi) will give me the 9th sine coefficient, but I'd like to know more generally how I can construct the Nth sine coefficient.
I'm doing some complicated (to me) fourier series, and I'm having trouble figuring out the formula for the Nth.
Thanks for any help.
Andrewgopher13Thu, 29 Dec 2011 15:52:24 +0100https://ask.sagemath.org/question/8600/