[docs] Document Epsilon alongside its source code
86
docs/architecture.svg
Normal file
@@ -0,0 +1,86 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="567.7" height="580.6" viewBox="50 50 450 480">
|
||||
<style>
|
||||
.st0{fill:#fff}.st1{fill:none}.st2{font-family:'SourceSansPro-Regular'}.st3{font-size:12px}.st4{fill:#f2f2f2}.st5{font-family:'SourceSansPro-Light'}.st6{font-size:21px}.st7,.st8{fill:none;stroke:#ffb734;stroke-width:.8;stroke-miterlimit:10}.st8{stroke-dasharray:1.9446,1.9446}.st9{fill:#ffb734}.st10,.st11{stroke-width:.8022}.st10{fill:none;stroke:#ffb734;stroke-miterlimit:10}.st11{stroke-dasharray:1.9487,1.9487}.st11,.st12,.st13,.st14{fill:none;stroke:#ffb734;stroke-miterlimit:10}.st12{stroke-width:.8022;stroke-dasharray:1.9998,1.9998}.st13,.st14{stroke-dasharray:2,2}.st14{stroke-width:.8}
|
||||
</style>
|
||||
<image width="148" height="80" xlink:href="C75050B38B4C690E.png" transform="translate(203.01 80.843)" overflow="visible" opacity=".1"/>
|
||||
<path class="st0" d="M202.6 81h141.9v73.3H202.6z"/>
|
||||
<path class="st1" d="M220 126.3h116v23.8H220z"/>
|
||||
<text transform="translate(220.012 134.867)" class="st2 st3">
|
||||
Calculation, Graph, ...
|
||||
</text>
|
||||
<path class="st4" d="M202.6 81h141.9v31.7H202.6z"/>
|
||||
<path class="st1" d="M220 90.1h116v15.4H220z"/>
|
||||
<text transform="translate(220.012 105.23)" class="st5 st6">
|
||||
APPS
|
||||
</text>
|
||||
<image width="126" height="78" xlink:href="C75050B38B4C690D.png" transform="translate(82.22 203.054)" overflow="visible" opacity=".1"/>
|
||||
<path class="st0" d="M82.3 203h119.6v71.8H82.3z"/>
|
||||
<path class="st1" d="M98.4 248.3h66.3v23.3H98.4z"/>
|
||||
<text transform="translate(98.372 256.867)" class="st2 st3">
|
||||
GUI Toolkit
|
||||
</text>
|
||||
<path class="st4" d="M82.3 203h119.6v31.7H82.3z"/>
|
||||
<path class="st1" d="M98.4 212.1h66.3v19.3H98.4z"/>
|
||||
<text transform="translate(98.372 227.228)" class="st5 st6">
|
||||
Esher
|
||||
</text>
|
||||
<image width="129" height="77" xlink:href="C75050B38B4C690A.png" transform="translate(80.824 316.754)" overflow="visible" opacity=".1"/>
|
||||
<path class="st0" d="M81 316.6h123v71.2H81z"/>
|
||||
<path class="st1" d="M98.4 361.9H204v16.3H98.4z"/>
|
||||
<text transform="translate(98.372 370.486)" class="st2 st3">
|
||||
Graphics engine
|
||||
</text>
|
||||
<path class="st4" d="M81 316.6h123v31.7H81z"/>
|
||||
<path class="st1" d="M98.4 325.7H204V345H98.4z"/>
|
||||
<text transform="translate(98.372 340.848)" class="st5 st6">
|
||||
Kandinsky
|
||||
</text>
|
||||
<image width="176" height="78" xlink:href="C75050B38B4C6905.png" transform="translate(190.822 428.656)" overflow="visible" opacity=".1"/>
|
||||
<path class="st0" d="M190.3 428h169.5v71.6H190.3z"/>
|
||||
<path class="st1" d="M207.6 473.3h147.3v20.5H207.6z"/>
|
||||
<text transform="translate(207.647 481.86)" class="st2 st3">
|
||||
Hardware abstraction Layer
|
||||
</text>
|
||||
<path class="st4" d="M190.3 428h169.5v31.7H190.3z"/>
|
||||
<path class="st1" d="M207.6 437.1h147.3v19.3H207.6z"/>
|
||||
<text transform="translate(207.647 452.222)" class="st5 st6">
|
||||
Ion
|
||||
</text>
|
||||
<image width="147" height="78" xlink:href="C75050B38B4C6907.png" transform="translate(346.237 203.338)" overflow="visible" opacity=".1"/>
|
||||
<path class="st0" d="M346.3 203h140.4v71.8H346.3z"/>
|
||||
<path class="st1" d="M363.7 248.3h112.1v20.5H363.7z"/>
|
||||
<text transform="translate(363.725 256.867)" class="st2 st3">
|
||||
Mathematical Engine
|
||||
</text>
|
||||
<path class="st4" d="M346.3 203h140.4v31.7H346.3z"/>
|
||||
<path class="st1" d="M363.7 212.1h112.1v19.3H363.7z"/>
|
||||
<text transform="translate(363.725 227.228)" class="st5 st6">
|
||||
Poincare
|
||||
</text>
|
||||
<g>
|
||||
<path class="st7" d="M195 157.2l-.9.3"/>
|
||||
<path class="st8" d="M192.3 158.3c-6 2.8-20.4 11.8-26.6 35.4"/>
|
||||
<path class="st7" d="M165.4 194.7c-.1.3-.2.6-.2 1"/>
|
||||
<path class="st9" d="M162.7 192.3l.7-.4 1.9 3.5 3.3-2.1.5.6-4.1 2.6z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st10" d="M354.9 157.2l.9.3"/>
|
||||
<path class="st11" d="M357.7 158.3c6 2.8 20.5 11.8 26.8 35.4"/>
|
||||
<path class="st10" d="M384.6 194.7c.1.3.2.6.2 1"/>
|
||||
<path class="st9" d="M381 193.9l.4-.6 3.4 2.1 1.8-3.5.7.3-2.2 4.3z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st10" d="M207.9 281.2s.3.2.7.7"/>
|
||||
<path class="st12" d="M210.1 283.2c11.3 10.6 62.3 62.3 64.8 136.7"/>
|
||||
<path class="st10" d="M275 421v1"/>
|
||||
<path class="st9" d="M271.6 419.4l.6-.5 2.8 2.8 2.5-3 .6.5-3.1 3.6z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st13" d="M141.8 281.2v28"/>
|
||||
<path class="st9" d="M138.6 306.6l.5-.5 2.7 2.9 2.7-2.9.6.5-3.3 3.6z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st14" d="M141.8 394.8l44.2 32.7"/>
|
||||
<path class="st9" d="M181.9 428.5l-.1-.8 3.9-.4-.7-3.9.8-.1.9 4.7z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
98
docs/index.md
Normal file
@@ -0,0 +1,98 @@
|
||||
---
|
||||
title: Software Engineering
|
||||
layout: breadcrumb
|
||||
breadcrumb: Software
|
||||
---
|
||||
# Epsilon
|
||||
|
||||
Epsilon is a high-performance graphing calculator operating system. It includes eight apps that cover the high school mathematics curriculum.
|
||||
|
||||
## Build your own version of Epsilon
|
||||
|
||||
First of all, you should learn [how to build and run](build/) your very own version of Epsilon. Note that you don't need an actual NumWorks calculator to do this. Indeed, Epsilon can be compiled as a standalone application that will run on your computer.
|
||||
|
||||
## Discover Epsilon's architecture
|
||||
|
||||
Epsilon's code is comprehensive, as it goes from a keyboard driver up to a math engine. Epsilon is made out of five main bricks: [Ion](<%= p "ion" %>), Kandinsky, [Poincaré](<%= p "poincare" %>), Escher, and Apps.
|
||||
|
||||

|
||||
|
||||
### Ion — Hardware abstraction layer
|
||||
|
||||
Ion is the underlying library that [abstracts all the hardware operations](ion/). It performs tasks such as setting the backlight intensity, configuring the LED or setting pixel colors on the screen. It also answers to questions such as "tell me which keys are pressed" and "what is the battery voltage?".
|
||||
|
||||
### Kandinsky — Graphics engine
|
||||
|
||||
That library is in charge of doing all the drawing. It performs functions such as "draw that text at this location" or "fill that rectangle in blue".
|
||||
|
||||
### Escher — GUI toolkit
|
||||
|
||||
Escher is our GUI toolkit. It provides functionalities such as "draw a button" or "place three tabs named Foo, Bar and Baz". It asks Ion for events and uses Kandinsky to do draw the actual user interface.
|
||||
|
||||
### Poincare — Mathematics engine
|
||||
|
||||
Poincare is in charge of parsing, laying out and evaluating mathematical expressions. You feed it some text such as `sin(root(2/3,3))` and it will draw the expression as in a text book and tell you that this expression is approximatively equal to 0.01524.
|
||||
|
||||
### Apps — Applications
|
||||
|
||||
Last but not least, each app makes heavy use of both Escher and Poincare to display a nice user interface and to perform mathematical computation.
|
||||
|
||||
## Read our coding guidelines
|
||||
|
||||
We're listing here all the topics you should be familiar with before being able to efficiently contribute to the project. Those are not hard requirements, but we believe it would be more efficient if you got familiar with the following concepts.</p>
|
||||
|
||||
### Using C++
|
||||
|
||||
The choice of a programming language is a controversial topic. Not all of them can be used to write an operating system, but quite a few can. We settled on C++ for several reasons:
|
||||
|
||||
- It is a [system](https://en.wikipedia.org/wiki/System_programming_language) programming language, which is something we need since we have to write some low-level code.
|
||||
- It has excellent tooling: several extremly high-quality compilers
|
||||
- It is used for several high-profile projects LLVM, WebKit, MySQL, Photoshop, etc... This ensures a strong ecosystem of tools, code and documentation.
|
||||
- It easily allows Object-Oriented Programming, which is a convenient abstraction.
|
||||
|
||||
|
||||
Of course knowing a tool means knowing its limits. C++ isn't exempt of defaults:</p>
|
||||
- It *is* a complicated language. The C++ 11 specification is 1300 pages long.
|
||||
- It allows for a lot of abstractions, which is a double-edged sword. It can allow for some very tricky code, and it's very easy to have complex operations being run without noticing.
|
||||
|
||||
If you want to contribute to Epsilon, you'll need to learn some C++.
|
||||
|
||||
### Working with limited memory
|
||||
|
||||
Our device has 256 KB of RAM. That's very little memory by today's standards. That being said, by writing code carefuly, a huge lot can be achieved in that space. After all, that's 64 times more memory than the computer of the Apollo mission!
|
||||
|
||||
#### Stack memory
|
||||
|
||||
The stack memory is possibly the most used area of memory. It contains all local variables, and keeps track of the context of code execution. It can be overflowed in case of nested function calls if the reserved space is too small. We booked 32KB for the stack.
|
||||
|
||||
#### Heap memory
|
||||
|
||||
Unfortunately, local variables can't answer all use cases, and sometimes one need to allocate memory that lives longer than a function call. This is traditionally done by using a pair of *malloc* / *free* functions.
|
||||
|
||||
This raises a lot of potential problems that can trigger unpredictable dynamic behaviors:
|
||||
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Memory leaks</dt>
|
||||
<dd class="text-justify">If one forgets to free memory that is no longer used, the system will eventually run out of available memory.</dd>
|
||||
<dt>Memory fragmentation</dt>
|
||||
<dd class="text-justify">Memory allocation has to be contiguous. So the allocation algorithm has to use a smart heuristic to ensure that it will not fragment its allocated space too much.</dd>
|
||||
</dl>
|
||||
|
||||
Some automatic memory management solutions do exist (garbage collection, smart pointers), but they all come with a cost. We decided to manually manage dynamic memory, but to use it as sparingly as possible.
|
||||
|
||||
### Writing code that runs on the bare metal
|
||||
|
||||
Unlike code that runs inside of an operating system (pretty much everything these days), an embedded firmware doesn't make use of virtual memory.
|
||||
|
||||
In practice, this means that the firmware will need to know in advance how the memory space is laid out. In other words, it will need to answer those questions:
|
||||
|
||||
- Where will the stack be located in memory?
|
||||
- What about the heap and global variables?
|
||||
- Where will we store read-only variables?
|
||||
- Where will the code live in memory?
|
||||
|
||||
The firmware will also need to take special care of the system initialization. There is no such thing as a "main" function on a firmware. Instead, on Cortex-M4 devices, after reset the CPU simply jumps to the address contained at address 0x00000000 (which happens to be the first bytes of flash memory). So if your firmware starts by 0x12345678, code execution will start at address 0x12345678.
|
||||
|
||||
Enforcing such a careful memory layout would be an impossible job without the proper tool. Fortunately, embedded linkers can be scripted and allow this kind of tailor-made configuration. You'll find Epsilon's linker script in "ion/src/device/boot/flash.ld" - it is heavily commented and should be self-explanatory.
|
||||
|
||||
That being said, there are additional things the OS usually takes care of which we need to do ourselves : for example, initialize global variables to zero. This is done in the "ion/src/device/boot/rt0.cpp" file, which is worth reading too.
|
||||
40
docs/ion/index.md
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
title: Ion — Firmware architecture — Software Engineering
|
||||
layout: breadcrumb
|
||||
breadcrumb: Ion
|
||||
---
|
||||
# Ion
|
||||
|
||||
## Overview
|
||||
|
||||
Ion is a library of functions that abstract interacting with the hardware. For example, Ion exposes calls such as `serialNumber()` and `LED::setColor()`. Code in Epsilon always uses Ion functions to perform operations that deal directly with the hardware — be it reading a key, setting a pixel on the screen or setting the color of the LED.
|
||||
|
||||
By providing multiple implementations of the Ion functions, we therefore can get Epsilon to run on multiple platforms. For example, we have an implementation of `Display::pushRect()` that knows how to drive the LCD panel of an actual calculator, and another implementation of the same `Display::pushRect()` function that knows how do display content in a web browser. This way, the rest of the Epsilon code can run unmodified either on a calculator or a web browser.
|
||||
|
||||
## Device
|
||||
|
||||
This is the reference platform corresponding to the actual device. To really understand what the code is doing, you'll need to refer to our <a href="../../../hardware/electrical/">Electrical Engineering</a> pages. Among other thing, Ion is responsible for handling the boot process and the memory layout of the code on the device:
|
||||
|
||||
### Boot
|
||||
|
||||
On boot, the Cortex core interprets the beginning of Flash memory as an array of addresses, each having a specific meaning. For example, the first value gives the address of the stack and the second one the address the processor jumps to right after reset. This list of addresses is called the <a href="https://github.com/numworks/epsilon/blob/master/ion/src/device/boot/isr.c">ISR table</a>.
|
||||
|
||||
### Memory layout
|
||||
|
||||
Like we saw in the previous paragraph, the MCU has a specific memory layout (for example, Flash starts at address 0x08000000) and expects certain values at certain addresses. To ensure the firmware is laid out in memory exactly how the processor expects it, we use a custom <a href="https://github.com/numworks/epsilon/blob/master/ion/src/device/boot/flash.ld">linker script</a>.
|
||||
|
||||
## Simulator
|
||||
|
||||
The simulator platform implements Ion calls using the <a href="http://www.fltk.org/">FLTK</a> library. The result is a native GUI program that can run under a variety of operating systems such as Windows, macOS or most Linux distributions.
|
||||
|
||||
It's very practical to code using the simulator, but one has to pay attention to the differences from an actual device: it'll be significantly faster, and will have a lot more memory. So code written using the simulator should always be thoroughly tested on an actual device.
|
||||
|
||||
## Emscripten
|
||||
|
||||
The emscripten platform implements Ion calls for a Web browser. This lets us build a version of Epsilon that can run directly in a browser, as shown in our <a href="/simulator/">online simulator</a>. The C++ code is transpiled to JavaScript using Emscripten, and then packaged in a webpage.
|
||||
|
||||
Building on Emscripten takes quite a lot of time so you will most likely not want to use it for development purposes. But obviously it's a very neat feature for end users who can give the calculator a spin straight from their browser.
|
||||
|
||||
## Blackbox
|
||||
|
||||
The blackbox platform may seem odd at first sight because it implements most Ion calls doing nothing. In practice, a blackbox build results in an executable that runs on a regular PC but does virtually no I/O. It is in fact very useful for measuring and instrumenting the code. We use it for fuzzing and running the test suite.
|
||||
46
docs/poincare/baseline.svg
Normal file
@@ -0,0 +1,46 @@
|
||||
<svg id="Calque_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 248 205">
|
||||
<style>
|
||||
.st0{fill:none;stroke:#000;stroke-width:.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}.st1{fill:#f2f2f2}.st2{fill:gray}.st3{fill:#ccc}.st4{fill:#fff}.st5{fill:none;stroke:#ffb734;stroke-miterlimit:10}.st6{fill:#ffb734}.st7{fill:none;stroke:#ffb734;stroke-linecap:round;stroke-linejoin:round}.st8,.st9{fill:none;stroke:gray;stroke-width:3;stroke-miterlimit:10}.st9{stroke:#000;stroke-width:2}.st10{fill:none;stroke:#a3b3ce;stroke-linecap:round;stroke-linejoin:round}.st11{fill:#a3b3ce}.st12,.st13{stroke-miterlimit:10}.st12{fill:none;stroke-linecap:square;stroke:#ffb734}.st13{stroke:#000}.st13,.st14{fill:none}.st15{font-family:'SourceSansPro-Light'}.st16{font-size:36.6915px}.st17{fill:none;stroke:#000;stroke-width:2;stroke-miterlimit:10;stroke-dasharray:4,2}
|
||||
</style>
|
||||
<path class="st0" d="M29 75.9h55.9V158H29zM139.9 27.9H243v174.7H139.9z"/>
|
||||
<path class="st12" d="M29 77v39.8"/>
|
||||
<path class="st6" d="M24.9 80.3l.7.7 3.4-3.6 3.3 3.6.8-.7-4.1-4.4zM24.9 113.5l.7-.7 3.4 3.6 3.3-3.6.8.7-4.1 4.4z"/>
|
||||
<path class="st14" d="M48.2 122.2h31.4v33.3H48.2z"/>
|
||||
<text transform="translate(48.187 148.54)" class="st15 st16">
|
||||
2
|
||||
</text>
|
||||
<path class="st14" d="M48.2 80.2h31.4v33.3H48.2z"/>
|
||||
<text transform="translate(48.187 106.606)" class="st15 st16">
|
||||
1
|
||||
</text>
|
||||
<path class="st14" d="M100.6 101.2H132v33.3h-31.4z"/>
|
||||
<text transform="translate(100.603 127.573)" class="st15 st16">
|
||||
+
|
||||
</text>
|
||||
<path class="st13" d="M39.4 117h36.7M153 117h76.9"/>
|
||||
<path class="st6" d="M114.3 7.8h2.6c2 0 3.2.7 3.2 2.4 0 1-.6 1.8-1.7 2.1v.1c1.4.2 2.3 1 2.3 2.3 0 1.9-1.4 2.8-3.6 2.8h-2.8V7.8zm2.3 4.3c2 0 2.8-.6 2.8-1.9 0-1.2-.9-1.8-2.7-1.8H115v3.7h1.6zm.3 4.9c1.9 0 3.1-.7 3.1-2.3 0-1.4-1.1-2.1-3.1-2.1h-2V17h2zM126.8 13.1c0-1.1-.3-2.2-1.7-2.2-1 0-1.8.5-2.3.8l-.3-.5c.5-.4 1.5-.9 2.6-.9 1.7 0 2.2 1.2 2.2 2.7v4.5h-.5l-.1-.9c-.7.6-1.6 1.1-2.5 1.1-1.1 0-2.1-.6-2.1-1.9.2-1.6 1.6-2.4 4.7-2.7zm-2.4 4c.8 0 1.5-.4 2.4-1.1v-2.4c-2.9.3-3.9 1-3.9 2.1.1 1 .7 1.4 1.5 1.4zM129.5 16.2c.6.5 1.2.9 2.3.9 1.1 0 1.7-.6 1.7-1.4 0-.9-.9-1.3-1.7-1.6-1.1-.4-2.2-.8-2.2-2 0-1 .8-1.9 2.3-1.9.7 0 1.5.3 2 .7l-.4.5c-.5-.4-1-.6-1.7-.6-1.1 0-1.6.6-1.6 1.3 0 .8.8 1.1 1.7 1.4 1.1.4 2.3.8 2.3 2.2 0 1.1-.9 2-2.4 2-1 0-2-.4-2.6-1l.3-.5zM138.5 10.3c1.7 0 2.7 1.2 2.7 3.3v.5H136c0 1.8 1.1 3.1 2.7 3.1.8 0 1.4-.2 1.9-.6l.3.5c-.6.3-1.2.7-2.2.7-1.8 0-3.3-1.4-3.3-3.7s1.5-3.8 3.1-3.8zm2 3.3c0-1.8-.8-2.7-2.1-2.7-1.2 0-2.3 1-2.4 2.7h4.5zM143.1 6.9h.6v9.7c0 .3.1.5.3.5h.3l.1.5c-.1 0-.3.1-.5.1-.6 0-.9-.4-.9-1.1V6.9zM146.3 8.2c0-.4.3-.6.6-.6s.6.2.6.6c0 .3-.3.6-.6.6s-.6-.3-.6-.6zm.3 2.3h.6v7.1h-.6v-7.1zM149.9 10.5h.6l.1 1.1c.7-.7 1.5-1.3 2.4-1.3 1.5 0 2.1.9 2.1 2.7v4.5h-.6v-4.4c0-1.5-.5-2.2-1.6-2.2-.8 0-1.4.4-2.3 1.3v5.3h-.6v-7zM160.2 10.3c1.7 0 2.7 1.2 2.7 3.3v.5h-5.1c0 1.8 1.1 3.1 2.7 3.1.8 0 1.4-.2 1.9-.6l.3.5c-.6.3-1.2.7-2.2.7-1.8 0-3.3-1.4-3.3-3.7s1.5-3.8 3-3.8zm2.1 3.3c0-1.8-.8-2.7-2.1-2.7-1.2 0-2.3 1-2.4 2.7h4.5zM4.3 53.8h2.6c2 0 3.2.7 3.2 2.4 0 1-.6 1.8-1.7 2.1v.1c1.4.2 2.3 1 2.3 2.3 0 1.9-1.4 2.8-3.6 2.8H4.3v-9.7zm2.3 4.3c2 0 2.8-.6 2.8-1.9 0-1.2-.9-1.8-2.7-1.8H4.9v3.7h1.7zm.3 4.9c1.9 0 3.1-.7 3.1-2.3 0-1.4-1.1-2.1-3.1-2.1h-2V63h2zM16.8 59.1c0-1.1-.3-2.2-1.7-2.2-1 0-1.8.5-2.3.8l-.3-.5c.5-.4 1.5-.9 2.6-.9 1.7 0 2.2 1.2 2.2 2.7v4.5h-.5l-.1-.9c-.7.6-1.6 1.1-2.5 1.1-1.1 0-2.1-.6-2.1-1.9.2-1.6 1.6-2.4 4.7-2.7zm-2.4 4c.8 0 1.5-.4 2.4-1.1v-2.4c-2.9.3-3.9 1-3.9 2.1.1 1 .7 1.4 1.5 1.4zM19.5 62.2c.6.5 1.2.9 2.3.9 1.1 0 1.7-.6 1.7-1.4 0-.9-.9-1.3-1.7-1.6-1.1-.4-2.2-.8-2.2-2 0-1 .8-1.9 2.3-1.9.7 0 1.5.3 2 .7l-.4.5c-.5-.4-1-.6-1.7-.6-1.1 0-1.6.6-1.6 1.3 0 .8.8 1.1 1.7 1.4 1.1.4 2.3.8 2.3 2.2 0 1.1-.9 2-2.4 2-1 0-2-.4-2.6-1l.3-.5zM28.5 56.3c1.7 0 2.7 1.2 2.7 3.3v.5H26c0 1.8 1.1 3.1 2.7 3.1.8 0 1.4-.2 1.9-.6l.3.5c-.6.3-1.2.7-2.2.7-1.8 0-3.3-1.4-3.3-3.7s1.5-3.8 3.1-3.8zm2 3.3c0-1.8-.8-2.7-2.1-2.7-1.2 0-2.3 1-2.4 2.7h4.5zM33.1 52.9h.6v9.7c0 .3.1.5.3.5h.3l.1.5c-.1 0-.3.1-.5.1-.6 0-.9-.4-.9-1.1v-9.7zM36.3 54.2c0-.4.3-.6.6-.6s.6.2.6.6c0 .3-.3.6-.6.6s-.6-.3-.6-.6zm.3 2.3h.6v7.1h-.6v-7.1zM39.9 56.5h.6l.1 1.1c.7-.7 1.5-1.3 2.4-1.3 1.5 0 2.1.9 2.1 2.7v4.5h-.6v-4.4c0-1.5-.5-2.2-1.6-2.2-.8 0-1.4.4-2.3 1.3v5.3H40v-7zM50.2 56.3c1.7 0 2.7 1.2 2.7 3.3v.5h-5.1c0 1.8 1.1 3.1 2.7 3.1.8 0 1.4-.2 1.9-.6l.3.5c-.6.3-1.2.7-2.2.7-1.8 0-3.3-1.4-3.3-3.7s1.5-3.8 3-3.8zm2.1 3.3c0-1.8-.8-2.7-2.1-2.7-1.2 0-2.3 1-2.4 2.7h4.5z"/>
|
||||
<path class="st14" d="M182.7 78.5h31.4v33.3h-31.4z"/>
|
||||
<text transform="translate(182.722 104.859)" class="st15 st16">
|
||||
2
|
||||
</text>
|
||||
<path class="st14" d="M182.7 36.5h31.4v33.3h-31.4z"/>
|
||||
<text transform="translate(182.722 62.926)" class="st15 st16">
|
||||
1
|
||||
</text>
|
||||
<path class="st13" d="M172.2 73.3h36.7"/>
|
||||
<path class="st14" d="M182.7 167.6h31.4v33.3h-31.4z"/>
|
||||
<text transform="translate(182.722 193.967)" class="st15 st16">
|
||||
4
|
||||
</text>
|
||||
<path class="st14" d="M182.7 125.7h31.4V159h-31.4z"/>
|
||||
<text transform="translate(182.722 152.034)" class="st15 st16">
|
||||
3
|
||||
</text>
|
||||
<path class="st13" d="M172.2 162.4h36.7"/>
|
||||
<path class="st12" d="M23.7 75.9h10.5M22.9 117h12.2"/>
|
||||
<g>
|
||||
<path class="st12" d="M139.9 28.1v88.7"/>
|
||||
<path class="st6" d="M135.8 31.4l.8.7 3.3-3.6 3.4 3.6.7-.7-4.1-4.4zM135.8 113.5l.8-.7 3.3 3.6 3.4-3.6.7.7-4.1 4.3z"/>
|
||||
</g>
|
||||
<path class="st12" d="M134.7 27.9h10.5M133.8 117H146"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.3 KiB |
103
docs/poincare/beautify.svg
Normal file
@@ -0,0 +1,103 @@
|
||||
<svg id="Calque_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 361">
|
||||
<style>
|
||||
.st0{fill:none;stroke:#000;stroke-width:.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}.st1{fill:#f2f2f2}.st2{fill:gray}.st3{fill:#ccc}.st4{fill:#fff}.st5{fill:none;stroke:#ffb734;stroke-miterlimit:10}.st6{fill:#ffb734}.st7{fill:none;stroke:#ffb734;stroke-linecap:round;stroke-linejoin:round}.st8{stroke:gray;stroke-width:3;stroke-miterlimit:10}.st8,.st9{fill:none}.st10{font-family:'SourceSansPro-Light'}.st11{font-size:21px}.st12{font-family:'SourceSansPro-Regular'}.st13{font-size:20px}.st14{font-family:'SourceCodePro-Medium'}.st15{font-size:18px}.st16{fill:none;stroke:#000;stroke-width:2;stroke-miterlimit:10}.st17{fill:none;stroke:#a3b3ce;stroke-linecap:round;stroke-linejoin:round}.st18{fill:#a3b3ce}.st19,.st20,.st21{fill:none;stroke-miterlimit:10}.st19{stroke-linecap:square;stroke:#ffb734}.st20,.st21{stroke:#000}.st21{stroke-width:2;stroke-dasharray:4,2}
|
||||
</style>
|
||||
<path class="st1" d="M190 181.8h140.4V247H190z"/>
|
||||
<path class="st3" d="M190 181.8h140.4v31.7H190z"/>
|
||||
<path class="st9" d="M190 190h140v19.3H190z"/>
|
||||
<text transform="translate(201.422 205.061)" class="st10 st11">
|
||||
Multiplication
|
||||
</text>
|
||||
<path class="st2" d="M0 0h392.5v33.5H0z"/>
|
||||
<path class="st1" d="M106 68.8h95V133h-95z"/>
|
||||
<path class="st3" d="M106 68.8h95v31.7h-95z"/>
|
||||
<path class="st9" d="M83 77h142v15.4H83z"/>
|
||||
<text transform="translate(117.765 92.062)" class="st10 st11">
|
||||
Addition
|
||||
</text>
|
||||
<path class="st1" d="M0 180.8h90V246H0z"/>
|
||||
<path class="st9" d="M-16 223.2h123v23.3H-16z"/>
|
||||
<text transform="translate(40.53 237.395)" class="st12 st13">
|
||||
1
|
||||
</text>
|
||||
<path class="st3" d="M0 180.8h90v31.7H0z"/>
|
||||
<path class="st9" d="M-16 190h121v19H-16z"/>
|
||||
<text transform="translate(8.77 205.061)" class="st10 st11">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M129 294.8h90V360h-90z"/>
|
||||
<path class="st9" d="M113 337.2h123v23.3H113z"/>
|
||||
<text transform="translate(166.42 351.396)" class="st12 st13">
|
||||
-1
|
||||
</text>
|
||||
<path class="st3" d="M129 294.8h90v31.7h-90z"/>
|
||||
<path class="st9" d="M113 304h121v19H113z"/>
|
||||
<text transform="translate(137.77 319.061)" class="st10 st11">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st9" d="M0 10h393v19H0z"/>
|
||||
<text transform="translate(131.701 22.725)" class="st4 st14 st15">
|
||||
1 + (-1) × π
|
||||
</text>
|
||||
<path class="st2" d="M570 0h392.5v33.5H570z"/>
|
||||
<path class="st9" d="M570 11h385v19H570z"/>
|
||||
<text transform="translate(735.5 23.725)" class="st4 st14 st15">
|
||||
1 - π
|
||||
</text>
|
||||
<path class="st1" d="M302 295.8h90V361h-90z"/>
|
||||
<path class="st9" d="M302 337.2h89v23.3h-89z"/>
|
||||
<text transform="translate(340.89 351.395)" class="st12 st13">
|
||||
π
|
||||
</text>
|
||||
<path class="st3" d="M302 295.8h90v31.7h-90z"/>
|
||||
<path class="st9" d="M286 305h121v19H286z"/>
|
||||
<text transform="translate(314.108 320.061)" class="st10 st11">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st5" d="M172.5 118.5l74 54.7"/>
|
||||
<path class="st6" d="M241.4 174.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st5" d="M279.5 228.5l78 57.7"/>
|
||||
<path class="st6" d="M352.4 287.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st5" d="M127.5 118.5l-69.8 52.7"/>
|
||||
<path class="st6" d="M57.9 165.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st5" d="M239.5 228.5l-77.8 58.7"/>
|
||||
<path class="st6" d="M161.9 281.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st1" d="M711 68.8h117V134H711z"/>
|
||||
<path class="st3" d="M711 68.8h117v31.7H711z"/>
|
||||
<path class="st9" d="M711 78h117v19H711z"/>
|
||||
<text transform="translate(719.321 93.061)" class="st10 st11">
|
||||
Subtraction
|
||||
</text>
|
||||
<path class="st1" d="M570 181.8h90V247h-90z"/>
|
||||
<path class="st9" d="M570 224.2h90v23.3h-90z"/>
|
||||
<text transform="translate(610.03 238.395)" class="st12 st13">
|
||||
1
|
||||
</text>
|
||||
<path class="st3" d="M570 181.8h90v31.7h-90z"/>
|
||||
<path class="st9" d="M570 191h90v19h-90z"/>
|
||||
<text transform="translate(579.269 206.061)" class="st10 st11">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M870 181.8h90V247h-90z"/>
|
||||
<path class="st9" d="M872 223.2h90v23.3h-90z"/>
|
||||
<text transform="translate(911.39 237.395)" class="st12 st13">
|
||||
π
|
||||
</text>
|
||||
<path class="st3" d="M870 181.8h90v31.7h-90z"/>
|
||||
<path class="st9" d="M870 191h90v19h-90z"/>
|
||||
<text transform="translate(882.608 206.061)" class="st10 st11">
|
||||
Symbol
|
||||
</text>
|
||||
<g>
|
||||
<path class="st7" d="M786.5 117.5l74 54.7"/>
|
||||
<path class="st6" d="M855.4 173.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st7" d="M744.5 117.5l-72.8 54.7"/>
|
||||
<path class="st6" d="M671.9 166.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st8" d="M425 19.5h119.6"/>
|
||||
<path class="st2" d="M538.6 24.6l5.1-5.1-5.1-5.1h4.3l5.1 5.1-5.1 5.1z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
64
docs/poincare/expression_tree.svg
Normal file
@@ -0,0 +1,64 @@
|
||||
<svg id="Calque_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 392 359">
|
||||
<style>
|
||||
.st0{fill:none;stroke:#000;stroke-width:.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}.st1{fill:#f2f2f2}.st2{fill:gray}.st3{fill:#ccc}.st4{fill:#fff}.st5{fill:none;stroke:#ffb734;stroke-miterlimit:10}.st6{fill:#ffb734}.st7{fill:none}.st8{font-family:'SourceSansPro-Light'}.st9{font-size:21px}.st10{font-family:'SourceSansPro-Regular'}.st11{font-size:20px}.st12{font-size:48px}.st13{font-family:'SourceCodePro-Medium'}.st14{font-size:18px}.st15{fill:none;stroke:#ffb734;stroke-linecap:round;stroke-linejoin:round}.st16,.st17{fill:none;stroke:gray;stroke-width:3;stroke-miterlimit:10}.st17{stroke:#000;stroke-width:2}.st18{fill:none;stroke:#a3b3ce;stroke-linecap:round;stroke-linejoin:round}.st19{fill:#a3b3ce}.st20,.st21,.st22{fill:none;stroke-miterlimit:10}.st20{stroke-linecap:square;stroke:#ffb734}.st21,.st22{stroke:#000}.st22{stroke-width:2;stroke-dasharray:4,2}
|
||||
</style>
|
||||
<path class="st2" d="M0 0h392.5v32.5H0z"/>
|
||||
<path class="st1" d="M106 67.8h95V132h-95z"/>
|
||||
<path class="st3" d="M106 67.8h95v31.7h-95z"/>
|
||||
<path class="st7" d="M83 76h142v15.4H83z"/>
|
||||
<text transform="translate(117.765 91.062)" class="st8 st9">
|
||||
Addition
|
||||
</text>
|
||||
<path class="st1" d="M0 179.8h90V245H0z"/>
|
||||
<path class="st7" d="M0 222.2h90v23.3H0z"/>
|
||||
<text transform="translate(40.03 236.395)" class="st10 st11">
|
||||
1
|
||||
</text>
|
||||
<path class="st3" d="M0 179.8h90v31.7H0z"/>
|
||||
<path class="st7" d="M0 189h90v19H0z"/>
|
||||
<text transform="translate(9.269 204.061)" class="st8 st9">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st7" d="M0 9h392v19H0z"/>
|
||||
<text transform="translate(147.4 21.725)" class="st4 st13 st14">
|
||||
1 + 2 × 3
|
||||
</text>
|
||||
<path class="st1" d="M126 294.8h90V360h-90z"/>
|
||||
<path class="st7" d="M126 336.2h90v23.3h-90z"/>
|
||||
<text transform="translate(166.03 350.396)" class="st10 st11">
|
||||
2
|
||||
</text>
|
||||
<path class="st3" d="M126 294.8h90v31.7h-90z"/>
|
||||
<path class="st7" d="M126 304h90v19h-90z"/>
|
||||
<text transform="translate(135.269 319.061)" class="st8 st9">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M302 294.8h90V360h-90z"/>
|
||||
<path class="st7" d="M302 336.2h90v23.3h-90z"/>
|
||||
<text transform="translate(342.03 350.396)" class="st10 st11">
|
||||
3
|
||||
</text>
|
||||
<path class="st3" d="M302 294.8h90v31.7h-90z"/>
|
||||
<path class="st7" d="M302 304h90v19h-90z"/>
|
||||
<text transform="translate(311.269 319.061)" class="st8 st9">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M188 179.8h140.4V245H188z"/>
|
||||
<path class="st3" d="M188 179.8h140.4v31.7H188z"/>
|
||||
<path class="st7" d="M188 188h140v19.3H188z"/>
|
||||
<text transform="translate(199.422 203.061)" class="st8 st9">
|
||||
Multiplication
|
||||
</text>
|
||||
<path class="st5" d="M167.5 112.5l78.1 57.4"/>
|
||||
<path class="st6" d="M240.5 171.2l-.1-1 4.9-.6-.9-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st5" d="M278.5 228.5l77 57.7"/>
|
||||
<path class="st6" d="M350.4 287.4l-.1-1 4.9-.5-.9-4.8 1-.2 1 5.9z"/>
|
||||
<g>
|
||||
<path class="st5" d="M136.5 112.5l-76.8 57.4"/>
|
||||
<path class="st6" d="M59.9 164.6l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st5" d="M239.5 228.5l-76.8 57.7"/>
|
||||
<path class="st6" d="M162.9 280.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
138
docs/poincare/index.md
Normal file
@@ -0,0 +1,138 @@
|
||||
---
|
||||
title: Poincare — Firmware architecture — Software Engineering
|
||||
layout: breadcrumb
|
||||
breadcrumb: Poincare
|
||||
katex: true
|
||||
---
|
||||
# Poincaré
|
||||
|
||||
## Structure
|
||||
|
||||
Poincare takes text input such as `1+2*3` and turns it into a tree structure, that can be simplified, approximated and pretty-printed.
|
||||
|
||||
Each node of a tree represents either an operator or a value. All nodes have a type (`Type::Addition`, `Type::Multiplication`...) and some also store a value (ie `Type::Rational`).
|
||||
|
||||
{:class="img-right"}
|
||||
According to their types, expressions are childless (`Type::Rational`) or store pointers to their children (we call those children operands). To ease tree traversal, each node also keeps a pointer to its parent: that information is somewhat redundant but makes dealing with the expression tree much easier. `Multiplication` and `Addition` are the only type that can hold an infinite number of operands. Other expressions have a fixed number of operands: for instance, an `AbsoluteValue` will only ever have one child.
|
||||
|
||||
## RTTI: Run-time type information
|
||||
|
||||
The type of a C++ object is used by the compiler to generate a vtable. A vtable is a lookup table that tells which function to call for a given object class, hence creating polymorphism. Once the vtable has been built, the compiler completely discards the type information of a given object.
|
||||
|
||||
The problem with vtables is that they allow polyphormism based on a single class only: you can have different code called on a Node depending on whether it's an addition or a multiplication. But vtables can't handle dynamic behavior based on two parameters. For example, if you want to call a function depending on the type of two parameters, vtables can't do that.
|
||||
|
||||
That case happens quite often in Poincare: for example, if an expression contains the addition of another addition, we can merge both nodes in a single one ($$1+(\pi+x)$$ is $$1+\pi+x$$), see figure below). And we want to implement this behavior only if both nodes are additions.
|
||||
|
||||
The C++ standard has support for keeping type information at runtime, a behavior known as RTTI. However that feature is quite comprehensive and a bit overkill for what we needed, so we decided to do an equivalent solution manually: each expression subclass implements a `type()` function to give its type.
|
||||
|
||||
{:class="img-responsive"}
|
||||
|
||||
## Expression parsing
|
||||
|
||||
Lexing and parsing are done by homemade lexer and parser available [here](https://github.com/numworks/epsilon/tree/master/poincare/src/parsing).
|
||||
|
||||
## Simplification
|
||||
|
||||
{:class="img-right"}
|
||||
Expression simplification is done in-place and modifies directly the expression. Simplifying is a two-step process: first the expression is reduced, then it is beautified. So far, we excluded matrices from the simplification process to avoid increasing complexity due to the non-commutativity of matrix multiplication.
|
||||
|
||||
### Ordering of operands
|
||||
|
||||
To simplify an expression one needs to find relevant patterns. Searching for a given pattern can be extremely long if done the wrong way. To make pattern searching much more efficient, we need to sort operands of commutative operations.
|
||||
|
||||
To sort those operands, we defined an order on expressions with the following features:
|
||||
|
||||
* The order is total on types and values: `Rational(-2/3)` < `Rational(0)` < `...` < `Multiplication` < `Power` < `Addition` < `...`
|
||||
* The order relationship is depth-first recursive: if two expressions are equal in type and values, we compare their operands starting with the last.
|
||||
* To compare two expressions, we first sort their commutative children to ensure the unicity of expression representations. This guarantees that the order is total on expressions.
|
||||
|
||||
|
||||
{:class="img-responsive"}
|
||||
In the example, both root nodes are r so we compare their last operands. Both are equal to $$\pi$$ so we compare the next operands. As 3 > 2, we can conclude on the order relation between the expressions.
|
||||
|
||||
Moreover, the simplification order has a few additional rules:
|
||||
|
||||
* Within an `Addition` or a `Multiplication`, any `Rational` is always the first operand
|
||||
* Comparing an `Addition` a with an `Expression` e is equivalent to comparing a with an `Addition` whose single operand is e. Same goes for the `Multiplication`.
|
||||
* To compare a `Power` p with an `Expression` e, we compare $$p$$ with $$e^1$$.
|
||||
|
||||
Thanks to these rules, the order groups similar terms together and thus avoid quadratic complexity when factorizing. For example, it groups expressions with same bases together (ie $$\pi$$ and $$\pi^3$$) and terms with same non-rational factors together (ie $$\pi$$ and $$2*\pi$$).
|
||||
|
||||
Last but not least, as this order is total, it makes checking if two expressions are identical very easy.
|
||||
|
||||
### Reduction
|
||||
|
||||
The reduction phase is the most important part of simplification. It happens recursively and bottom-up: we first reduce the operands of an expression before reducing the expression itself. That way, when reducing itself, an expression can assert that its operands are reduced (and thus have some very useful knowledge such as "there is no `Division` or `Subtraction` among my operands"). Every type of `Expression` has its own reduction rules.
|
||||
|
||||
To decrease the set of possible expression types in reduced expressions, we turn `Subtraction` into `Addition`, `Division` and `Root` into `Power` and so on:
|
||||
|
||||
* $$a-b \rightarrow a+(-1)*b$$
|
||||
* $$-a \rightarrow (-1)*a$$
|
||||
* $$\frac{a}{b} \rightarrow a*b^{-1}$$
|
||||
* $$\sqrt{x} \rightarrow x^{\frac{1}{2}}$$
|
||||
* $$\sqrt[y]{x} \rightarrow x^{\frac{1}{y}}$$
|
||||
* $$\ln(x) \rightarrow log_{e}(x)$$
|
||||
|
||||
{:class="img-responsive"}
|
||||
|
||||
Here is a short tour of the reduction rules for the main `Expression` subclasses:
|
||||
|
||||
#### `Additions` are reduced by common applying mathematics rules
|
||||
|
||||
* Associativity: $$(a+b)+c \rightarrow a+b+c$$
|
||||
* Commutativity: $$a+b \rightarrow b+a$$ which enables to sort operands and group like-terms together
|
||||
* Factorization: $$a+5*a \rightarrow 6*a$$
|
||||
* $$a+0 \rightarrow a$$
|
||||
* Reducing addition to the same denominator
|
||||
|
||||
#### `Multiplications` apply the following rules
|
||||
|
||||
* Associativity: $$(a*b)*c \rightarrow a*b*c$$
|
||||
* Commutativity: $$a*b \rightarrow b*a$$ (which is true because we do no reduce matrices yet)
|
||||
* Factorization: $$a*a^5 \rightarrow a^6$$
|
||||
* $$a*0 \rightarrow 0$$
|
||||
* $$\frac{sine}{cosine} \rightarrow tangent$$
|
||||
* Distribution: $$a*(b+c) \rightarrow a*b+a*c$$
|
||||
|
||||
#### `Powers` apply the following rules
|
||||
|
||||
* We get rid of square roots at denominator and of sum of 2 square roots at denominator
|
||||
* $$x^0 \rightarrow 1\;if\;x \neq 0$$
|
||||
* $$x^1 \rightarrow x$$
|
||||
* $$0^x \rightarrow 0 \;if\; x > 0$$
|
||||
* $$1^x \rightarrow 1$$
|
||||
* $$(a^b)^c \rightarrow a^{b*c} \;if\; a > 0 \;or\; c \in \mathbb{Z}$$
|
||||
* $$(a*b*c*...)^n \rightarrow a^n*b^n*c^n*... \;if\; n \in \mathbb{Z}$$
|
||||
* $$(a*b*c*...)^r \rightarrow \mid a\mid^r*(sign(a)*b*c*...)^r \;if\; a \in \mathbb{Q}$$
|
||||
* $$a^{b+c} \rightarrow (a^b)*b^c \;if\; a, b \in \mathbb{Z}$$
|
||||
* $$a^{b+c} \rightarrow (a^b)*b^c \;if\; a, b \in \mathbb{Z}$$
|
||||
* $$r^s\;with\; r, s \in \mathbb{Q}$$ can be simplified using the factorisation in primes of $$r$$ (ie, $$8^{\frac{1}{2}} \rightarrow 2*2^{\frac{1}{2}}$$)
|
||||
* $$i^{\frac{p}{q}} \rightarrow e^{\frac{i*\pi*p}{2*q}} \;with\; p, q \in \mathbb{Z}$$
|
||||
* $$e^{\frac{i*\pi*p}{q}} \rightarrow cos(\frac{\pi*p}{q})+i*sin(\frac{\pi*p}{q}) \;with\; p, q \in \mathbb{Z}$$
|
||||
* $$x^{log(y,x)} \rightarrow y \;if\;y > 0$$
|
||||
* $$10^{log(x)} \rightarrow x \;if\; x > 0$$
|
||||
|
||||
To avoid infinite loops, reduction is contextualized on the parent expression. This forces to reduce an expression only once it has been attached to its parent expression.
|
||||
|
||||
### Beautify
|
||||
|
||||
{:class="img-left"}
|
||||
This phase turns expressions in a more readable way. Divisions, subtractions, Naperian logarithms reappear at this step. Parentheses are also added to be able to print the tree in infix notation without any ambiguity. This phase is also recursive and top-down: we first beautify the node expression and then beautify its operands.
|
||||
|
||||
## Approximation
|
||||
|
||||
Expressions can be approximate thanks to the method `approximate()` which return another (dynamically allocated) expression that can be either:
|
||||
|
||||
* A complex
|
||||
* A matrix of complexes
|
||||
|
||||
To approximate an expression, we first approximate its operands (which are ensured to be either complex or matrix of complexes) and then approximate the expression depending on its type (an `Addition` add its operand approximations for example).
|
||||
|
||||
# Pretty print
|
||||
|
||||
Poincare is responsible for laying out expressions in 2D as in a text book. The `ExpressionLayout` class represents the layout on screen of an `Expression`, and can be derived from an `Expression` by calling the function `createLayout()` . `ExpressionLayout` is also a tree structure, although the layout tree does not exactly follow the expression tree
|
||||
|
||||
{:class="img-responsive"}
|
||||
|
||||
{:class="img-right"}
|
||||
The `baseline()` of `ExpressionLayout` is useful to align several layouts relatively to each other.
|
||||
135
docs/poincare/layout.svg
Normal file
@@ -0,0 +1,135 @@
|
||||
<svg id="Calque_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1006 471">
|
||||
<style>
|
||||
.st0{fill:none;stroke:#000;stroke-width:.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}.st1{fill:#f2f2f2}.st2{fill:gray}.st3{fill:#ccc}.st4{fill:#fff}.st5{fill:none;stroke:#ffb734;stroke-miterlimit:10}.st6{fill:#ffb734}.st7{fill:none;stroke:#ffb734;stroke-linecap:round;stroke-linejoin:round}.st8,.st9{stroke-miterlimit:10}.st8{fill:none;stroke:gray;stroke-width:3}.st9{stroke:#000;stroke-width:2}.st10,.st9{fill:none}.st11{font-family:'SourceCodePro-Medium'}.st12{font-size:21px}.st13{font-family:'SourceSansPro-Light'}.st14{font-family:'SourceSansPro-Regular'}.st15{font-size:20px}.st16{fill:none;stroke:#a3b3ce;stroke-linecap:round;stroke-linejoin:round}.st17{fill:#a3b3ce}.st18,.st19,.st20{fill:none;stroke-miterlimit:10}.st18{stroke-linecap:square;stroke:#ffb734}.st19,.st20{stroke:#000}.st20{stroke-width:2;stroke-dasharray:4,2}
|
||||
</style>
|
||||
<path class="st1" d="M683 179.8h113V245H683zM577 405.8h90V471h-90zM789 405.8h90V471h-90z"/>
|
||||
<path class="st9" d="M87 27.5h39.2"/>
|
||||
<path d="M122.2 30.9l3.4-3.4-3.4-3.4h2.9l3.4 3.4-3.4 3.4z"/>
|
||||
<path class="st9" d="M451 27.5h39.2"/>
|
||||
<path d="M486.2 30.9l3.4-3.4-3.4-3.4h2.9l3.4 3.4-3.4 3.4z"/>
|
||||
<path class="st9" d="M818 27.5h39.2"/>
|
||||
<path d="M853.2 30.9l3.4-3.4-3.4-3.4h2.9l3.4 3.4-3.4 3.4z"/>
|
||||
<path class="st10" d="M145 .5h248v19H145z"/>
|
||||
<text transform="translate(145 15.352)" class="st11 st12">
|
||||
Expression
|
||||
</text>
|
||||
<path class="st10" d="M0 .5h64v19H0z"/>
|
||||
<text transform="translate(0 15.352)" class="st11 st12">
|
||||
Input
|
||||
</text>
|
||||
<path class="st1" d="M238 178.8h117V244H238z"/>
|
||||
<path class="st3" d="M238 178.8h117v31.7H238z"/>
|
||||
<path class="st10" d="M240 186h114v19H240z"/>
|
||||
<text transform="translate(263.432 201.061)" class="st13 st12">
|
||||
Division
|
||||
</text>
|
||||
<path class="st1" d="M236 66.8h117V132H236z"/>
|
||||
<path class="st3" d="M236 66.8h117v31.7H236zM0 66.8h71v31.7H0zM871 66.8h87V120h-87z"/>
|
||||
<path class="st10" d="M238 74h114v19H238z"/>
|
||||
<text transform="translate(251.047 89.061)" class="st13 st12">
|
||||
Logarithm
|
||||
</text>
|
||||
<path class="st10" d="M7 74h114v19H7z"/>
|
||||
<text transform="translate(7 89.061)" class="st13 st12">
|
||||
ln(2/3)
|
||||
</text>
|
||||
<path class="st10" d="M870 .5h130v19H870z"/>
|
||||
<text transform="translate(870 15.352)" class="st11 st12">
|
||||
Rendering
|
||||
</text>
|
||||
<path d="M918.9 86.5c4.4-4.5 6.6-7 6.6-9.3 0-1.7-.9-3-2.9-3-1.2 0-2.3.8-3.1 1.8l-.6-.6c1-1.1 2.2-2 3.8-2 2.4 0 3.8 1.5 3.8 3.8 0 2.7-2.4 5.2-6.2 9.2.7 0 1.5-.1 2.2-.1h4.6v.8h-8.2v-.6zM907.8 94.4c0-8 1-14.6 2.8-20.6l.6.7c-1.7 5.7-2.5 12.7-2.5 19.9s.9 14.2 2.5 19.9l-.6.7c-1.7-6.1-2.8-12.6-2.8-20.6zM938 94.4c0-8-.9-14.6-2.5-20.6l-.5.7c1.5 5.7 2.2 12.7 2.2 19.9s-.8 14.2-2.2 19.9l.5.7c1.6-6.1 2.5-12.6 2.5-20.6zM919.2 109.8c.8.9 1.9 1.7 3.7 1.7 1.8 0 3.1-1.2 3.1-3s-1.3-3.1-4.7-3.1v-.8c3.1 0 4.2-1.3 4.2-2.9 0-1.5-1.1-2.5-2.7-2.5-1.2 0-2.3.7-3.1 1.5l-.5-.6c.9-.9 2.1-1.6 3.6-1.6 2.1 0 3.7 1.2 3.7 3.2 0 1.8-1.1 2.8-2.6 3.3v.1c1.7.4 3 1.6 3 3.5 0 2.3-1.8 3.8-4.1 3.8-2.1 0-3.4-1-4.3-1.9l.7-.7z"/>
|
||||
<path class="st1" d="M137 293.8h90V359h-90z"/>
|
||||
<path class="st10" d="M136 336.2h91v23.3h-91z"/>
|
||||
<text transform="translate(176.53 350.396)" class="st14 st15">
|
||||
2
|
||||
</text>
|
||||
<path class="st3" d="M137 293.8h90v31.7h-90z"/>
|
||||
<path class="st10" d="M121 303h121v19H121z"/>
|
||||
<text transform="translate(145.77 318.061)" class="st13 st12">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M346 293.8h90V359h-90z"/>
|
||||
<path class="st10" d="M348 336.2h90v23.3h-90z"/>
|
||||
<text transform="translate(388.03 350.396)" class="st14 st15">
|
||||
3
|
||||
</text>
|
||||
<path class="st10" d="M577 448.2h90v23.3h-90z"/>
|
||||
<text transform="translate(608.45 462.395)" class="st14 st15">
|
||||
«2»
|
||||
</text>
|
||||
<path class="st10" d="M789 448.2h90v23.3h-90z"/>
|
||||
<text transform="translate(820.45 462.395)" class="st14 st15">
|
||||
«3»
|
||||
</text>
|
||||
<path class="st3" d="M346 293.8h90v31.7h-90z"/>
|
||||
<path class="st10" d="M330 303h121v19H330z"/>
|
||||
<text transform="translate(354.77 318.061)" class="st13 st12">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st7" d="M316.5 227.5l74 54.7"/>
|
||||
<path class="st6" d="M385.4 283.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st7" d="M274.5 227.5l-72.8 54.7"/>
|
||||
<path class="st6" d="M201.9 276.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st1" d="M678 293.8h117V359H678z"/>
|
||||
<path class="st3" d="M577 405.8h90v31.7h-90z"/>
|
||||
<path class="st10" d="M561 415h121v19H561z"/>
|
||||
<text transform="translate(596.322 430.061)" class="st13 st12">
|
||||
String
|
||||
</text>
|
||||
<path class="st3" d="M789 405.8h90v31.7h-90z"/>
|
||||
<path class="st10" d="M773 415h121v19H773z"/>
|
||||
<text transform="translate(808.322 430.061)" class="st13 st12">
|
||||
String
|
||||
</text>
|
||||
<path class="st16" d="M758.5 342.5l74 54.7"/>
|
||||
<path class="st17" d="M827.4 398.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st16" d="M716.5 342.5l-72.8 54.7"/>
|
||||
<path class="st17" d="M643.9 391.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st7" d="M294.5 116v54.9"/>
|
||||
<path class="st6" d="M290.4 167.6l.7-.7 3.4 3.6 3.4-3.6.7.7-4.1 4.4z"/>
|
||||
<path class="st16" d="M739.5 227v56.9"/>
|
||||
<path class="st17" d="M735.4 280.6l.7-.7 3.4 3.6 3.4-3.6.7.7-4.1 4.4z"/>
|
||||
<path class="st10" d="M506 .5h248v19H506z"/>
|
||||
<text transform="translate(506 15.352)" class="st11 st12">
|
||||
Layout
|
||||
</text>
|
||||
<path class="st1" d="M597 66.8h117V132H597z"/>
|
||||
<path class="st3" d="M597 66.8h117v31.7H597z"/>
|
||||
<path class="st10" d="M599 74h114v19H599z"/>
|
||||
<text transform="translate(611.491 89.061)" class="st13 st12">
|
||||
Horizontal
|
||||
</text>
|
||||
<path class="st1" d="M499 179.8h90V245h-90z"/>
|
||||
<path class="st10" d="M498 222.2h91v23.3h-91z"/>
|
||||
<text transform="translate(526.9 236.395)" class="st14 st15">
|
||||
«ln»
|
||||
</text>
|
||||
<path class="st3" d="M499 179.8h90v31.7h-90z"/>
|
||||
<path class="st10" d="M483 189h121v19H483z"/>
|
||||
<text transform="translate(518.322 204.061)" class="st13 st12">
|
||||
String
|
||||
</text>
|
||||
<path class="st3" d="M683 179.8h113v31.7H683z"/>
|
||||
<path class="st10" d="M679 189h121v19H679z"/>
|
||||
<text transform="translate(689.606 204.061)" class="st13 st12">
|
||||
Parenthesis
|
||||
</text>
|
||||
<path class="st3" d="M678 293.8h117v31.7H678z"/>
|
||||
<path class="st10" d="M674 303h121v19H674z"/>
|
||||
<text transform="translate(699.326 318.061)" class="st13 st12">
|
||||
Fraction
|
||||
</text>
|
||||
<g>
|
||||
<path class="st16" d="M676.5 116.5l74 54.7"/>
|
||||
<path class="st17" d="M745.4 172.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st16" d="M634.5 116.5l-72.8 54.7"/>
|
||||
<path class="st17" d="M561.9 165.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
</g>
|
||||
<path class="st19" d="M912 94h21"/>
|
||||
<g>
|
||||
<path d="M888.4 84h.9v13.9c0 .4.2.7.4.7h.4l.2.8c-.2.1-.4.1-.7.1-.8 0-1.2-.5-1.2-1.6V84zM893.4 89h.8l.1 1.6h.1c1-1 2.1-1.8 3.5-1.8 2.1 0 3 1.3 3 3.9v6.5h-.9v-6.3c0-2.1-.7-3.1-2.3-3.1-1.2 0-2.1.6-3.3 1.9v7.6h-.9V89z"/>
|
||||
</g>
|
||||
<path class="st20" d="M0 28.2h71M871 28h135M145 28.2h291M506 28.2h300"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 7.1 KiB |
68
docs/poincare/order.svg
Normal file
@@ -0,0 +1,68 @@
|
||||
<svg id="Calque_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 808 179">
|
||||
<style>
|
||||
.st0{fill:none;stroke:#000;stroke-width:.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}.st1{fill:#f2f2f2}.st2{fill:gray}.st3{fill:#ccc}.st4{fill:#fff}.st5{fill:none;stroke:#ffb734;stroke-miterlimit:10}.st6{fill:#ffb734}.st7{stroke:#ffb734;stroke-linecap:round;stroke-linejoin:round}.st7,.st8{fill:none}.st9{font-family:'SourceSansPro-Light'}.st10{font-size:21px}.st11{font-family:'SourceSansPro-Regular'}.st12{font-size:20px}.st13,.st14{fill:none;stroke:gray;stroke-width:3;stroke-miterlimit:10}.st14{stroke:#000;stroke-width:2}.st15{fill:none;stroke:#a3b3ce;stroke-linecap:round;stroke-linejoin:round}.st16{fill:#a3b3ce}.st17,.st18,.st19{fill:none;stroke-miterlimit:10}.st17{stroke-linecap:square;stroke:#ffb734}.st18,.st19{stroke:#000}.st19{stroke-width:2;stroke-dasharray:4,2}
|
||||
</style>
|
||||
<path class="st1" d="M101 .8h117V66H101z"/>
|
||||
<path class="st3" d="M101 .8h117v31.7H101z"/>
|
||||
<path class="st8" d="M99 10h121v19H99z"/>
|
||||
<text transform="translate(123.265 25.061)" class="st9 st10">
|
||||
Addition
|
||||
</text>
|
||||
<path class="st1" d="M0 112.8h90V178H0z"/>
|
||||
<path class="st8" d="M0 155.2h90v23.3H0z"/>
|
||||
<text transform="translate(40.03 169.395)" class="st11 st12">
|
||||
3
|
||||
</text>
|
||||
<path class="st3" d="M0 112.8h90v31.7H0z"/>
|
||||
<path class="st8" d="M0 122h90v19H0z"/>
|
||||
<text transform="translate(9.269 137.061)" class="st9 st10">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M224 112.8h90V178h-90z"/>
|
||||
<path class="st8" d="M224 154.2h90v23.3h-90z"/>
|
||||
<text transform="translate(263.39 168.395)" class="st11 st12">
|
||||
π
|
||||
</text>
|
||||
<path class="st3" d="M224 112.8h90v31.7h-90z"/>
|
||||
<path class="st8" d="M224 122h90v19h-90z"/>
|
||||
<text transform="translate(236.608 137.061)" class="st9 st10">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st7" d="M181.5 49.5l74 54.7"/>
|
||||
<path class="st6" d="M250.4 105.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st7" d="M139.5 49.5l-72.8 54.7"/>
|
||||
<path class="st6" d="M66.9 98.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st1" d="M595 .8h117V66H595z"/>
|
||||
<path class="st3" d="M595 .8h117v31.7H595z"/>
|
||||
<path class="st8" d="M593 10h121v19H593z"/>
|
||||
<text transform="translate(617.265 25.061)" class="st9 st10">
|
||||
Addition
|
||||
</text>
|
||||
<path class="st1" d="M494 112.8h90V178h-90z"/>
|
||||
<path class="st8" d="M494 155.2h90v23.3h-90z"/>
|
||||
<text transform="translate(534.03 169.395)" class="st11 st12">
|
||||
2
|
||||
</text>
|
||||
<path class="st3" d="M494 112.8h90v31.7h-90z"/>
|
||||
<path class="st8" d="M478 122h121v19H478z"/>
|
||||
<text transform="translate(502.77 137.061)" class="st9 st10">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M718 112.8h90V178h-90z"/>
|
||||
<path class="st8" d="M718 154.2h90v23.3h-90z"/>
|
||||
<text transform="translate(757.39 168.395)" class="st11 st12">
|
||||
π
|
||||
</text>
|
||||
<path class="st3" d="M718 112.8h90v31.7h-90z"/>
|
||||
<path class="st8" d="M702 122h121v19H702z"/>
|
||||
<text transform="translate(730.108 137.061)" class="st9 st10">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st7" d="M675.5 49.5l74 54.7"/>
|
||||
<path class="st6" d="M744.4 105.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<g>
|
||||
<path class="st7" d="M633.5 49.5l-72.8 54.7"/>
|
||||
<path class="st6" d="M560.9 98.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
</g>
|
||||
<path class="st13" d="M386 56.5l35.5 31.4-35.1 33.6"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
147
docs/poincare/reduce.svg
Normal file
@@ -0,0 +1,147 @@
|
||||
<svg id="Calque_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 961 480">
|
||||
<style>
|
||||
.st0{fill:none;stroke:#000;stroke-width:.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}.st1{fill:#f2f2f2}.st2{fill:gray}.st3{fill:#ccc}.st4{fill:#fff}.st5{fill:none;stroke:#ffb734;stroke-miterlimit:10}.st6{fill:#ffb734}.st7{fill:none;stroke:#ffb734;stroke-linecap:round;stroke-linejoin:round}.st8{stroke:gray;stroke-width:3;stroke-miterlimit:10}.st8,.st9{fill:none}.st10{font-family:'SourceSansPro-Light'}.st11{font-size:21px}.st12{font-family:'SourceCodePro-Medium'}.st13{font-size:18px}.st14{font-family:'SourceSansPro-Regular'}.st15{font-size:20px}.st16{fill:none;stroke:#000;stroke-width:2;stroke-miterlimit:10}.st17{fill:none;stroke:#a3b3ce;stroke-linecap:round;stroke-linejoin:round}.st18{fill:#a3b3ce}.st19,.st20,.st21{fill:none;stroke-miterlimit:10}.st19{stroke-linecap:square;stroke:#ffb734}.st20,.st21{stroke:#000}.st21{stroke-width:2;stroke-dasharray:4,2}
|
||||
</style>
|
||||
<path class="st2" d="M0 0h392.5v33.5H0z"/>
|
||||
<path class="st1" d="M189 69.8h95V134h-95z"/>
|
||||
<path class="st3" d="M189 69.8h95v31.7h-95z"/>
|
||||
<path class="st9" d="M166 78h142v15.4H166z"/>
|
||||
<text transform="translate(200.765 93.062)" class="st10 st11">
|
||||
Addition
|
||||
</text>
|
||||
<path class="st1" d="M72 181.8h117V247H72z"/>
|
||||
<path class="st3" d="M72 181.8h117v31.7H72z"/>
|
||||
<path class="st9" d="M70 191h121v19H70z"/>
|
||||
<text transform="translate(80.322 206.061)" class="st10 st11">
|
||||
Subtraction
|
||||
</text>
|
||||
<path class="st9" d="M0 11h392v19H0z"/>
|
||||
<text transform="translate(152.8 23.725)" class="st4 st12 st13">
|
||||
1 - 2π+π
|
||||
</text>
|
||||
<path class="st1" d="M302 181.8h90V247h-90z"/>
|
||||
<path class="st9" d="M302 223.2h89v23.3h-89z"/>
|
||||
<text transform="translate(340.89 237.395)" class="st14 st15">
|
||||
π
|
||||
</text>
|
||||
<path class="st3" d="M302 181.8h90v31.7h-90z"/>
|
||||
<path class="st9" d="M286 191h121v19H286z"/>
|
||||
<text transform="translate(314.108 206.061)" class="st10 st11">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st1" d="M302 414.8h90V480h-90z"/>
|
||||
<path class="st9" d="M302 456.2h89v23.3h-89z"/>
|
||||
<text transform="translate(340.89 470.395)" class="st14 st15">
|
||||
π
|
||||
</text>
|
||||
<path class="st3" d="M302 414.8h90v31.7h-90z"/>
|
||||
<path class="st9" d="M286 424h121v19H286z"/>
|
||||
<text transform="translate(314.108 439.061)" class="st10 st11">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st5" d="M256.5 117.5l74 54.7"/>
|
||||
<path class="st6" d="M325.4 173.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st5" d="M150.5 229.5l78 57.7"/>
|
||||
<path class="st6" d="M223.4 288.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st5" d="M211.5 117.5l-69.8 52.7"/>
|
||||
<path class="st6" d="M141.9 164.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st5" d="M110.5 229.5l-77.8 58.7"/>
|
||||
<path class="st6" d="M32.9 282.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st1" d="M0 296.8h90V362H0z"/>
|
||||
<path class="st9" d="M0 339.2h90v23.3H0z"/>
|
||||
<text transform="translate(40.03 353.396)" class="st14 st15">
|
||||
1
|
||||
</text>
|
||||
<path class="st3" d="M0 296.8h90v31.7H0z"/>
|
||||
<path class="st9" d="M-16 306h121v19H-16z"/>
|
||||
<text transform="translate(8.77 321.061)" class="st10 st11">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M86 414.8h90V480H86z"/>
|
||||
<path class="st9" d="M86 457.2h90v23.3H86z"/>
|
||||
<text transform="translate(126.03 471.396)" class="st14 st15">
|
||||
2
|
||||
</text>
|
||||
<path class="st3" d="M86 414.8h90v31.7H86z"/>
|
||||
<path class="st9" d="M70 424h121v19H70z"/>
|
||||
<text transform="translate(94.77 439.061)" class="st10 st11">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M167 296.8h140.4V362H167z"/>
|
||||
<path class="st3" d="M167 296.8h140.4v31.7H167z"/>
|
||||
<path class="st9" d="M167 305h140v19.3H167z"/>
|
||||
<text transform="translate(178.422 320.061)" class="st10 st11">
|
||||
Multiplication
|
||||
</text>
|
||||
<path class="st1" d="M747 182.8h140.4V248H747z"/>
|
||||
<path class="st3" d="M747 182.8h140.4v31.7H747z"/>
|
||||
<path class="st9" d="M747 191h140v19.3H747z"/>
|
||||
<text transform="translate(758.422 206.061)" class="st10 st11">
|
||||
Multiplication
|
||||
</text>
|
||||
<path class="st5" d="M258.5 345.5l78 57.7"/>
|
||||
<path class="st6" d="M331.4 404.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st5" d="M214.5 345.5l-77.8 58.7"/>
|
||||
<path class="st6" d="M136.9 398.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st2" d="M559 0h402v33.5H559z"/>
|
||||
<path class="st1" d="M663 69.8h95V134h-95z"/>
|
||||
<path class="st3" d="M663 69.8h95v31.7h-95z"/>
|
||||
<path class="st9" d="M640 78h142v15.4H640z"/>
|
||||
<text transform="translate(674.765 93.062)" class="st10 st11">
|
||||
Addition
|
||||
</text>
|
||||
<path class="st1" d="M560 181.8h90V247h-90z"/>
|
||||
<path class="st9" d="M559 224.2h92v23.3h-92z"/>
|
||||
<text transform="translate(600.03 238.395)" class="st14 st15">
|
||||
1
|
||||
</text>
|
||||
<path class="st3" d="M560 181.8h90v31.7h-90z"/>
|
||||
<path class="st9" d="M544 191h121v19H544z"/>
|
||||
<text transform="translate(568.77 206.061)" class="st10 st11">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M665 295.8h90V361h-90z"/>
|
||||
<path class="st9" d="M665 338.2h90v23.3h-90z"/>
|
||||
<text transform="translate(701.92 352.396)" class="st14 st15">
|
||||
-1
|
||||
</text>
|
||||
<path class="st3" d="M665 295.8h90v31.7h-90z"/>
|
||||
<path class="st9" d="M649 305h121v19H649z"/>
|
||||
<text transform="translate(673.77 320.061)" class="st10 st11">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st9" d="M560 11h401v19H560z"/>
|
||||
<text transform="translate(695.701 23.725)" class="st4 st12 st13">
|
||||
1 + (-1) × π
|
||||
</text>
|
||||
<path class="st1" d="M872 296.8h90V362h-90z"/>
|
||||
<path class="st9" d="M872 338.2h89v23.3h-89z"/>
|
||||
<text transform="translate(910.89 352.395)" class="st14 st15">
|
||||
π
|
||||
</text>
|
||||
<path class="st3" d="M872 296.8h90v31.7h-90z"/>
|
||||
<path class="st9" d="M856 306h121v19H856z"/>
|
||||
<text transform="translate(884.108 321.061)" class="st10 st11">
|
||||
Symbol
|
||||
</text>
|
||||
<g>
|
||||
<path class="st5" d="M729.5 119.5l74 54.7"/>
|
||||
<path class="st6" d="M798.4 175.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st5" d="M835.5 229.5l78 57.7"/>
|
||||
<path class="st6" d="M908.4 288.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st5" d="M684.5 119.5l-69.8 52.7"/>
|
||||
<path class="st6" d="M614.9 166.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st5" d="M795.5 229.5l-77.8 58.7"/>
|
||||
<path class="st6" d="M717.9 282.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st8" d="M414 17.5h119.6"/>
|
||||
<path class="st2" d="M527.6 22.6l5.1-5.1-5.1-5.1h4.3l5.1 5.1-5.1 5.1z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.7 KiB |
117
docs/poincare/rtti.svg
Normal file
@@ -0,0 +1,117 @@
|
||||
<svg id="Calque_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 948.5 361">
|
||||
<style>
|
||||
.st0{fill:gray}.st1{fill:#f2f2f2}.st2{fill:#ccc}.st3{fill:none}.st4{font-family:'SourceSansPro-Light'}.st5{font-size:21px}.st6{font-family:'SourceSansPro-Regular'}.st7{font-size:20px}.st8{fill:#fff}.st9{font-family:'SourceCodePro-Medium'}.st10{font-size:18px}.st11{font-family:'Apple-Chancery'}.st12{fill:none;stroke:#ffb734;stroke-miterlimit:10}.st13{fill:#ffb734}.st14{fill:none;stroke:#ffb734;stroke-linecap:round;stroke-linejoin:round}.st15{fill:none;stroke:gray;stroke-width:3;stroke-miterlimit:10}
|
||||
</style>
|
||||
<path class="st0" d="M0 0h392.5v32.5H0z"/>
|
||||
<path class="st1" d="M106 68.8h95V133h-95z"/>
|
||||
<path class="st2" d="M106 68.8h95v31.7h-95z"/>
|
||||
<path class="st3" d="M106 77h95v15.4h-95z"/>
|
||||
<text transform="translate(117.265 92.062)" class="st4 st5">
|
||||
Addition
|
||||
</text>
|
||||
<path class="st1" d="M206 180.8h95V245h-95z"/>
|
||||
<path class="st2" d="M206 180.8h95v31.7h-95z"/>
|
||||
<path class="st3" d="M183 189h142v15.4H183z"/>
|
||||
<text transform="translate(217.765 204.062)" class="st4 st5">
|
||||
Addition
|
||||
</text>
|
||||
<path class="st1" d="M0 180.8h90V246H0z"/>
|
||||
<path class="st3" d="M0 223.2h90v23.3H0z"/>
|
||||
<text transform="translate(40.03 237.395)" class="st6 st7">
|
||||
1
|
||||
</text>
|
||||
<path class="st2" d="M0 180.8h90v31.7H0z"/>
|
||||
<path class="st3" d="M2 190h88v19H2z"/>
|
||||
<text transform="translate(10.269 205.061)" class="st4 st5">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st3" d="M0 10h392v19H0z"/>
|
||||
<text transform="translate(147.4 22.725)" class="st8 st9 st10">
|
||||
1 + (π+x)
|
||||
</text>
|
||||
<path class="st1" d="M117 295.8h90V361h-90z"/>
|
||||
<path class="st3" d="M117 337.2h89v23.3h-89z"/>
|
||||
<text transform="translate(155.89 351.395)" class="st6 st7">
|
||||
π
|
||||
</text>
|
||||
<path class="st2" d="M117 295.8h90v31.7h-90z"/>
|
||||
<path class="st3" d="M117 305h89v19h-89z"/>
|
||||
<text transform="translate(129.108 320.061)" class="st4 st5">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st1" d="M302 294.8h90V360h-90z"/>
|
||||
<path class="st3" d="M302 333.2h90v23.3h-90z"/>
|
||||
<text transform="translate(341.99 350.455)" class="st11 st7">
|
||||
x
|
||||
</text>
|
||||
<path class="st2" d="M302 294.8h90v31.7h-90z"/>
|
||||
<path class="st3" d="M302 304h90v19h-90z"/>
|
||||
<text transform="translate(314.608 319.061)" class="st4 st5">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st12" d="M173.5 118.5l74 52.7"/>
|
||||
<path class="st13" d="M242.4 172.6l-.2-1 4.9-.6-1-4.9 1-.2 1.2 5.9z"/>
|
||||
<path class="st12" d="M273.5 228.5l78 58.7"/>
|
||||
<path class="st13" d="M346.4 288.4l-.1-1 4.9-.5-.9-4.8 1-.2 1 5.9z"/>
|
||||
<path class="st12" d="M128.5 118.5l-69.8 52.7"/>
|
||||
<path class="st13" d="M58.9 165.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st12" d="M233.5 228.5l-77.8 58.7"/>
|
||||
<path class="st13" d="M155.9 281.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st0" d="M556 0h392.5v33.5H556z"/>
|
||||
<path class="st1" d="M708 70.8h95V135h-95z"/>
|
||||
<path class="st2" d="M708 70.8h95v31.7h-95z"/>
|
||||
<path class="st3" d="M708 79h95v15.4h-95z"/>
|
||||
<text transform="translate(719.265 94.062)" class="st4 st5">
|
||||
Addition
|
||||
</text>
|
||||
<path class="st1" d="M556 181.8h90V247h-90z"/>
|
||||
<path class="st3" d="M556 224.2h90v23.3h-90z"/>
|
||||
<text transform="translate(596.03 238.395)" class="st6 st7">
|
||||
1
|
||||
</text>
|
||||
<path class="st2" d="M556 181.8h90v31.7h-90z"/>
|
||||
<path class="st3" d="M556 191h90v19h-90z"/>
|
||||
<text transform="translate(565.269 206.061)" class="st4 st5">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st3" d="M556 10h392v19H556z"/>
|
||||
<text transform="translate(703.4 22.725)" class="st8 st9 st10">
|
||||
1 + π + x
|
||||
</text>
|
||||
<path class="st1" d="M858 180.8h90V246h-90z"/>
|
||||
<path class="st3" d="M858 222.2h90v23.3h-90z"/>
|
||||
<text transform="translate(897.39 236.395)" class="st6 st7">
|
||||
π
|
||||
</text>
|
||||
<path class="st2" d="M858 180.8h90v31.7h-90z"/>
|
||||
<path class="st3" d="M858 190h90v19h-90z"/>
|
||||
<text transform="translate(870.608 205.061)" class="st4 st5">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st1" d="M707 181.8h90V247h-90z"/>
|
||||
<path class="st3" d="M707 221.2h91v23.3h-91z"/>
|
||||
<text transform="translate(747.49 238.456)" class="st11 st7">
|
||||
x
|
||||
</text>
|
||||
<path class="st2" d="M707 181.8h90v31.7h-90z"/>
|
||||
<path class="st3" d="M691 191h121v19H691z"/>
|
||||
<text transform="translate(719.108 206.061)" class="st4 st5">
|
||||
Symbol
|
||||
</text>
|
||||
<g>
|
||||
<path class="st14" d="M773.5 118.5l74 54.7"/>
|
||||
<path class="st13" d="M842.4 174.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st14" d="M731.5 118.5l-72.8 54.7"/>
|
||||
<path class="st13" d="M658.9 167.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st14" d="M752 118.5l-.5 54.4"/>
|
||||
<path class="st13" d="M747.4 169.6l.8-.7 3.3 3.6 3.4-3.5.7.6-4.1 4.4z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st15" d="M413 17.5h119.6"/>
|
||||
<path class="st0" d="M526.6 22.6l5.1-5.1-5.1-5.1h4.3l5.1 5.1-5.1 5.1z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.0 KiB |
123
docs/poincare/simplify.svg
Normal file
@@ -0,0 +1,123 @@
|
||||
<svg id="Calque_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 948 480">
|
||||
<style>
|
||||
.st0{fill:none;stroke:#000;stroke-width:.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}.st1{fill:#f2f2f2}.st2{fill:gray}.st3{fill:#ccc}.st4{fill:none}.st5{font-family:'SourceSansPro-Light'}.st6{font-size:21px}.st7{fill:#fff}.st8{font-family:'SourceCodePro-Medium'}.st9{font-size:18px}.st10{font-family:'SourceSansPro-Regular'}.st11{font-size:20px}.st12{fill:none;stroke:#ffb734;stroke-miterlimit:10}.st13{fill:#ffb734}.st14{fill:none;stroke:#ffb734;stroke-linecap:round;stroke-linejoin:round}.st15,.st16{fill:none;stroke:gray;stroke-width:3;stroke-miterlimit:10}.st16{stroke:#000;stroke-width:2}.st17{fill:none;stroke:#a3b3ce;stroke-linecap:round;stroke-linejoin:round}.st18{fill:#a3b3ce}.st19,.st20,.st21{fill:none;stroke-miterlimit:10}.st19{stroke-linecap:square;stroke:#ffb734}.st20,.st21{stroke:#000}.st21{stroke-width:2;stroke-dasharray:4,2}
|
||||
</style>
|
||||
<path class="st2" d="M0 1h392.5v32.5H0z"/>
|
||||
<path class="st1" d="M189 69.8h95V134h-95z"/>
|
||||
<path class="st3" d="M189 69.8h95v31.7h-95z"/>
|
||||
<path class="st4" d="M166 78h142v15.4H166z"/>
|
||||
<text transform="translate(200.765 93.062)" class="st5 st6">
|
||||
Addition
|
||||
</text>
|
||||
<path class="st1" d="M72 181.8h117V247H72z"/>
|
||||
<path class="st3" d="M72 181.8h117v31.7H72z"/>
|
||||
<path class="st4" d="M70 191h121v19H70z"/>
|
||||
<text transform="translate(80.322 206.061)" class="st5 st6">
|
||||
Subtraction
|
||||
</text>
|
||||
<path class="st1" d="M697 69.8h117V135H697z"/>
|
||||
<path class="st3" d="M697 69.8h117v31.7H697z"/>
|
||||
<path class="st4" d="M697 79h117v19H697z"/>
|
||||
<text transform="translate(705.321 94.061)" class="st5 st6">
|
||||
Subtraction
|
||||
</text>
|
||||
<path class="st4" d="M0 10h392v19H0z"/>
|
||||
<text transform="translate(142 22.725)" class="st7 st8 st9">
|
||||
1 - 2π + π
|
||||
</text>
|
||||
<path class="st1" d="M302 181.8h90V247h-90z"/>
|
||||
<path class="st4" d="M302 223.2h89v23.3h-89z"/>
|
||||
<text transform="translate(340.89 237.395)" class="st10 st11">
|
||||
π
|
||||
</text>
|
||||
<path class="st3" d="M302 181.8h90v31.7h-90z"/>
|
||||
<path class="st4" d="M286 191h121v19H286z"/>
|
||||
<text transform="translate(314.108 206.061)" class="st5 st6">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st1" d="M302 414.8h90V480h-90z"/>
|
||||
<path class="st4" d="M302 456.2h89v23.3h-89z"/>
|
||||
<text transform="translate(340.89 470.395)" class="st10 st11">
|
||||
π
|
||||
</text>
|
||||
<path class="st3" d="M302 414.8h90v31.7h-90z"/>
|
||||
<path class="st4" d="M286 424h121v19H286z"/>
|
||||
<text transform="translate(314.108 439.061)" class="st5 st6">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st12" d="M256.5 117.5l74 54.7"/>
|
||||
<path class="st13" d="M325.4 173.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st12" d="M150.5 229.5l78 57.7"/>
|
||||
<path class="st13" d="M223.4 288.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st12" d="M211.5 117.5l-69.8 52.7"/>
|
||||
<path class="st13" d="M141.9 164.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st12" d="M110.5 229.5l-77.8 58.7"/>
|
||||
<path class="st13" d="M32.9 282.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st2" d="M556 1h392.5v32.5H556z"/>
|
||||
<path class="st1" d="M556 180.8h90V246h-90z"/>
|
||||
<path class="st4" d="M556 223.2h90v23.3h-90z"/>
|
||||
<text transform="translate(596.03 237.395)" class="st10 st11">
|
||||
1
|
||||
</text>
|
||||
<path class="st3" d="M556 180.8h90v31.7h-90z"/>
|
||||
<path class="st4" d="M556 190h90v19h-90z"/>
|
||||
<text transform="translate(565.269 205.061)" class="st5 st6">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M0 296.8h90V362H0z"/>
|
||||
<path class="st4" d="M0 339.2h90v23.3H0z"/>
|
||||
<text transform="translate(40.03 353.396)" class="st10 st11">
|
||||
1
|
||||
</text>
|
||||
<path class="st3" d="M0 296.8h90v31.7H0z"/>
|
||||
<path class="st4" d="M-16 306h121v19H-16z"/>
|
||||
<text transform="translate(8.77 321.061)" class="st5 st6">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st1" d="M86 414.8h90V480H86z"/>
|
||||
<path class="st4" d="M86 457.2h90v23.3H86z"/>
|
||||
<text transform="translate(126.03 471.396)" class="st10 st11">
|
||||
2
|
||||
</text>
|
||||
<path class="st3" d="M86 414.8h90v31.7H86z"/>
|
||||
<path class="st4" d="M70 424h121v19H70z"/>
|
||||
<text transform="translate(94.77 439.061)" class="st5 st6">
|
||||
Rational
|
||||
</text>
|
||||
<path class="st4" d="M554 11h394v19H554z"/>
|
||||
<text transform="translate(724 23.762)" class="st7 st8 st9">
|
||||
1 - π
|
||||
</text>
|
||||
<path class="st1" d="M858 181.8h90V247h-90z"/>
|
||||
<path class="st4" d="M858 223.2h90v23.3h-90z"/>
|
||||
<text transform="translate(897.39 237.395)" class="st10 st11">
|
||||
π
|
||||
</text>
|
||||
<path class="st3" d="M858 181.8h90v31.7h-90z"/>
|
||||
<path class="st4" d="M858 191h90v19h-90z"/>
|
||||
<text transform="translate(870.608 206.061)" class="st5 st6">
|
||||
Symbol
|
||||
</text>
|
||||
<path class="st14" d="M788.5 119.5l74 54.7"/>
|
||||
<path class="st13" d="M857.4 175.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
<path class="st14" d="M719.5 118.5l-72.8 54.7"/>
|
||||
<path class="st13" d="M646.9 167.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
<path class="st15" d="M412 16.5h119.6"/>
|
||||
<path class="st2" d="M525.6 21.6l5.1-5.1-5.1-5.1h4.3l5.1 5.1-5.1 5.1z"/>
|
||||
<g>
|
||||
<path class="st1" d="M167 296.8h140.4V362H167z"/>
|
||||
</g>
|
||||
<path class="st3" d="M167 296.8h140.4v31.7H167z"/>
|
||||
<path class="st4" d="M167 305h140v19.3H167z"/>
|
||||
<text transform="translate(178.422 320.061)" class="st5 st6">
|
||||
Multiplication
|
||||
</text>
|
||||
<g>
|
||||
<path class="st12" d="M258.5 345.5l78 57.7"/>
|
||||
<path class="st13" d="M331.4 404.5l-.1-1 4.9-.6-1-4.8 1-.2 1.1 5.9z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st12" d="M214.5 345.5l-77.8 58.7"/>
|
||||
<path class="st13" d="M136.9 398.9l1 .2-.9 4.8 4.9.5-.1 1-6-.6z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.7 KiB |