<jupyter_start><jupyter_text>Computing Total DerivativesProblem has a method, `compute_totals`, that allows you to compute the unscaled total derivative values for a model.If the model approximated its Jacobian, the method uses an approximation method. ```{eval-rst}    .. automethod:: openmdao.core.problem.Problem.compute_totals        :noindex:```  UsageHere is a simple example of using `compute_totals`:<jupyter_code>from openmdao.test_suite.components.paraboloid import Paraboloid

prob = om.Problem()
model = prob.model

model.add_subsystem('comp', Paraboloid())

model.set_input_defaults('comp.x', 3.0)
model.set_input_defaults('comp.y', -4.0)

prob.setup()

prob.run_model()

totals = prob.compute_totals(of=['comp.f_xy'], wrt=['comp.x', 'comp.y'])
print(totals[('comp.f_xy', 'comp.x')][0][0])
print(totals[('comp.f_xy', 'comp.y')][0][0])
from openmdao.utils.assert_utils import assert_near_equal
import numpy as np

assert_near_equal(totals[('comp.f_xy', 'comp.x')][0][0], -4.0, tolerance=1e-8)
assert_near_equal(totals[('comp.f_xy', 'comp.y')][0][0], 3.0, tolerance=1e-8)
totals = prob.compute_totals(of=['comp.f_xy'], wrt=['comp.x', 'comp.y'], return_format='dict')
print(totals['comp.f_xy']['comp.x'][0][0])
print(totals['comp.f_xy']['comp.y'][0][0])
from openmdao.utils.assert_utils import assert_near_equal
import numpy as np

assert_near_equal(totals['comp.f_xy']['comp.x'][0][0], -4.0, tolerance=1e-8)
assert_near_equal(totals['comp.f_xy']['comp.y'][0][0], 3.0, tolerance=1e-8)<jupyter_output><empty_output><jupyter_text>By default, `compute_totals` returns the derivatives unscaled, but you can also request that they be scaled by the driver scale values declared when the des_vars, objectives, or constraints are added:<jupyter_code>import openmdao.api as om
from openmdao.test_suite.components.paraboloid import Paraboloid

prob = om.Problem()
model = prob.model

model.add_subsystem('comp', Paraboloid())

model.set_input_defaults('comp.x', 3.0)
model.set_input_defaults('comp.y', -4.0)

model.add_design_var('comp.x', 3.0, ref0=50.0)
model.add_design_var('comp.y', -4.0)
model.add_objective('comp.f_xy')

prob.setup()

prob.run_model()

totals = prob.compute_totals(of=['comp.f_xy'], wrt=['comp.x', 'comp.y'], driver_scaling=True)
print(totals[('comp.f_xy', 'comp.x')][0][0])
print(totals[('comp.f_xy', 'comp.y')][0][0])
from openmdao.utils.assert_utils import assert_near_equal
import numpy as np

assert_near_equal(totals[('comp.f_xy', 'comp.y')][0][0], 3.0, tolerance=1e-8)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1764240506329114, 'fraction_numerical': 0.022943037974683545, 'mean_word_length': 7.0285714285714285, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '311066', 'license': 'Apache-2.0', 'n_tokens_mistral': 989, 'n_tokens_neox': 967, 'n_words': 178, 'path': 'openmdao/docs/openmdao_book/features/core_features/working_with_derivatives/compute_totals.ipynb', 'repo_name': 'sebasgo/OpenMDAO', 'size': '2528'}