File: t_LeastSquaresEquationsSolver_std.py

package info (click to toggle)
openturns 1.26-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,708 kB
  • sloc: cpp: 261,605; python: 67,030; ansic: 4,378; javascript: 406; sh: 185; xml: 164; makefile: 101
file content (21 lines) | stat: -rwxr-xr-x 633 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /usr/bin/env pythons

import openturns as ot
import openturns.experimental as otexp
import openturns.testing as ott

ot.TESTPREAMBLE()

# Analytical construction */
inputs = ["x", "y"]
formulas = ["y*x-sin(2*x)", "1 + cos(y) + x"]
analytical = ot.SymbolicFunction(inputs, formulas)
algo = otexp.LeastSquaresEquationsSolver()
algo.setResidualError(1e-10)
algo.setMaximumCallsNumber(1000)
starting_point = [2.0, 1.0]
print("Solve ", formulas, "= [0,0] for ", inputs)
solution = algo.solve(analytical, starting_point)
print("[x,y] = ", solution)
print("algo=", algo)
ott.assert_almost_equal(analytical(solution), [0, 0], 1e-5, 1e-5)