## Draw – Remove Singularity – Mathematica Stack Exchange

I got help from other members to draw this equation. but there is still a problem. when I draw this equation.

``````    eq = -1.94178*10^24*H*Te^0.5 - (3.2*(7.33376*10^27*Te^(7/2) +
4.66533*10^24*Ti^(7/2)))/
(10^9*H) + 7.68161*10^40*H*(5.41/((10^15*E^(148/Ti))*Ti^(3/2)) +
2.00122/((10^10*E^((53.124*(1 - (-0.059357*Ti + 0.0010404*Ti^2 -
(9.1653*Ti^3)/10^6)/
(1 + 0.20165*Ti + 0.0027621*Ti^2 +
(9.8305*Ti^3)/10^7))^(1/3))/Ti^(1/3)))*
(Ti^(2/3)*(1 - (-0.059357*Ti + 0.0010404*Ti^2 -
(9.1653*Ti^3)/10^6)/
(1 + 0.20165*Ti + 0.0027621*Ti^2 + (9.8305*Ti^3)/10^7))^(5/6))));

sol = H /. Solve(eq == 0, H) // Simplify;
``````

It seems that on the left side of the plot is singularity.
How can I solve the problem?
If I want to add ContourLabels, it causes a problem.
So I have to remove the singularity first and then add countorlabel

``````c = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25};

ContourPlot(sol((2)), {Ti, 1, 1000}, {Te, 1, 160}, Contours -> c,
ColorFunction -> "GrayTones", PlotPoints -> 100,
FrameLabel -> {Style("!(*SubscriptBox((T), (i)))(keV)",
FontSize -> 14, FontFamily -> "Times"),
Style("!(*SubscriptBox((T), (e)))(keV)", FontSize -> 14,
FontFamily -> "Times")},
LabelStyle -> {Directive(Black, Bold), (FontSize -> 16),
FontFamily -> "Times"},
PlotLegends ->
Placed(BarLegend(Automatic,
LegendLabel ->
Style("(Rho)R(g.!(*SuperscriptBox((cm), (-2))))",
FontSize -> 12)), {After, Center}),
ContourLabels -> (Text(#3, {#1, #2}, Background -> White) &),
Background -> White) &))
``````

Posted on Categories Articles

## dynamic – How to draw a bitmap interactively with the mouse?

I can not find that `MNIST` Example of Dynamic Activation I am firmly convinced that I have seen it in the documentation.

What would be the most efficient way to

1. Draw a black and white bitmap interactively
2. Let every change evaluate a function (/ dynamic value)

?

Somewhere in the documentation, I think, there was a much more robust version of the following:

``````c // ClearAll
c(m_) := With({w = Clip(m, {1, s})}, a((s - w((2)), w((1)))) = 0);
a = ConstantArray(1, {s, s});
DynamicModule({},
EventHandler(Dynamic@Image(a), {
"MouseDragged" :> (c@MousePosition("Graphics"))
})
)
``````

Posted on Categories Articles

## Draw – Add cross as a graphic instead of a point

How do I add a cross (eg + shape or x) to a diagram as a graph, as if I were adding a point with point?

Existing solutions (https://mathematica.stackexchange.com/a/155162/45020) always seem to use a whole additional listplot. That's awkward when you just add one point.

Also, I've noticed that for some reason, the two cross lines in this answer do not cross in the middle (most noticeably if you use FontSize -> 15).

So how do I add a + or – shape to a plot, centered on the point I give it, and with the obviously required symmetries, regardless of the size of the marker.

## libpng – stata15 very slow to draw graphs in Ubuntu 19.10 (Gnome)

For those who have tried to use stata on Linux, there have probably already been some problems with the icons and the libpng12 library … while I could fix them and start stata normally and display the icons, it somehow takes a lot long, until stata a plots scatter plot with about 150,000 observations.

• At first I thought it was a problem with stata, but it works well under manjaro (arch-based, with gnome 3.34.1).

• I have also tried several versions of stata (mp, se) and several versions (14.2, 15, 15.1) … and the results are the same for all versions: works as expected in Manjaro and very slowly in Ubuntu.

• Apart from plotting, the data seems to be just as fast as in other systems.
• At first I thought the problem was related to that libpng12 Library. I've installed this library in several ways, including using the binary file from the archive, from this ppa as in this tutorial and
also manually from xenials repo.
• also tried in elementaryOS (5.1) and ubuntu 16.04, so no problem only with the version 19.10.

does anyone have an idea what I could try?

## motivation

Pythons abstract base classes in the `collections.abc` Modules work as mixins and also define abstract interfaces that call common functions in Python objects.

While reading the actual source is quite revealing, it would be useful for Python programmers to look at the hierarchy as a graph.

Unified Modeling Language (UML) is a method of visualizing system design.

## libraries

Graphviz is a natural choice for this type of issue. There are many examples of people who generate such issues with Graphviz.

However, to ensure correctness and completeness, as well as a simple customization of the logic with which they were created, the Python classes must be inserted into Graphviz.

A natural choice is python-graphviz, but we need to put the python into the graphviz interface.

## Our grammar of graphics

UML communicates functions that Python does not have. By using a smaller subset of the relevant functions, we get a diagram that is clearer and easier for UML familiar users to understand.

Our subgroup consists of class diagrams, in which:

• Names, data elements and methods of abstract classes are printed in italics, concrete implementations are not.
• Edges (lines) are dashed if the subclass is abstract, not if the relation is a specialization.
• We only show is a Relationships (class hierarchy) are not has a Relationships (composition) because it does not really apply to our application and because the `abc` The module has no such relevant comments (if we had comments showing this relationship, we could support them, but I will not be here).

## Avoid information overload in the output

We exclude most standard methods and members in `object`, We also hide other members related to class relationships and implementations that have no direct impact on users.

We do not display return types (eg. `: type`) because we miss the notes in the module.

We do not show `+` (Public), `-` (private) and `#` (protected) icons, because everything in Python can be accessed and it is just a convention indicating that users should avoid interfaces preceded by underscores (`_`).

## The code

I have this environment with Anaconda, which uses a fresh installation and needed

``````\$ conda install graphviz python-graphviz
``````

First we import the Digraph object python-graphviz, some functions from the standard library `collections.abc` Module for the abstract base classes we want to examine and some types we want to use to distinguish between objects.

We also put types or methods and members that we want to exclude into a tuple and put the names of methods that we intentionally hide in a group.

``````from graphviz import Digraph
from inspect import getclasstree, isabstract, classify_class_attrs, signature
import collections.abc
from html import escape
from abc import ABCMeta
from types import WrapperDescriptorType, MethodDescriptorType, BuiltinFunctionType

# usually want to hide default (usually unimplemented) implementations:
# ClassMethodDescriptorType includes dict.fromkeys - interesting/rare- enough?
EXCLUDED_TYPES = (
WrapperDescriptorType, # e.g. __repr__ and __lt__
MethodDescriptorType, # e.g. __dir__, __format__, __reduce__, __reduce_ex__
BuiltinFunctionType, # e.g. __new__
)
HIDE_METHODS = {
'__init_subclass__',             # error warning, can't get signature
'_abc_impl', '__subclasshook__', # why see this?
'__abstractmethods__',
}
``````

Now we need to create the table (labels) for the graphviz nodes. Graphviz uses a syntax that looks like HTML (but not).

Here we create a function that inherits the class and returns the table from the information we can derive from the class.

``````def node_label(cls, show_all=False, hide_override=set()):
italic_format = '{}'.format
name_format = italic_format if isabstract(cls) else format
attributes = ()
methods = ()
abstractmethods = getattr(cls, "__abstractmethods__", ())
for attr in classify_class_attrs(cls):
if ((show_all or attr.name(0) != '_' or attr.name in abstractmethods)
and not isinstance(attr.object, EXCLUDED_TYPES)
and attr.name not in hide_override):
if name in abstractmethods:
name = italic_format(attr.name)
else:
name = attr.name
if attr.kind in {'property', 'data'}:
attributes.append(name)
else:
try:
args = escape(str(signature(attr.object)))
except (ValueError, TypeError) as e:
print(f'was not able to get signature for {attr}, {repr(e)}')
args = '()'
methods.append(name + args)
td_align = ''
line_join = ''.join
attr_section = f"{td_align}{line_join(attributes)}"
method_section = f"{td_align}{line_join(methods)}"
return f"""<

{attr_section}
{method_section}

{name_format(cls.__name__)}
>"""
``````

The above code gives us a way to create the tables for the nodes.

Now we define a function that takes a class tree (the kind that is returned by) `inspect.getclasstree(classes)`) and returns a fully instantiated `Digraph` Object suitable to display an image.

``````def generate_dot(
classtree, show_all=False,
hide_override=HIDE_METHODS, show_object=False):
"""recurse through classtree structure
and return a Digraph object
"""
dot = Digraph(
name=None, comment=None,
filename=None, directory=None, format='svg',
engine=None, encoding='utf-8',
graph_attr=None,
node_attr=dict(shape='none'),
edge_attr=dict(
arrowtail='onormal',
dir='back'),
body=None, strict=False)
def recurse(classtree):
for classobjs in classtree:
if isinstance(classobjs, tuple):
cls, bases = classobjs
if show_object or cls is not object:
dot.node(
cls.__name__,
label=node_label(cls, show_all=show_all,
hide_override=hide_override))
for base in bases:
if show_object or base is not object:
dot.edge(base.__name__, cls.__name__,
style="dashed" if isabstract(base) else 'solid')
if isinstance(classobjs, list):
recurse(classobjs)
recurse(classtree)
return dot
``````

And the use:

``````classes = (c for c in vars(collections.abc).values() if isinstance(c, ABCMeta))
classtree = getclasstree(classes, unique=True)

dot = generate_dot(classtree, show_all=True, show_object=True)
#print(dot.source) # far too verbose...
dot
``````

We do `show_object=True` here, but since everything is an object in Python, it's a bit redundant and will be at the top of every class hierarchy, so I think it's safe to use the default `show_object=False` for regular use.

``````dot.render('abcs', format='png')
``````

Gives us the following PNG file (because the stack overflow does not display SVGs): ## Suggestions for further work

An expert in Python or Graphviz could find important things that we have missed here.

We could Pull out some features and write some unit tests.

We could also search and edit annotations for data items that are usually included in it `__dict__`,

We may also not treat all types of Python object creation as we should.

I've mostly used the following example code to model the classes for creating the node table:

``````from abc import abstractmethod, ABCMeta
from inspect import isabstract, isfunction, classify_class_attrs, signature

class NodeBase(metaclass=ABCMeta):
__slots__ = 'slota', 'slotb'
@abstractmethod
def abstract_method(self, bar, baz=True):
raise NotImplementedError
def implemented_method(self, bar, baz=True):
return True
@property
@abstractmethod
def abstract_property(self):
raise NotImplementedError
@property
def property(self):
return False

class NodeExample(NodeBase):
__slots__ = 'slotc'

NE = NodeExample
``````

Posted on Categories Articles

## Draw the star shape square in the terminal using Python

I'm trying to use this code to draw a square with stars on my terminal:

``````print("t"" "*15 + "*"*45)
print(" "*9 + "*" + " "*9+"some text" + " "*25+ "*")
print(" "*9 + "*" + " "*9+"some text" + " "*25 + "*")
print(" "*9 + "*" + " "*9+"some text" + " "*25 + "*")
print(" "*9 + "*"*45)
``````

What I'm trying to do is write a Python script that contains a list of commands in this star-shaped field that I can type into the terminal to do things. For a different length, I'll have to change the number of spaces after that by calculating how many spaces I need to print the last star correctly and the same thing before the "text". This is a silly way.

Does any of you have any ideas that can help make this more efficient?

## Drawing – How do I use a list of rules to draw complex solutions?

I'm trying to find the frequency for three circular particles connected in a circle with different spring constants and different masses. After deriving the equations of motion, I get three complex equations for w, which I transform into a matrix. If I set the determinant to 0, I should be able to find w (the frequency). k, l, m, M are constants and w is a function of ka.

For simplicity, I have changed the exponential function to a trigonometric function. I assumed that I would get some real solutions, but Mathematica found only complex solutions. So I'm wondering if the solutions are wrong or if I've made a mistake somewhere. The story is completely empty.

Here is my code:

``````
In(299):= k = 9;
l = 12;
m = 2;
M = 4 ;
mat = {{m*w^2 - 2*k, k, k*Exp(-3 I*ka)}, {k, M*w^2 - (l + k),
l}, {-k*Exp(-3 I*ka), l, M*w^2 - (k - l)}};
mydet = ExpToTrig(Det(mat))
sol = Solve(mydet == 0, w)

Out(304)= 3483 + 558 w^2 - 432 w^4 + 32 w^6 - 1701 Cos(6 ka) +
324 w^2 Cos(6 ka) + 1701 I Sin(6 ka) - 324 I w^2 Sin(6 ka)

Out(305)= {{w -> -(Sqrt)(9/
2 + (1386 2^(1/3))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) - (324 2^(1/3) Cos(6 ka))/(-4478976 + 6718464 Cos(6 ka) +
Sqrt(4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) + (
1/(96 2^(
1/3)))((-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3)) + (324 I 2^(1/3) Sin(6 ka))/(-4478976 +
6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3))}, {w -> (Sqrt)(9/2 + (
1386 2^(1/3))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) - (
324 2^(1/3)
Cos(6 ka))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) + (-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3)/(
96 2^(1/3)) + (
324 I 2^(1/3)
Sin(6 ka))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3))}, {w -> -(Sqrt)(9/
2 - (693 2^(1/3))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) + (693 I 2^(1/3) Sqrt(3))/(-4478976 + 6718464 Cos(6 ka) +
Sqrt(4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) + (162 2^(1/3) Cos(6 ka))/(-4478976 + 6718464 Cos(6 ka) +
Sqrt(4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) - (162 I 2^(1/3) Sqrt(3) Cos(6 ka))/(-4478976 +
6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) - (
1/(
192 2^(1/3)))((-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3)) - (
1/(64 2^(1/3) Sqrt(3)))
I (-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) - (162 I 2^(1/3) Sin(6 ka))/(-4478976 +
6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) - (162 2^(1/3) Sqrt(3) Sin(6 ka))/(-4478976 +
6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3))}, {w -> (Sqrt)(9/2 - (
693 2^(1/3))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) + (
693 I 2^(1/3) Sqrt(
3))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) + (
162 2^(1/3)
Cos(6 ka))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) - (
162 I 2^(1/3) Sqrt(3)
Cos(6 ka))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) - (-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3)/(
192 2^(1/3)) - (1/(64 2^(1/3) Sqrt(3)))
I (-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) - (
162 I 2^(1/3)
Sin(6 ka))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) - (
162 2^(1/3) Sqrt(3)
Sin(6 ka))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3))}, {w -> -(Sqrt)(9/
2 - (693 2^(1/3))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) - (693 I 2^(1/3) Sqrt(3))/(-4478976 + 6718464 Cos(6 ka) +
Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) + (162 2^(1/3) Cos(6 ka))/(-4478976 + 6718464 Cos(6 ka) +
Sqrt(4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) + (162 I 2^(1/3) Sqrt(3) Cos(6 ka))/(-4478976 +
6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) - (
1/(192 2^(
1/3)))((-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3)) + (
1/(64 2^(1/3) Sqrt(3)))
I (-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) - (162 I 2^(1/3) Sin(6 ka))/(-4478976 +
6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) + (162 2^(1/3) Sqrt(3) Sin(6 ka))/(-4478976 +
6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3))}, {w -> (Sqrt)(9/2 - (
693 2^(1/3))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) - (
693 I 2^(1/3) Sqrt(
3))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) + (
162 2^(1/3)
Cos(6 ka))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) + (
162 I 2^(1/3) Sqrt(3)
Cos(6 ka))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(
1/3) - (-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3)/(
192 2^(1/3)) + (1/(64 2^(1/3) Sqrt(3)))
I (-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) - (
162 I 2^(1/3)
Sin(6 ka))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3) + (
162 2^(1/3) Sqrt(3)
Sin(6 ka))/(-4478976 + 6718464 Cos(6 ka) + Sqrt(
4 (-133056 + 31104 Cos(6 ka) -
31104 I Sin(6 ka))^3 + (-4478976 + 6718464 Cos(6 ka) -
6718464 I Sin(6 ka))^2) - 6718464 I Sin(6 ka))^(1/3))}}

ComplexListPlot(w /. sol, PlotLegends -> "Expressions")
``````

The plot is empty, although I have 6 complex solutions. I also tried Plot (w / Sol, {ka, 0, pi}), which also gives an empty plot. I am not getting any errors with these codes, so I assume there is a problem formatting the solution.

## Draw diagonal lines in the image with c / c ++

I have a picture and I want to draw several diagonal lines in the picture. I have the height and width of the picture.

I see some examples, but they use a graphics library. I can not use the DrawLine function or Bresenham's line algorithm. Can someone help me please? Main code is here:
// main processing
// ———————————————— —————————————

``````for(i=0; i bypass
{
O_R = I_R;
O_G = I_G;
O_B = I_B;
}

FrameY(i)(j) = min(ACCUR_,max(0,O_R));
FrameU(i)(j) = min(ACCUR_,max(0,O_G));
FrameV(i)(j) = min(ACCUR_,max(0,O_B));
}
}
``````

}
I have bmp.h where it is defined:
void DrawLine (int x0, int y0, int x1, int y1, unsigned character r, unsigned character g, unsigned character b);
However, I do not know how to use this API in the application code.

Although there is a way to solve with Bresenham's line algorithm, how can we draw diagonal lines from top left to bottom right?
Many thanks

## Draw – Use Mathematica to draw the flow of an ODE with discontinuity

How can I use Mathematica to draw in the flow of the following ODE? $$mathbb R$$?
$$frac {d} {dt} X (t, x) = chi _ { {x> 0 }} (X (t, x)), t in (0, T),$$
$$X (0, x) = x, x in mathbb R$$

from where $$chi$$ denotes the display function of a set.

I know about the command `NDSolve`but is it applicable in this situation due to the discontinuity in the source term? And I would be mainly interested in taking a nice picture of the river.

Posted on Categories Articles

## Draw – arrowhead at each point of the graph

I try to observe the flow of the vector. That's why I want to use arrowheads to indicate the flow at each point. I see many examples of how to get a big arrowhead, but not at every point. I'm trying to draw the "vector" variable with arrowheads.

``````f(x_, y_) = x + x/(x^2 + y^2);
gradientf(x_, y_) = D(f(x, y), {{x, y}});
pnts1 = {{-1.8, 0.2}, {-1.8, 0.4}, {-1.8, 0.6}, {-1.8, 0.8}, {-1.8,
1.}, {-1.8, 1.2}, {-1.8, 1.4}, {-1.8, 1.6}, {-1.8, 1.8}, {-1.8,
2.}, {-1.6, 0.2}, {-1.6, 0.4}, {-1.6, 0.6}, {-1.6, 0.8}, {-1.6,
1.}, {-1.6, 1.2}, {-1.6, 1.4}, {-1.6, 1.6}, {-1.6, 1.8}, {-1.6,
2.}, {-1.4, 0.2}, {-1.4, 0.4}, {-1.4, 0.6}, {-1.4, 0.8}, {-1.4,
1.}, {-1.4, 1.2}, {-1.4, 1.4}, {-1.4, 1.6}, {-1.4, 1.8}, {-1.4,
2.}, {-1.2, 0.2}, {-1.2, 0.4}, {-1.2, 0.6}, {-1.2, 0.8}, {-1.2,
1.}, {-1.2, 1.2}, {-1.2, 1.4}, {-1.2, 1.6}, {-1.2, 1.8}, {-1.2,
2.}, {-1., 0.2}, {-1., 0.4}, {-1., 0.6}, {-1., 0.8}, {-1.,
1.}, {-1., 1.2}, {-1., 1.4}, {-1., 1.6}, {-1., 1.8}, {-1.,
2.}, {-0.8, 0.6}, {-0.8, 0.8}, {-0.8, 1.}, {-0.8, 1.2}, {-0.8,
1.4}, {-0.8, 1.6}, {-0.8, 1.8}, {-0.8, 2.}, {-0.6, 0.8}, {-0.6,
1.}, {-0.6, 1.2}, {-0.6, 1.4}, {-0.6, 1.6}, {-0.6, 1.8}, {-0.6,
2.}, {-0.4, 1.}, {-0.4, 1.2}, {-0.4, 1.4}, {-0.4, 1.6}, {-0.4,
1.8}, {-0.4, 2.}, {-0.2, 1.}, {-0.2, 1.2}, {-0.2, 1.4}, {-0.2,
1.6}, {-0.2, 1.8}, {-0.2, 2.}, {0., 1.}, {0., 1.2}, {0.,
1.4}, {0., 1.6}, {0., 1.8}, {0., 2.}, {0.2, 1.}, {0.2, 1.2}, {0.2,
1.4}, {0.2, 1.6}, {0.2, 1.8}, {0.2, 2.}, {0.4, 1.}, {0.4,
1.2}, {0.4, 1.4}, {0.4, 1.6}, {0.4, 1.8}, {0.4, 2.}, {0.6,
0.8}, {0.6, 1.}, {0.6, 1.2}, {0.6, 1.4}, {0.6, 1.6}, {0.6,
1.8}, {0.6, 2.}, {0.8, 0.6}, {0.8, 0.8}, {0.8, 1.}, {0.8,
1.2}, {0.8, 1.4}, {0.8, 1.6}, {0.8, 1.8}, {0.8, 2.}, {1.,
0.2}, {1., 0.4}, {1., 0.6}, {1., 0.8}, {1., 1.}, {1., 1.2}, {1.,
1.4}, {1., 1.6}, {1., 1.8}, {1., 2.}, {1.2, 0.2}, {1.2,
0.4}, {1.2, 0.6}, {1.2, 0.8}, {1.2, 1.}, {1.2, 1.2}, {1.2,
1.4}, {1.2, 1.6}, {1.2, 1.8}, {1.2, 2.}, {1.4, 0.2}, {1.4,
0.4}, {1.4, 0.6}, {1.4, 0.8}, {1.4, 1.}, {1.4, 1.2}, {1.4,
1.4}, {1.4, 1.6}, {1.4, 1.8}, {1.4, 2.}, {1.6, 0.2}, {1.6,
0.4}, {1.6, 0.6}, {1.6, 0.8}, {1.6, 1.}, {1.6, 1.2}, {1.6,
1.4}, {1.6, 1.6}, {1.6, 1.8}, {1.6, 2.}, {1.8, 0.2}, {1.8,
0.4}, {1.8, 0.6}, {1.8, 0.8}, {1.8, 1.}, {1.8, 1.2}, {1.8,
1.4}, {1.8, 1.6}, {1.8, 1.8}, {1.8, 2.}, {2., 0.2}, {2.,
0.4}, {2., 0.6}, {2., 0.8}, {2., 1.}, {2., 1.2}, {2., 1.4}, {2.,
1.6}, {2., 1.8}, {2., 2.}};
vector = pnts1 + gradientf @@@ pnts1;
ListPlot(vector)
``````