Ask Your Question

dazedANDconfused's profile - activity

2019-09-07 21:34:01 -0500 commented question solving simultaneous equations with solve()

I don't know what's going wrong here. I'll leave that to the experts. I did find that not specifying the algorithm gives many solutions, including the solution you list.

print s

I tried assume(x>0,y>0) but that didn't work.

2019-09-02 11:03:15 -0500 commented question how do I enter 2sin|1−3√2|cos|1+ 2√3|

The problem you've written makes no sense. Please clarify: What is the argument for sin? Should sin * be sin( ? If so where should the closing parenthesis be? Same could asked for cos. Assuming you mean 2 * sin(abs(1-3 * sqrt(2)))*cos(abs(1+2 * sqrt(3))) then I have Sage running without a problem, with an answer of about 0.049579.

2019-08-05 09:52:55 -0500 commented answer Code to find separating set in SageMath of a given Graph

I don't see anything in the documentation that would provide all minimal separating sets of a graph. Given that circulants would have a lot of vertex separating sets, I don't see any way around brute force checking whether the removal of k vertices (where k is the vertex connectivity) over all subsets of k vertices results in a disconnected graph. If so add to the list.

2019-08-04 10:27:23 -0500 answered a question Code to find separating set in SageMath of a given Graph

Try this code:

from sage.graphs.connectivity import vertex_connectivity

The result, running in a SageCell Server is

(3, [1, 2, 3])

Which says the vertex connectivity is 3 and the vertices 1,2,3 are such a set.

The documentation for vertex_connectivity() is here.

2019-07-28 18:36:01 -0500 answered a question How to compute a perfect matching in a general graph?

You should download the PDF documentation which is available here. On page 222 there are 3 listed:

  1. matching() Return a maximum weighted matching of the graph represented by the list of its edges.
  2. has_perfect_matching() Return whether this graph has a perfect matching
  3. perfect_matchings() Return an iterator over all perfect matchings of the graph.

Clicking on each method will bring you to more instructions and examples.

2019-06-22 19:13:29 -0500 commented answer find all matchings in a graph

That makes sense; then just needs a loop from 0 to vertices/2.

2019-06-21 19:08:11 -0500 commented question find all matchings in a graph

The documentation has matching_polynomial here; it's coefficients, ignoring the sign, tell you the number of matchings as the the number of edges increases. The matching polynomial for the Petersen graph is x^10 - 15x^8 + 75x^6 - 145x^4 + 90x^2 - 6 which would be interpreted as 1 matching with 0 edges, 15 matchings with 1 edge, 75 matchings with 2 edges, 145 matchings with 3 edges, 90 matchings with 4 edges, and 6 matchings with 5 edges. It doesn't list the matchings but the documentation mentions an algorithm used to get the polynomial.

2019-05-24 11:06:33 -0500 answered a question How to use sagetex?

I'm not familiar with the setup you are using but to use sagetex, latex your example.tex file. This will create a .sage file. Next, use the Sage terminal to load the .sage file. The file not found error sounds like you're running Sage on the wrong directory so try cd (change directory) to the directory containing your .sage file when using the Sage terminal. Finally latex your .tex file again. You can find more detail to this answer by looking at an answer posted by DJP here. The easiest way, however, to get up and running with LaTeX, Sage, and Sagetex is with a free Cocalc account. Just create a .tex file, copy/paste example.tex into it, and then compile and you're done.

2019-04-01 05:59:56 -0500 received badge  Nice Answer (source)
2019-03-31 21:51:57 -0500 commented answer Create program to find which graphs contain specific subgraph

There is an extensive, almost 900 page, pdf reference doc just on graph theory which is available here.

2019-03-31 19:32:44 -0500 answered a question How to save combinations of plots?

Basically you want to save the picture, not show it. combining show and save is the problem. Try this:

a = plot(f1, (x,-1,2))
b = plot(f2, (x,-1,2))
c = plot(f3, (x,-1,2))
pic = a+b+c'pic.pdf')

Press on the link pic.pdf to see it and download it. Note, with multiple plots you might want to color them. This can be done, for example, with b = plot(f2, (x,-1,2),color='red'). If you want to show as well insert the line right after pic is defined.

EDIT: As Juanjo comments below, you can combine the 3 plots into 1. If you stack the functions together on one line using ; you can compress the code even more:

f1=x; f2=cos(x); f3=x^2
pic = plot([f1,f2,f3], (x,-1,2), color=["red","green", "blue"])'pic.pdf')
2019-03-30 21:57:42 -0500 answered a question Create program to find which graphs contain specific subgraph

How about:

g10=[g for g in graphs.nauty_geng('10 25') if g.clique_number()==4]
H = graphs.CycleGraph(5)
for g in g10:
    if g.subgraph_search(H,induced=False):

After defining the subgraph you want, the cycle on 5 vertices, look through the graphs in g10 and figure out if it has H, not necessarily induced. It then prints out the graphs. The documentation for subgraph_search is here.

EDIT: With respect to your comment below, I think that it is possible but I don't know enough of the intricacies of the graph theory commands. Consider this code.

g10=[g for g in graphs.nauty_geng('10 25') if g.clique_number()==4]
H = graphs.CycleGraph(5)
K = graphs.CompleteGraph(4)
for g in g10:
    if g.subgraph_search(H,induced=False):
        for p in g.subgraph_search_iterator(K,induced=True):
            for v in p:
                    print "False"
                    print p
                    print "True"

For each graph in g10 it looks for a non-induced C_5. If the graph has it then it looks for an induced K_4. When it finds it, it looks at all the vertices in it (the subgraph p which is a K_4) and looks to see if the degree of any vertex is less than 6. If so, it prints out "False", the 4 vertices inducing K_4 and the graph from g10 that they are a subgraph of. If you didn't require the graph to have H then you can easily modify the code to what you want.

2019-03-29 10:30:33 -0500 commented question desolve (how can i enable numeric?)

The documentation is not as user friendly as a guide; this is useful. I don't have experience with differential equations but adding contrib_ode=True, show_method=True to desolve tells you it's separable and after adding the lines c = de.variables()[0] sol = solve(de,y) ; sol as suggested in the guide (page 219) gets you closer. One of the experts here will know what to do.

2019-03-29 08:38:51 -0500 commented question desolve crazy output

Type (f-blob).find_root(0,10) to tell SAGE to find the root that you know is in the interval from 0 to 10 and ignore the rest.

2019-03-08 07:58:14 -0500 commented answer How to change sqrt(5) to decimal?

More detail, such as controlling the number of digits or precision, can be found in the documentation here. On this site, here gives some options.

2019-02-19 12:08:10 -0500 commented question Trouble Plotting a Function

You should give details that tmonteil asks for in order for the whizzes here to figure out what is wrong.

2019-02-19 11:53:48 -0500 commented question Trouble Plotting a Function

If you go to the Sage Cell Server here and copy/paste and run your code, it works fine.

2019-02-03 10:06:26 -0500 commented question Piecewise in SageTeX

Can you post your LaTeX code? I have no trouble plotting the piecewise function you used with sagetex. Maybe I don't understand what you are attempting. Also, are you using Cocalc off the internet or is this compiled using Sage from your computer? If Sage from your computer, what version of Sage?

2018-11-30 02:41:05 -0500 received badge  Nice Answer (source)
2018-11-29 12:09:16 -0500 commented answer log base 2 in sagemath

Nice! I wasn't aware of that book.

2018-11-29 11:52:50 -0500 answered a question log base 2 in sagemath

You've done it correctly and SAGE gives you the exact answer. If you try log(8,2) you'll get 3 because that's the exact answer and no logs are required. To force a numerical answer try, for example log(1000,2).n(digits=9) to get an approximate answer of 9.96578429. You can check if that's close by typing 2^9.96578429 to get 1000.00000369996. Want a closer answer? Change to digits=12 and repeat. Same thing with other functions such as sqrt(2).n(digits=4)

Alternatively, the documentation gives n(log(1000,2)) which gives you the approximation 9.96578428466209 with less key strokes. You can find the log function documentation here

2018-11-23 14:53:33 -0500 commented answer Is it possible to access Sage with an android tablet?

I tried but your instructions haven't working for me. I was, for example, pushed to install ConnectBot and then didn't seem to configure it correctly. So I could never get to CLI prompt. I'm stuck in ConnectBot with an error about "the authenticity of 'localhost' can't be established".

2018-11-22 09:18:01 -0500 commented question Is it possible to access Sage with an android tablet?

I've had problems with using the Sage app but there is a Sage Cell Server on the internet. So any tablet can access Sage. I don't find them convenient for anything but a couple of lines of code, given the lack of a real keyboard.

2018-11-07 20:06:15 -0500 commented question drawing the corners for the inner parallelogram(solved)

I'm having trouble understanding the question. What is a angle circle? From your code, I think you might mean arc. Your commented line is drawing the arc for an ellipse. The documentation is here and at the bottom of the page indicates you would want something like g+=arc((0,0), 1, sector=(pi/4,3*pi/4)) but I'm not sure where you want it to start and stop. What does "and add the alpha character into it" mean?

2018-11-07 10:18:34 -0500 commented question finding general term of a sequence

There is no "the nth term" for a sequence like you've given with ... . For example: 1,2,3,.... could be the sequence f(n)=n or it could be f(n)=n^3-6n^2+12n-6. There are actually an infinite number of formulas that could work here.

2018-10-26 21:45:33 -0500 commented question Need help with plotting

This sounds like homework where there's a misunderstanding as to what you're supposed to do. Try: t = var('t') parametric_plot((cos(t)+cos(2t), sin(t) + sin(3t)), (t, 0, 2*pi), color=hue(0.6)) to see the parametric curve formed by your equations above. You can't form a line without a specific value of t to get the second point.

2018-10-26 11:42:52 -0500 commented question Indefinite integral is incorrect

Using integral(sqrt(1+cos(x)**2), x).full_simplify() as suggested still results in an answer which is incorrect, doesn't it? This is a nonelementary integral. See here or here