Wiki Царёв

Материал из Wiki
Перейти к: навигация, поиск

TsarWiki.png

Содержание

Математические формулы

Однородное линейное ду в частных производных 1-го порядка

 \frac{\partial u}{\partial t} + t\frac{\partial u}{\partial x} = 0.

Mathematically, to ensure that the spacing after evaluating f(x_4) is proportional to the spacing prior to that evaluation, if f(x_4) is f_{4a} and our new triplet of points is x_1, x_2, and x_4, then we want

\frac{c}{a} = \frac{a}{b}.

However, if f(x_4) is f_{4b} and our new triplet of points is x_2, x_4, and x_3, then we want

\frac{c}{b - c} = \frac{a}{b}.

Eliminating c from these two simultaneous equations yields

\left(\frac{b}{a}\right)^2 - \frac{b}{a} = 1,

or

\frac{b}{a} = \varphi,

where φ is the golden ratio:

\varphi = \frac{1 + \sqrt{5}}{2} = 1.618033988\ldots

The appearance of the golden ratio in the proportional spacing of the evaluation points is how this search algorithm gets its name.


Химическая формула

Получение метана:

<chem>2 NaOH + CH3COOH -> Na2CO3 + H2O + CH4 ^</chem>

Программный код

<source lang="go"> Структуры в Golang

package main import "fmt"

type person struct{

   name string
   age int

}

func main() {

   var tom = person {name: "Tom", age: 24}
   fmt.Println(tom.name)       // Tom
   fmt.Println(tom.age)        // 24
    
   tom.age = 38    // изменяем значение
   fmt.Println(tom.name, tom.age)      // Tom 38

} </source>


<syntaxhighlight lang="python"> import math


invphi = (math.sqrt(5) - 1) / 2 # 1 / phi invphi2 = (3 - math.sqrt(5)) / 2 # 1 / phi^2


def gssrec(f, a, b, tol=1e-5, h=None, c=None, d=None, fc=None, fd=None):

   """Golden-section search, recursive.
   Given a function f with a single local minimum in
   the interval [a, b], gss returns a subset interval
   [c, d] that contains the minimum with d-c <= tol.
   Example:
   >>> f = lambda x: (x - 2) ** 2
   >>> a = 1
   >>> b = 5
   >>> tol = 1e-5
   >>> (c, d) = gssrec(f, a, b, tol)
   >>> print (c, d)
   1.9999959837979107 2.0000050911830893
   """
   (a, b) = (min(a, b), max(a, b))
   if h is None:
       h = b - a
   if h <= tol:
       return (a, b)
   if c is None:
       c = a + invphi2 * h
   if d is None:
       d = a + invphi * h
   if fc is None:
       fc = f(c)
   if fd is None:
       fd = f(d)
   if fc < fd:  # fc > fd to find the maximum
       return gssrec(f, a, d, tol, h * invphi, c=None, fc=None, d=c, fd=fc)
   else:
       return gssrec(f, c, b, tol, h * invphi, c=d, fc=fd, d=None, fd=None)

</syntaxhighlight>

Персональные инструменты
Пространства имён

Варианты
Действия
Навигация
Инструменты