4.14.6.2 General metric tensor
The function metric_tensor()
creates a general symmetric metric
tensor with two indices that can be used to raise/lower tensor indices. The
metric tensor is denoted as ‘g’ in the output and if its indices are of
mixed variance it is automatically replaced by a delta tensor:
| {
symbol A("A");
varidx mu(symbol("mu"), 4), nu(symbol("nu"), 4), rho(symbol("rho"), 4);
ex e = metric_tensor(mu, nu) * indexed(A, nu.toggle_variance(), rho);
cout << e.simplify_indexed() << endl;
// -> A~mu~rho
e = delta_tensor(mu, nu.toggle_variance()) * metric_tensor(nu, rho);
cout << e.simplify_indexed() << endl;
// -> g~mu~rho
e = metric_tensor(mu.toggle_variance(), nu.toggle_variance())
* metric_tensor(nu, rho);
cout << e.simplify_indexed() << endl;
// -> delta.mu~rho
e = metric_tensor(nu.toggle_variance(), rho.toggle_variance())
* metric_tensor(mu, nu) * (delta_tensor(mu.toggle_variance(), rho)
+ indexed(A, mu.toggle_variance(), rho));
cout << e.simplify_indexed() << endl;
// -> 4+A.rho~rho
}
|