diff --git a/articles/media/trace_example.png b/articles/media/trace_example.png new file mode 100644 index 0000000000..ccf3581871 Binary files /dev/null and b/articles/media/trace_example.png differ diff --git a/articles/user-guide/host-programs.md b/articles/user-guide/host-programs.md index f3dbdbf619..d82aaf7947 100644 --- a/articles/user-guide/host-programs.md +++ b/articles/user-guide/host-programs.md @@ -565,3 +565,11 @@ So, to run `MeasureSuperpositionArray`, we need to define a "wrapper" operation Wrapper function and simulate Jupyter cell This operation can of course be used similarly with `%estimate` and other execution commands. + +### Visualizing Q# programs + +In a Q# Jupyter Notebook, you can visualize your Q# programs using the `%trace` magic command (more details about the command [here](xref:microsoft.quantum.iqsharp.magic-ref.trace)). Given a Q# operation as an argument, `%trace` will simulate that operation and trace out the gates in an execution path. This execution path is then rendered and output as a visualization within the Jupyter Notebook. For example, this is a visualization of a non-deterministic Q# program: + +Trace example + +You can find a more detailed explanation of the `%trace` magic command and how to use it in this [Jupyter Notebook sample](https://github.com/microsoft/Quantum/blob/master/samples/diagnostics/program-visualization/TraceExample.ipynb).