Engee documentation
Notebook

Calculation of square roots

This model displays the calculation of the roots of a quadratic equation.

A quadratic equation is a second degree algebraic equation with a general form:

𝑎𝑥^2+𝑏𝑥+𝑐=0, 𝑎≠0

The model itself is shown in the figure below.

image_2.png

Next, let's add the auxiliary function of the model and specify the coefficients of the equation.

In [ ]:
# Подключение вспомогательной функции запуска модели.
function run_model( name_model)
    
    Path = (@__DIR__) * "/" * name_model * ".engee"
    
    if name_model in [m.name for m in engee.get_all_models()] # Проверка условия загрузки модели в ядро
        model = engee.open( name_model ) # Открыть модель
        model_output = engee.run( model, verbose=true ); # Запустить модель
    else
        model = engee.load( Path, force=true ) # Загрузить модель
        model_output = engee.run( model, verbose=true ); # Запустить модель
        engee.close( name_model, force=true ); # Закрыть модель
    end
    sleep(5)
    return model_output
end
Out[0]:
run_model (generic function with 1 method)
In [ ]:
a = 1;
b = 7;
c = 5;

Run the model and output the calculated tax amount.

In [ ]:
run_model("Root_Quadratic_Equation") # Запуск модели.

Discriminant = collect(simout["Root_Quadratic_Equation/Дискриминант"]);
x1 = collect(simout["Root_Quadratic_Equation/x1"]);
x2 = collect(simout["Root_Quadratic_Equation/x2"]);

println("Дискриминант: " * string(Discriminant.value))
println("x1: " * string(x1.value))
println("x2: " * string(x2.value))
Building...
Progress 100%
Дискриминант: Any[29.0]
x1: Any[-6.192582403567252]
x2: Any[-0.8074175964327481]

Conclusion

In this example we have demonstrated the possibilities of using Engee to realise everyday tasks.