#11837: Make Newton basin plotting fun and easy
---------------------------+------------------------------------------------
Reporter: kcrisman | Owner: jason, was
Type: enhancement | Status: new
Priority: major | Milestone:
Component: graphics | Keywords: fractal newton complex plot
Work_issues: | Upstream: N/A
Reviewer: | Author: Karl-Dieter Crisman
Merged: | Dependencies:
---------------------------+------------------------------------------------
Comment(by SimonKing):
If you evaluate the contents of your spyx file in a %cython cell in the
notebook, you will find two links just below the cell. The first contains
the c-file created from the cython code. The second is the annotated
version of the code.
I suggest to look at the annotated code. The lines of the cython code are
individually coloured in different shades of yellow. If a line is very
dark then the single cython line corresponds to ''many'' c-lines. By
clicking on the line number, you can see how each line is translated into
c.
You will find that your code is mostly dark yellow. If you want to make it
fast, the lines that are most frequently executed should be white.
Another tool: Use %prun on your functions (but it could be that it will
only work on the command line - I tried in the notebook, but it didn't
work). It will show you the internal Python function calls that took the
most time (I think it can not show you calls to Cython functions). So,
%prun may give you an idea what part of your code needs work most
urgently.
Using
{{{
sage: %prun basin_plot([-1,i,1],(-3,3),(-3,3),plot_points=100,figsize=7)
}}}
on the command line, where I had replaces `2/3` by `2./3` in the code, I
found:
{{{
ncalls tottime percall cumtime percall filename:lineno(function)
1 5.396 5.396 15.362 15.362
{_home_king_SAGE_work_attributes_newton_basins_spyx_1.basin_plot}
104309/71386 3.291 0.000 5.029 0.000
complex_interval_field.py:261(__call__)
1049154 0.771 0.000 0.771 0.000 {isinstance}
59576 0.700 0.000 0.721 0.000
polynomial_ring.py:301(_element_constructor_)
38450/19225 0.638 0.000 3.372 0.000
complex_field.py:279(_element_constructor_)
38458 0.521 0.000 3.043 0.000 qqbar.py:2951(interval)
59576 0.507 0.000 1.629 0.000
polynomial_ring_constructor.py:47(PolynomialRing)
57675 0.474 0.000 2.629 0.000
complex_field.py:246(__call__)
59576 0.297 0.000 0.369 0.000
{sage.structure.parent_gens.normalize_names}
38458 0.296 0.000 0.597 0.000
qqbar.py:2927(interval_diameter)
186759 0.262 0.000 0.262 0.000
complex_interval_field.py:242(_real_field)
59576 0.215 0.000 0.733 0.000
polynomial_ring_constructor.py:442(_single_variate)
13738 0.213 0.000 0.307 0.000
number_field.py:5075(_coerce_non_number_field_element_in)
}}}
So, it seems to me that most time is spent for internal calls to the
complex interval field, and to the function `interval` in qqbar.py. That
may be surprising, because, if I am not mistaken, you simply want to work
with complex numbers, but not with algebraic numbers.
In other words, it would be worth while to find out how your code uses
complex interval fields and algebraic numbers, and to rewrite it such that
only "usual" complex doubles are used. It may very well be that the
algebraic numbers arise in a coercion happening behind the scenes.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11837#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.