Skip to content

Commit 66b9bdc

Browse files
philipturnerrxwei
andauthored
Update docs/DifferentiableProgrammingImplementation.md
Co-authored-by: Richard Wei <[email protected]>
1 parent 7b7cc53 commit 66b9bdc

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

docs/DifferentiableProgrammingImplementation.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -307,37 +307,37 @@ Activity analysis classifies values in a function into these categories:
307307
Here is the result of activity analysis for this example:
308308

309309
```swift
310-
// Varied values are in all caps.
310+
// Varied values are surrounded by asterisks.
311311
// These values depend on the input (`x`).
312312
@differentiable
313-
func f(_ X: Float) -> Float {
314-
let SINX = sin(X)
313+
func f(_ **x**: Float) -> Float {
314+
let **sinx** = sin(**x**)
315315
let cos3 = cos(3)
316-
let RESULT = SINX * cos3
317-
print(RESULT)
318-
return RESULT
316+
let **result** = **sinx** * cos3
317+
print(**result**)
318+
return **result**
319319
}
320320

321-
// Useful values are in all caps.
321+
// Useful values are surrounded by asterisks.
322322
// These values contribute to the output (`result`).
323323
@differentiable
324-
func f(_ X: Float) -> Float {
325-
let SINX = sin(X)
326-
let COS3 = cos(3) // 3 should be treated as if capitalized.
327-
let RESULT = SINX * COS3
328-
print(RESULT)
329-
return RESULT
324+
func f(_ **x**: Float) -> Float {
325+
let **sinx** = sin(**x**)
326+
let **cos3** = cos(**3**)
327+
let **result** = **sinx** * **cos3**
328+
print(**result**)
329+
return **result**
330330
}
331331

332-
// Active values are in all caps.
332+
// Active values are surrounded by asterisks.
333333
// These values are varied and useful, and thus need a derivative.
334334
@differentiable
335-
func f(_ X: Float) -> Float {
336-
let SINX = sin(X)
335+
func f(_ **x**: Float) -> Float {
336+
let **sinx** = sin(**x**)
337337
let cos3 = cos(3)
338-
let RESULT = SINX * cos3
338+
let **result** = **sinx** * cos3
339339
let void = print(result)
340-
return RESULT
340+
return **result**
341341
}
342342
```
343343

0 commit comments

Comments
 (0)