# Lightweight, versatile, and platform agnostic architecture¶

Optuna is entirely written in Python and has few dependencies. This means that we can quickly move to the real example once you get interested in Optuna.

## Quadratic Function Example¶

Usually, Optuna is used to optimize hyperparameters, but as an example, let’s optimize a simple quadratic function: $$(x - 2)^2$$.

First of all, import optuna.

import optuna


In optuna, conventionally functions to be optimized are named objective.

def objective(trial):
x = trial.suggest_float("x", -10, 10)
return (x - 2) ** 2


This function returns the value of $$(x - 2)^2$$. Our goal is to find the value of x that minimizes the output of the objective function. This is the “optimization.” During the optimization, Optuna repeatedly calls and evaluates the objective function with different values of x.

A Trial object corresponds to a single execution of the objective function and is internally instantiated upon each invocation of the function.

The suggest APIs (for example, suggest_float()) are called inside the objective function to obtain parameters for a trial. suggest_float() selects parameters uniformly within the range provided. In our example, from $$-10$$ to $$10$$.

To start the optimization, we create a study object and pass the objective function to method optimize() as follows.

study = optuna.create_study()
study.optimize(objective, n_trials=100)


best_params = study.best_params
found_x = best_params["x"]
print("Found x: {}, (x - 2)^2: {}".format(found_x, (found_x - 2) ** 2))


Out:

Found x: 1.9552812528296772, (x - 2)^2: 0.0019997663484832497


We can see that the x value found by Optuna is close to the optimal value of 2.

Note

When used to search for hyperparameters in machine learning, usually the objective function would return the loss or accuracy of the model.

## Study Object¶

Let us clarify the terminology in Optuna as follows:

• Trial: A single call of the objective function

• Study: An optimization session, which is a set of trials

• Parameter: A variable whose value is to be optimized, such as x in the above example

In Optuna, we use the study object to manage optimization. Method create_study() returns a study object. A study object has useful properties for analyzing the optimization outcome.

To get the dictionary of parameter name and parameter values:

study.best_params


Out:

{'x': 1.9552812528296772}


To get the best observed value of the objective function:

study.best_value


Out:

0.0019997663484832497


study.best_trial


Out:

FrozenTrial(number=91, values=[0.0019997663484832497], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 698113), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 701344), params={'x': 1.9552812528296772}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=91, state=TrialState.COMPLETE, value=None)


To get all trials:

study.trials


Out:

[FrozenTrial(number=0, values=[46.06236786362137], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 417810), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 418163), params={'x': 8.786926245630003}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=0, state=TrialState.COMPLETE, value=None), FrozenTrial(number=1, values=[1.3174442700877405], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 418463), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 418727), params={'x': 0.8522002482629034}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=1, state=TrialState.COMPLETE, value=None), FrozenTrial(number=2, values=[18.656621621355416], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 418985), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 419229), params={'x': -2.3193311543982613}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=2, state=TrialState.COMPLETE, value=None), FrozenTrial(number=3, values=[0.0912711698688751], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 419481), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 419723), params={'x': 2.302111187924041}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=3, state=TrialState.COMPLETE, value=None), FrozenTrial(number=4, values=[0.8249066582501879], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 419972), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 420227), params={'x': 1.091756278166379}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=4, state=TrialState.COMPLETE, value=None), FrozenTrial(number=5, values=[24.088522448071156], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 420478), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 420723), params={'x': 6.908005954363865}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=5, state=TrialState.COMPLETE, value=None), FrozenTrial(number=6, values=[28.080852610664405], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 420976), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 421220), params={'x': 7.299136968475565}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=6, state=TrialState.COMPLETE, value=None), FrozenTrial(number=7, values=[0.26757033460012164], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 421469), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 421720), params={'x': 1.4827279878051378}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=7, state=TrialState.COMPLETE, value=None), FrozenTrial(number=8, values=[24.176643235321677], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 421969), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 422222), params={'x': -2.916975008612681}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=8, state=TrialState.COMPLETE, value=None), FrozenTrial(number=9, values=[83.65744599062697], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 422468), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 422719), params={'x': -7.146444445281837}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=9, state=TrialState.COMPLETE, value=None), FrozenTrial(number=10, values=[4.62633221899974], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 422962), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 426071), params={'x': 4.150891029085328}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=10, state=TrialState.COMPLETE, value=None), FrozenTrial(number=11, values=[2.325840158457356], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 426363), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 429345), params={'x': 3.525070542124972}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=11, state=TrialState.COMPLETE, value=None), FrozenTrial(number=12, values=[32.63250429965425], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 429635), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 432621), params={'x': -3.7124867001730735}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=12, state=TrialState.COMPLETE, value=None), FrozenTrial(number=13, values=[2.492415367338656], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 432914), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 435820), params={'x': 3.5787385367243862}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=13, state=TrialState.COMPLETE, value=None), FrozenTrial(number=14, values=[8.16360501935792], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 436125), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 439057), params={'x': -0.8572023063405783}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=14, state=TrialState.COMPLETE, value=None), FrozenTrial(number=15, values=[71.03821180429107], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 439348), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 442273), params={'x': -6.428416921598687}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=15, state=TrialState.COMPLETE, value=None), FrozenTrial(number=16, values=[0.004028883010827186], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 442563), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 445492), params={'x': 2.063473482737496}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=16, state=TrialState.COMPLETE, value=None), FrozenTrial(number=17, values=[11.949307077442636], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 445783), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 448745), params={'x': 5.456776978262068}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=17, state=TrialState.COMPLETE, value=None), FrozenTrial(number=18, values=[58.938053698890926], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 449035), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 451943), params={'x': 9.677112328140765}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=18, state=TrialState.COMPLETE, value=None), FrozenTrial(number=19, values=[7.669291396726786], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 452254), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 455114), params={'x': -0.7693485509640685}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=19, state=TrialState.COMPLETE, value=None), FrozenTrial(number=20, values=[46.05537457803253], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 455406), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 458277), params={'x': -4.786411023363714}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=20, state=TrialState.COMPLETE, value=None), FrozenTrial(number=21, values=[0.10565520536103212], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 458568), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 461443), params={'x': 1.6749535335355388}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=21, state=TrialState.COMPLETE, value=None), FrozenTrial(number=22, values=[0.043585906260789745], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 461735), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 464619), params={'x': 2.2087723790657896}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=22, state=TrialState.COMPLETE, value=None), FrozenTrial(number=23, values=[9.692485373836151], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 464911), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 467794), params={'x': 5.113275666213346}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=23, state=TrialState.COMPLETE, value=None), FrozenTrial(number=24, values=[0.4261950282100488], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 468102), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 471040), params={'x': 2.6528361419300013}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=24, state=TrialState.COMPLETE, value=None), FrozenTrial(number=25, values=[127.70810443936504], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 471335), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 474314), params={'x': -9.300801052994652}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=25, state=TrialState.COMPLETE, value=None), FrozenTrial(number=26, values=[4.963874180270653], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 474611), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 477607), params={'x': -0.22797535450252537}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=26, state=TrialState.COMPLETE, value=None), FrozenTrial(number=27, values=[14.858980132300612], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 477903), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 480921), params={'x': 5.854734768087243}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=27, state=TrialState.COMPLETE, value=None), FrozenTrial(number=28, values=[0.4044473808150176], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 481217), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 484254), params={'x': 2.635961776221667}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=28, state=TrialState.COMPLETE, value=None), FrozenTrial(number=29, values=[13.274803154041729], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 484549), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 487581), params={'x': -1.6434603269476846}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=29, state=TrialState.COMPLETE, value=None), FrozenTrial(number=30, values=[35.46737701252267], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 487876), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 490936), params={'x': 7.955449354374753}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=30, state=TrialState.COMPLETE, value=None), FrozenTrial(number=31, values=[0.06873887361697407], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 491233), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 494311), params={'x': 1.7378190059959073}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=31, state=TrialState.COMPLETE, value=None), FrozenTrial(number=32, values=[1.8365719330636183], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 494612), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 497700), params={'x': 0.6447981947091355}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=32, state=TrialState.COMPLETE, value=None), FrozenTrial(number=33, values=[0.048138964587950014], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 498001), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 501069), params={'x': 2.2194059356260674}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=33, state=TrialState.COMPLETE, value=None), FrozenTrial(number=34, values=[3.121346975556382], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 501369), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 504443), params={'x': 0.23326658050616422}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=34, state=TrialState.COMPLETE, value=None), FrozenTrial(number=35, values=[1.970435094179814], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 504740), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 507816), params={'x': 3.403721872088561}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=35, state=TrialState.COMPLETE, value=None), FrozenTrial(number=36, values=[7.149454604396553], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 508129), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 511212), params={'x': 4.673846406283755}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=36, state=TrialState.COMPLETE, value=None), FrozenTrial(number=37, values=[0.03400710569515017], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 511513), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 514566), params={'x': 1.8155898438394724}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=37, state=TrialState.COMPLETE, value=None), FrozenTrial(number=38, values=[13.514223323678092], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 514864), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 517982), params={'x': -1.6761696538215005}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=38, state=TrialState.COMPLETE, value=None), FrozenTrial(number=39, values=[19.499352595858735], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 518291), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 521364), params={'x': 6.415807128471389}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=39, state=TrialState.COMPLETE, value=None), FrozenTrial(number=40, values=[1.146941529112557], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 521661), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 524747), params={'x': 0.9290464393296238}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=40, state=TrialState.COMPLETE, value=None), FrozenTrial(number=41, values=[0.0073973514006425885], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 525049), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 528149), params={'x': 2.086007856621605}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=41, state=TrialState.COMPLETE, value=None), FrozenTrial(number=42, values=[0.01611708957144875], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 528449), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 531534), params={'x': 2.126953099889088}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=42, state=TrialState.COMPLETE, value=None), FrozenTrial(number=43, values=[0.5363196805921203], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 531834), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 534915), params={'x': 2.7323385013722277}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=43, state=TrialState.COMPLETE, value=None), FrozenTrial(number=44, values=[4.362187806444458], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 535218), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 538324), params={'x': 4.088585120708385}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=44, state=TrialState.COMPLETE, value=None), FrozenTrial(number=45, values=[0.7687705223526913], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 538629), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 541725), params={'x': 1.123204401041673}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=45, state=TrialState.COMPLETE, value=None), FrozenTrial(number=46, values=[4.6234771681220055], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 542029), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 545122), params={'x': -0.1502272363920063}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=46, state=TrialState.COMPLETE, value=None), FrozenTrial(number=47, values=[1.830130685028487], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 545426), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 548607), params={'x': 3.3528232275609726}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=47, state=TrialState.COMPLETE, value=None), FrozenTrial(number=48, values=[6.350556555632274], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 548908), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 551991), params={'x': 4.520031062434008}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=48, state=TrialState.COMPLETE, value=None), FrozenTrial(number=49, values=[0.10929449602750155], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 552308), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 555388), params={'x': 1.6694028190871835}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=49, state=TrialState.COMPLETE, value=None), FrozenTrial(number=50, values=[8.603131170873263], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 555692), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 558834), params={'x': -0.9331094713415085}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=50, state=TrialState.COMPLETE, value=None), FrozenTrial(number=51, values=[0.035612691458366395], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 559138), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 562237), params={'x': 2.1887132519415804}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=51, state=TrialState.COMPLETE, value=None), FrozenTrial(number=52, values=[0.07126425189850516], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 562545), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 565674), params={'x': 2.266953651217782}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=52, state=TrialState.COMPLETE, value=None), FrozenTrial(number=53, values=[2.0626812937611665], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 565978), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 569086), params={'x': 0.563796221366492}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=53, state=TrialState.COMPLETE, value=None), FrozenTrial(number=54, values=[1.2830663673612237], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 569392), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 572499), params={'x': 3.132725194988274}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=54, state=TrialState.COMPLETE, value=None), FrozenTrial(number=55, values=[4.101150416514107], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 572803), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 575896), params={'x': 4.025129728317203}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=55, state=TrialState.COMPLETE, value=None), FrozenTrial(number=56, values=[0.02938472526254856], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 576217), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 579304), params={'x': 1.8285802658310644}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=56, state=TrialState.COMPLETE, value=None), FrozenTrial(number=57, values=[25.136529315161397], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 579612), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 582737), params={'x': -3.0136343419879954}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=57, state=TrialState.COMPLETE, value=None), FrozenTrial(number=58, values=[0.3656443170229612], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 583044), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 586379), params={'x': 1.395314695876474}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=58, state=TrialState.COMPLETE, value=None), FrozenTrial(number=59, values=[2.767698627592421], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 586688), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 589821), params={'x': 0.3363598262868197}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=59, state=TrialState.COMPLETE, value=None), FrozenTrial(number=60, values=[10.217395952692335], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 590132), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 593253), params={'x': 5.196466166361273}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=60, state=TrialState.COMPLETE, value=None), FrozenTrial(number=61, values=[0.00948325444341199], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 593563), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 596694), params={'x': 2.097382002666879}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=61, state=TrialState.COMPLETE, value=None), FrozenTrial(number=62, values=[0.88082615486098], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 597004), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 600125), params={'x': 2.9385233906839936}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=62, state=TrialState.COMPLETE, value=None), FrozenTrial(number=63, values=[0.10173007082782642], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 600436), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 603529), params={'x': 1.6810484820104685}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=63, state=TrialState.COMPLETE, value=None), FrozenTrial(number=64, values=[4.030772914386389], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 603841), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 606971), params={'x': 4.007678488799038}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=64, state=TrialState.COMPLETE, value=None), FrozenTrial(number=65, values=[5.921788693442692], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 607294), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 610436), params={'x': -0.43347255859660216}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=65, state=TrialState.COMPLETE, value=None), FrozenTrial(number=66, values=[0.03750199867250696], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 610750), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 613895), params={'x': 2.1936543277918337}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=66, state=TrialState.COMPLETE, value=None), FrozenTrial(number=67, values=[1.0778351401557733], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 614208), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 617369), params={'x': 0.9618116066167117}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=67, state=TrialState.COMPLETE, value=None), FrozenTrial(number=68, values=[13.341008222091157], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 617685), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 620827), params={'x': -1.6525344929365358}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=68, state=TrialState.COMPLETE, value=None), FrozenTrial(number=69, values=[0.004017479424620208], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 621138), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 624387), params={'x': 1.9366164104470234}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=69, state=TrialState.COMPLETE, value=None), FrozenTrial(number=70, values=[1.7022485479029594], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 624699), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 627863), params={'x': 3.304702474858908}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=70, state=TrialState.COMPLETE, value=None), FrozenTrial(number=71, values=[0.011106133013500817], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 628197), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 631310), params={'x': 2.1053856395032113}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=71, state=TrialState.COMPLETE, value=None), FrozenTrial(number=72, values=[0.2682692181026748], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 631625), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 634765), params={'x': 1.4820528809784972}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=72, state=TrialState.COMPLETE, value=None), FrozenTrial(number=73, values=[0.6294099571197741], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 635080), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 638239), params={'x': 2.7933536141719997}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=73, state=TrialState.COMPLETE, value=None), FrozenTrial(number=74, values=[3.3117704874311986], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 638558), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 641717), params={'x': 0.18017295123102461}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=74, state=TrialState.COMPLETE, value=None), FrozenTrial(number=75, values=[0.012854488579377462], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 642032), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 645196), params={'x': 1.8866223629661587}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=75, state=TrialState.COMPLETE, value=None), FrozenTrial(number=76, values=[2.558659642462775], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 645510), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 648689), params={'x': 3.5995810834286504}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=76, state=TrialState.COMPLETE, value=None), FrozenTrial(number=77, values=[7.170315480957983], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 649004), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 652170), params={'x': 4.6777444764125615}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=77, state=TrialState.COMPLETE, value=None), FrozenTrial(number=78, values=[1.1217447479838196], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 652482), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 655621), params={'x': 0.9408754804161035}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=78, state=TrialState.COMPLETE, value=None), FrozenTrial(number=79, values=[7.860887101069938], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 655939), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 659115), params={'x': -0.8037273585478917}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=79, state=TrialState.COMPLETE, value=None), FrozenTrial(number=80, values=[15.085079804225336], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 659434), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 662606), params={'x': 5.883951570787841}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=80, state=TrialState.COMPLETE, value=None), FrozenTrial(number=81, values=[0.014785293695023103], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 662923), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 666101), params={'x': 1.878405206957604}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=81, state=TrialState.COMPLETE, value=None), FrozenTrial(number=82, values=[0.5228800769588607], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 666417), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 669614), params={'x': 2.7231044716767148}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=82, state=TrialState.COMPLETE, value=None), FrozenTrial(number=83, values=[0.33365234998449494], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 669933), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 673117), params={'x': 1.4223735203572339}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=83, state=TrialState.COMPLETE, value=None), FrozenTrial(number=84, values=[0.01150804991613793], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 673432), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 676622), params={'x': 2.107275579309263}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=84, state=TrialState.COMPLETE, value=None), FrozenTrial(number=85, values=[0.15452512595239803], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 676936), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 680141), params={'x': 2.3930968404253563}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=85, state=TrialState.COMPLETE, value=None), FrozenTrial(number=86, values=[1.9677340376883328], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 680458), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 683657), params={'x': 0.5972405631440818}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=86, state=TrialState.COMPLETE, value=None), FrozenTrial(number=87, values=[2.728059805015314], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 683974), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 687195), params={'x': 3.651683930119596}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=87, state=TrialState.COMPLETE, value=None), FrozenTrial(number=88, values=[0.056185751459615116], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 687516), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 690718), params={'x': 2.237035337997555}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=88, state=TrialState.COMPLETE, value=None), FrozenTrial(number=89, values=[0.6300506130300543], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 691038), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 694244), params={'x': 1.2062427241089035}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=89, state=TrialState.COMPLETE, value=None), FrozenTrial(number=90, values=[5.531471710100687], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 694565), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 697792), params={'x': -0.3519080998416346}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=90, state=TrialState.COMPLETE, value=None), FrozenTrial(number=91, values=[0.0019997663484832497], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 698113), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 701344), params={'x': 1.9552812528296772}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=91, state=TrialState.COMPLETE, value=None), FrozenTrial(number=92, values=[0.9931581224633752], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 701667), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 704913), params={'x': 2.996573189717331}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=92, state=TrialState.COMPLETE, value=None), FrozenTrial(number=93, values=[0.01711689352037538], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 705231), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 708467), params={'x': 1.869168453649835}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=93, state=TrialState.COMPLETE, value=None), FrozenTrial(number=94, values=[0.33421794803273813], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 708790), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 711983), params={'x': 2.578115860388502}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=94, state=TrialState.COMPLETE, value=None), FrozenTrial(number=95, values=[1.675665808552741], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 712318), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 715518), params={'x': 0.7055248907171907}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=95, state=TrialState.COMPLETE, value=None), FrozenTrial(number=96, values=[3.0065741729154762], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 715836), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 719066), params={'x': 3.7339475692521606}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=96, state=TrialState.COMPLETE, value=None), FrozenTrial(number=97, values=[5.653095898830819], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 719387), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 722606), params={'x': 4.377624002829467}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=97, state=TrialState.COMPLETE, value=None), FrozenTrial(number=98, values=[0.011549848607419136], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 722928), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 726162), params={'x': 1.892529778043315}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=98, state=TrialState.COMPLETE, value=None), FrozenTrial(number=99, values=[0.6932544837909879], datetime_start=datetime.datetime(2021, 6, 7, 7, 8, 29, 726485), datetime_complete=datetime.datetime(2021, 6, 7, 7, 8, 29, 730072), params={'x': 1.1673809491784446}, distributions={'x': UniformDistribution(high=10.0, low=-10.0)}, user_attrs={}, system_attrs={}, intermediate_values={}, trial_id=99, state=TrialState.COMPLETE, value=None)]


To get the number of trials:

len(study.trials)


Out:

100


By executing optimize() again, we can continue the optimization.

study.optimize(objective, n_trials=100)


To get the updated number of trials:

len(study.trials)


Out:

200


As the objective function is so easy that the last 100 trials don’t improve the result. However, we can check the result again:

best_params = study.best_params
found_x = best_params["x"]
print("Found x: {}, (x - 2)^2: {}".format(found_x, (found_x - 2) ** 2))


Out:

Found x: 2.0027853883964926, (x - 2)^2: 7.7583885193154e-06


Total running time of the script: ( 0 minutes 0.710 seconds)

Gallery generated by Sphinx-Gallery