@@ -60,4 +60,37 @@ e := Sin( x1 ) / Cos( x1 ) + Sin( x2 ) ^ 2 + Cos( x2 ) ^ 2;
60
60
# ! Sin( x1 ) / Cos( x1 ) + Sin( x2 ) ^ 2 + Cos( x2 ) ^ 2
61
61
SimplifyExpressionUsingPython( [ e ] );
62
62
# ! [ "Tan(x1) + 1" ]
63
+ Diff( e, 1 )( dummy_input );
64
+ # ! Sin( x1 ) ^ 2 / Cos( x1 ) ^ 2 + 1
65
+ LazyDiff( e, 1 )( dummy_input );;
66
+ # Diff( [ "x1", "x2", "x3" ],
67
+ # "(((Sin(x1))/(Cos(x1)))+((Sin(x2))^(2)))+((Cos(x2))^(2))", 1 )( [ x1, x2, x3 ] );
68
+ JacobianMatrixUsingPython( [ x1* Cos(x2)+ Exp(x3), x1* x2* x3 ] , [ 1 , 2 , 3 ] );
69
+ # ! [ [ "Cos(x2)", "-x1*Sin(x2)", "Exp(x3)" ], [ "x2*x3", "x1*x3", "x1*x2" ] ]
70
+ LaTeXOutputUsingPython( e );
71
+ # ! "\\frac{\\sin{\\left(x_{1} \\right)}}{\\cos{\\left(x_{1} \\right)}}
72
+ # ! + \\sin^{2}{\\left(x_{2} \\right)} + \\cos^{2}{\\left(x_{2} \\right)}"
73
+ sigmoid := Expression( [ " x" ] , " Exp(x)/(1+Exp(x))" );
74
+ # ! Exp( x ) / (1 + Exp( x ))
75
+ sigmoid := AsFunction( sigmoid );
76
+ # ! function( vec ) ... end
77
+ sigmoid( [ 0 ] );
78
+ # ! 0.5
79
+ points := List( 0.1 * [ - 20 .. 20 ] , x -> [ x, sigmoid( [ x ] ) ] );
80
+ # ! [ [ -2., 0.119203 ], [ -1.9, 0.130108 ], [ -1.8, 0.141851 ], [ -1.7, 0.154465 ],
81
+ # ! [ -1.6, 0.167982 ], [ -1.5, 0.182426 ], [ -1.4, 0.197816 ], [ -1.3, 0.214165 ],
82
+ # ! [ -1.2, 0.231475 ], [ -1.1, 0.24974 ], [ -1., 0.268941 ], [ -0.9, 0.28905 ],
83
+ # ! [ -0.8, 0.310026 ], [ -0.7, 0.331812 ], [ -0.6, 0.354344 ], [ -0.5, 0.377541 ],
84
+ # ! [ -0.4, 0.401312 ], [ -0.3, 0.425557 ], [ -0.2, 0.450166 ], [ -0.1, 0.475021 ],
85
+ # ! [ 0., 0.5 ], [ 0.1, 0.524979 ], [ 0.2, 0.549834 ], [ 0.3, 0.574443 ],
86
+ # ! [ 0.4, 0.598688 ], [ 0.5, 0.622459 ], [ 0.6, 0.645656 ], [ 0.7, 0.668188 ],
87
+ # ! [ 0.8, 0.689974 ], [ 0.9, 0.71095 ], [ 1., 0.731059 ], [ 1.1, 0.75026 ],
88
+ # ! [ 1.2, 0.768525 ], [ 1.3, 0.785835 ], [ 1.4, 0.802184 ], [ 1.5, 0.817574 ],
89
+ # ! [ 1.6, 0.832018 ], [ 1.7, 0.845535 ], [ 1.8, 0.858149 ], [ 1.9, 0.869892 ],
90
+ # ! [ 2., 0.880797 ] ]
91
+ labels := List( points, point -> SelectBasedOnCondition( point[ 2 ] < 0.5 , 0 , 1 ) );
92
+ # ! [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
93
+ # ! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
94
+ ScatterPlotUsingPython( points, labels : size := " 100" , action := " save" );;
95
+ # e.g, dir("/tmp/gaptempdirX7Qsal/")
63
96
# ! @EndExample
0 commit comments