-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab2_diary.m
3701 lines (1947 loc) · 131 KB
/
lab2_diary.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Symbolic math
% Example
syms a11 a12 a21 a22 b11 b12 b21 b22
A = [a11 a12; a21 a22];
B = [b11 b12; b21 b22];
A
A =
[ a11, a12]
[ a21, a22]
B
B =
[ b11, b12]
[ b21, b22]
C = A*B
C =
[ a11*b11 + a12*b21, a11*b12 + a12*b22]
[ a21*b11 + a22*b21, a21*b12 + a22*b22]
D = A.*B
D =
[ a11*b11, a12*b12]
[ a21*b21, a22*b22]
% How to define a symbolic variable
% 1.
x = sym('x');
y = sym('y');
z = x^2;
sqrt(x^2)
ans =
(x^2)^(1/2)
% Lets redefine x, now x > 0
x = sym('x','positive');
z = x^2;
sqrt(z)
ans =
x
A'
ans =
[ conj(a11), conj(a21)]
[ conj(a12), conj(a22)]
% if we limit matrix elements to only real
syms a11 a12 a21 a22 real
A = [a11 a12; a21 a22];
A'
ans =
[ a11, a21]
[ a12, a22]
% how to define a symbolic variable 3
A = sym('a', [2, 3])
A =
[ a1_1, a1_2, a1_3]
[ a2_1, a2_2, a2_3]
% how to get a derivative
syms x
diff(x^2)
ans =
2*x
% how to get a partial derivative
syms x y
z = 5*x^5 + y^4;
diff(z,x)
ans =
25*x^4
diff(z,y)
ans =
4*y^3
% how to find integral
syms x
int(x^2,x)
ans =
x^3/3
syms x y
int(x^2,y)
ans =
x^2*y
% how to find definite integral
int(x,x,0,3)
ans =
9/2
% the answer is not a double class
double(int(x,x,0,3))
ans =
4.5000
int(x^2,-3,3)
ans =
18
% how to calculate limits
lim(1/(x-1),x,1,'left')
{Undefined function or variable 'lim'.
}
limit(1/(x-1),x,1,'left')
ans =
-Inf
limit(1/(x-1),x,1,'right')
ans =
Inf
% how to solve equation
syms x
solve(x^2 - 3*x + 2 == 0, x)
ans =
1
2
% how to solve equation system
syms x y z
solve(x+y+z==6,x-y+z==2,x+y-z==0,x,y,z)
ans =
<a href="matlab:helpPopup struct" style="font-weight:bold">struct</a> with fields:
x: [1×1 sym]
y: [1×1 sym]
z: [1×1 sym]
solve(x+y+z==6,x-y+z==2,x+y-z==0)
ans =
<a href="matlab:helpPopup struct" style="font-weight:bold">struct</a> with fields:
x: [1×1 sym]
y: [1×1 sym]
z: [1×1 sym]
xyz = solve(x+y+z==6,x-y+z==2,x+y-z==0)
xyz =
<a href="matlab:helpPopup struct" style="font-weight:bold">struct</a> with fields:
x: [1×1 sym]
y: [1×1 sym]
z: [1×1 sym]
xyz.x
ans =
1
y
y =
y
xyz.y
ans =
2
xyz.z
ans =
3
% symbolic constant
% vpa
a = vpa(pi)
a =
3.1415926535897932384626433832795
b = vpa(sqrt(2))
b =
1.4142135623730950488016887242097
c = a + b
c =
4.5558062159628882872643321074892
% we can change number of digits by using function "digits()"
digits(50)
a = vpa(pi)
a =
3.1415926535897932384626433832795028841971693993751
b = vpa(2)
b =
2.0
c = a + b
c =
5.1415926535897932384626433832795028841971693993751
b = vpa(sqrt(2))
b =
1.4142135623730950488016887242096980785696718753769
digits(5)
a = vpa(pi)
a =
3.1416
% how to display a "pretty" formula
syms x
y = (x-1)*(x-2)/((x-3)^3*(x-4))
y =
((x - 1)*(x - 2))/((x - 3)^3*(x - 4))
pretty(y)
(x - 1) (x - 2)
----------------
3
(x - 3) (x - 4)
% how to display a "pretty" formula 2
syms x
y = (x-1)*(x-2)/((x-3)^3*(x-4));
y_ltx = latex(y)
y_ltx =
'\frac{\left(x-1\right)\,\left(x-2\right)}{{\left(x-3\right)}^3\,\left(x-4\right)}'
% lets add $
y_ltx2 = ['$',y_ltx,'$']
y_ltx2 =
'$\frac{\left(x-1\right)\,\left(x-2\right)}{{\left(x-3\right)}^3\,\left(x-4\right)}$'
text(1,1,y_ltx2,'Interpreter','Latex')
text(0.5,0.5,y_ltx2,'Interpreter','Latex')
text(0.5,0.5,y_ltx2,'Interpreter','Latex','Fontsize',48)
text(0,0,y_ltx2,'Interpreter','Latex','Fontsize',48)
text(0,0.5,y_ltx2,'Interpreter','Latex','Fontsize',48)
text(0,0.5,y_ltx2,'Interpreter','Latex','Fontsize',48,'BackgroundColor','black')
text(0,0.5,y_ltx2,'Interpreter','Latex','Fontsize',48)
% how to simplify result
syms x
y = (x-1)*(x-2)/((x-3)^3*(x-4));
yd = diff(y)
yd =
(x - 1)/((x - 3)^3*(x - 4)) + (x - 2)/((x - 3)^3*(x - 4)) - ((x - 1)*(x - 2))/((x - 3)^3*(x - 4)^2) - (3*(x - 1)*(x - 2))/((x - 3)^4*(x - 4))
simplify(yd)
ans =
-(2*(x^3 - 5*x^2 + 4*x + 3))/((x - 3)^4*(x - 4)^2)
% other way to simplify
syms x
y = (x-1)/(x-2)
y =
(x - 1)/(x - 2)
expand(y)
ans =
x/(x - 2) - 1/(x - 2)
y = (x-1)*(x-2)
y =
(x - 1)*(x - 2)
expand(y)
ans =
x^2 - 3*x + 2
factor(y2)
{Undefined function or variable 'y2'.
}
y2 = expand(y)
y2 =
x^2 - 3*x + 2
factor(y2)
ans =
[ x - 1, x - 2]
horner(y)
ans =
x*(x - 3) + 2
% how to show the result graphically
syms x
y = x^2;
ezplot(y)
% how to calculate the result(this will be 2nd task of lab2)
% 1. in it given y = (x-1)*(x-2)/(sqrt(x-3)*(x-4))
% task is find derivative and plot y and y' on the graph by using plot function and then add the legend by using latex generator
% 2.
syms x
y = (x-1)*(x-2)/(sqrt(x-3)*(x-4));
% 3.
% take the derivative
yd = diff(y)
yd =
(x - 1)/((x - 3)^(1/2)*(x - 4)) + (x - 2)/((x - 3)^(1/2)*(x - 4)) - ((x - 1)*(x - 2))/((x - 3)^(1/2)*(x - 4)^2) - ((x - 1)*(x - 2))/(2*(x - 3)^(3/2)*(x - 4))
yd = simplify(diff(y))
yd =
(x^3 - 15*x^2 + 54*x - 52)/(2*(x - 3)^(3/2)*(x - 4)^2)
% 4. define x as numerical vector
x = -4:0.01:0;
% 5. vectorization
% we will put dot before( */ ^)
y_ltx = vectorize(y)
y_ltx =
'((x - 1).*(x - 2))./((x - 3).^(1./2).*(x - 4))'
yd_ltx = vectorize(yd)
yd_ltx =
'(54.*x - 15.*x.^2 + x.^3 - 52)./(2.*(x - 3).^(3./2).*(x - 4).^2)'
% 6. eval - interpreter function
yn = eval(y_ltx);
ydn = eval(yd_ltx)
ydn =
Columns 1 through 6
0.0000 - 0.2413i 0.0000 - 0.2415i 0.0000 - 0.2417i 0.0000 - 0.2418i 0.0000 - 0.2420i 0.0000 - 0.2422i
Columns 7 through 12
0.0000 - 0.2424i 0.0000 - 0.2426i 0.0000 - 0.2428i 0.0000 - 0.2430i 0.0000 - 0.2431i 0.0000 - 0.2433i
Columns 13 through 18
0.0000 - 0.2435i 0.0000 - 0.2437i 0.0000 - 0.2439i 0.0000 - 0.2441i 0.0000 - 0.2443i 0.0000 - 0.2445i
Columns 19 through 24
0.0000 - 0.2446i 0.0000 - 0.2448i 0.0000 - 0.2450i 0.0000 - 0.2452i 0.0000 - 0.2454i 0.0000 - 0.2456i
Columns 25 through 30
0.0000 - 0.2458i 0.0000 - 0.2460i 0.0000 - 0.2462i 0.0000 - 0.2464i 0.0000 - 0.2465i 0.0000 - 0.2467i
Columns 31 through 36
0.0000 - 0.2469i 0.0000 - 0.2471i 0.0000 - 0.2473i 0.0000 - 0.2475i 0.0000 - 0.2477i 0.0000 - 0.2479i
Columns 37 through 42
0.0000 - 0.2481i 0.0000 - 0.2483i 0.0000 - 0.2485i 0.0000 - 0.2487i 0.0000 - 0.2489i 0.0000 - 0.2491i
Columns 43 through 48
0.0000 - 0.2493i 0.0000 - 0.2495i 0.0000 - 0.2496i 0.0000 - 0.2498i 0.0000 - 0.2500i 0.0000 - 0.2502i
Columns 49 through 54
0.0000 - 0.2504i 0.0000 - 0.2506i 0.0000 - 0.2508i 0.0000 - 0.2510i 0.0000 - 0.2512i 0.0000 - 0.2514i
Columns 55 through 60
0.0000 - 0.2516i 0.0000 - 0.2518i 0.0000 - 0.2520i 0.0000 - 0.2522i 0.0000 - 0.2524i 0.0000 - 0.2526i
Columns 61 through 66
0.0000 - 0.2528i 0.0000 - 0.2530i 0.0000 - 0.2532i 0.0000 - 0.2534i 0.0000 - 0.2536i 0.0000 - 0.2538i
Columns 67 through 72
0.0000 - 0.2540i 0.0000 - 0.2542i 0.0000 - 0.2544i 0.0000 - 0.2546i 0.0000 - 0.2548i 0.0000 - 0.2550i
Columns 73 through 78
0.0000 - 0.2552i 0.0000 - 0.2554i 0.0000 - 0.2557i 0.0000 - 0.2559i 0.0000 - 0.2561i 0.0000 - 0.2563i
Columns 79 through 84
0.0000 - 0.2565i 0.0000 - 0.2567i 0.0000 - 0.2569i 0.0000 - 0.2571i 0.0000 - 0.2573i 0.0000 - 0.2575i
Columns 85 through 90
0.0000 - 0.2577i 0.0000 - 0.2579i 0.0000 - 0.2581i 0.0000 - 0.2583i 0.0000 - 0.2585i 0.0000 - 0.2587i
Columns 91 through 96
0.0000 - 0.2590i 0.0000 - 0.2592i 0.0000 - 0.2594i 0.0000 - 0.2596i 0.0000 - 0.2598i 0.0000 - 0.2600i
Columns 97 through 102
0.0000 - 0.2602i 0.0000 - 0.2604i 0.0000 - 0.2606i 0.0000 - 0.2608i 0.0000 - 0.2611i 0.0000 - 0.2613i
Columns 103 through 108
0.0000 - 0.2615i 0.0000 - 0.2617i 0.0000 - 0.2619i 0.0000 - 0.2621i 0.0000 - 0.2623i 0.0000 - 0.2625i
Columns 109 through 114
0.0000 - 0.2628i 0.0000 - 0.2630i 0.0000 - 0.2632i 0.0000 - 0.2634i 0.0000 - 0.2636i 0.0000 - 0.2638i
Columns 115 through 120
0.0000 - 0.2640i 0.0000 - 0.2643i 0.0000 - 0.2645i 0.0000 - 0.2647i 0.0000 - 0.2649i 0.0000 - 0.2651i
Columns 121 through 126
0.0000 - 0.2653i 0.0000 - 0.2655i 0.0000 - 0.2658i 0.0000 - 0.2660i 0.0000 - 0.2662i 0.0000 - 0.2664i
Columns 127 through 132
0.0000 - 0.2666i 0.0000 - 0.2669i 0.0000 - 0.2671i 0.0000 - 0.2673i 0.0000 - 0.2675i 0.0000 - 0.2677i
Columns 133 through 138
0.0000 - 0.2679i 0.0000 - 0.2682i 0.0000 - 0.2684i 0.0000 - 0.2686i 0.0000 - 0.2688i 0.0000 - 0.2690i
Columns 139 through 144
0.0000 - 0.2693i 0.0000 - 0.2695i 0.0000 - 0.2697i 0.0000 - 0.2699i 0.0000 - 0.2701i 0.0000 - 0.2704i
Columns 145 through 150
0.0000 - 0.2706i 0.0000 - 0.2708i 0.0000 - 0.2710i 0.0000 - 0.2713i 0.0000 - 0.2715i 0.0000 - 0.2717i
Columns 151 through 156
0.0000 - 0.2719i 0.0000 - 0.2721i 0.0000 - 0.2724i 0.0000 - 0.2726i 0.0000 - 0.2728i 0.0000 - 0.2730i
Columns 157 through 162
0.0000 - 0.2733i 0.0000 - 0.2735i 0.0000 - 0.2737i 0.0000 - 0.2739i 0.0000 - 0.2742i 0.0000 - 0.2744i
Columns 163 through 168
0.0000 - 0.2746i 0.0000 - 0.2748i 0.0000 - 0.2751i 0.0000 - 0.2753i 0.0000 - 0.2755i 0.0000 - 0.2757i
Columns 169 through 174
0.0000 - 0.2760i 0.0000 - 0.2762i 0.0000 - 0.2764i 0.0000 - 0.2766i 0.0000 - 0.2769i 0.0000 - 0.2771i
Columns 175 through 180
0.0000 - 0.2773i 0.0000 - 0.2775i 0.0000 - 0.2778i 0.0000 - 0.2780i 0.0000 - 0.2782i 0.0000 - 0.2784i
Columns 181 through 186
0.0000 - 0.2787i 0.0000 - 0.2789i 0.0000 - 0.2791i 0.0000 - 0.2794i 0.0000 - 0.2796i 0.0000 - 0.2798i
Columns 187 through 192
0.0000 - 0.2800i 0.0000 - 0.2803i 0.0000 - 0.2805i 0.0000 - 0.2807i 0.0000 - 0.2810i 0.0000 - 0.2812i
Columns 193 through 198
0.0000 - 0.2814i 0.0000 - 0.2816i 0.0000 - 0.2819i 0.0000 - 0.2821i 0.0000 - 0.2823i 0.0000 - 0.2825i
Columns 199 through 204
0.0000 - 0.2828i 0.0000 - 0.2830i 0.0000 - 0.2832i 0.0000 - 0.2835i 0.0000 - 0.2837i 0.0000 - 0.2839i
Columns 205 through 210
0.0000 - 0.2841i 0.0000 - 0.2844i 0.0000 - 0.2846i 0.0000 - 0.2848i 0.0000 - 0.2851i 0.0000 - 0.2853i
Columns 211 through 216
0.0000 - 0.2855i 0.0000 - 0.2858i 0.0000 - 0.2860i 0.0000 - 0.2862i 0.0000 - 0.2864i 0.0000 - 0.2867i
Columns 217 through 222
0.0000 - 0.2869i 0.0000 - 0.2871i 0.0000 - 0.2873i 0.0000 - 0.2876i 0.0000 - 0.2878i 0.0000 - 0.2880i
Columns 223 through 228
0.0000 - 0.2883i 0.0000 - 0.2885i 0.0000 - 0.2887i 0.0000 - 0.2889i 0.0000 - 0.2892i 0.0000 - 0.2894i
Columns 229 through 234
0.0000 - 0.2896i 0.0000 - 0.2899i 0.0000 - 0.2901i 0.0000 - 0.2903i 0.0000 - 0.2905i 0.0000 - 0.2908i
Columns 235 through 240
0.0000 - 0.2910i 0.0000 - 0.2912i 0.0000 - 0.2914i 0.0000 - 0.2917i 0.0000 - 0.2919i 0.0000 - 0.2921i
Columns 241 through 246
0.0000 - 0.2923i 0.0000 - 0.2926i 0.0000 - 0.2928i 0.0000 - 0.2930i 0.0000 - 0.2932i 0.0000 - 0.2935i
Columns 247 through 252
0.0000 - 0.2937i 0.0000 - 0.2939i 0.0000 - 0.2941i 0.0000 - 0.2944i 0.0000 - 0.2946i 0.0000 - 0.2948i
Columns 253 through 258
0.0000 - 0.2950i 0.0000 - 0.2952i 0.0000 - 0.2955i 0.0000 - 0.2957i 0.0000 - 0.2959i 0.0000 - 0.2961i
Columns 259 through 264
0.0000 - 0.2963i 0.0000 - 0.2966i 0.0000 - 0.2968i 0.0000 - 0.2970i 0.0000 - 0.2972i 0.0000 - 0.2974i
Columns 265 through 270
0.0000 - 0.2976i 0.0000 - 0.2979i 0.0000 - 0.2981i 0.0000 - 0.2983i 0.0000 - 0.2985i 0.0000 - 0.2987i
Columns 271 through 276
0.0000 - 0.2989i 0.0000 - 0.2991i 0.0000 - 0.2994i 0.0000 - 0.2996i 0.0000 - 0.2998i 0.0000 - 0.3000i
Columns 277 through 282
0.0000 - 0.3002i 0.0000 - 0.3004i 0.0000 - 0.3006i 0.0000 - 0.3008i 0.0000 - 0.3010i 0.0000 - 0.3012i
Columns 283 through 288
0.0000 - 0.3014i 0.0000 - 0.3016i 0.0000 - 0.3019i 0.0000 - 0.3021i 0.0000 - 0.3023i 0.0000 - 0.3025i
Columns 289 through 294
0.0000 - 0.3027i 0.0000 - 0.3029i 0.0000 - 0.3031i 0.0000 - 0.3033i 0.0000 - 0.3035i 0.0000 - 0.3037i
Columns 295 through 300
0.0000 - 0.3038i 0.0000 - 0.3040i 0.0000 - 0.3042i 0.0000 - 0.3044i 0.0000 - 0.3046i 0.0000 - 0.3048i
Columns 301 through 306
0.0000 - 0.3050i 0.0000 - 0.3052i 0.0000 - 0.3054i 0.0000 - 0.3056i 0.0000 - 0.3057i 0.0000 - 0.3059i
Columns 307 through 312
0.0000 - 0.3061i 0.0000 - 0.3063i 0.0000 - 0.3065i 0.0000 - 0.3067i 0.0000 - 0.3068i 0.0000 - 0.3070i
Columns 313 through 318
0.0000 - 0.3072i 0.0000 - 0.3074i 0.0000 - 0.3075i 0.0000 - 0.3077i 0.0000 - 0.3079i 0.0000 - 0.3080i
Columns 319 through 324
0.0000 - 0.3082i 0.0000 - 0.3084i 0.0000 - 0.3085i 0.0000 - 0.3087i 0.0000 - 0.3088i 0.0000 - 0.3090i
Columns 325 through 330
0.0000 - 0.3092i 0.0000 - 0.3093i 0.0000 - 0.3095i 0.0000 - 0.3096i 0.0000 - 0.3098i 0.0000 - 0.3099i
Columns 331 through 336
0.0000 - 0.3101i 0.0000 - 0.3102i 0.0000 - 0.3103i 0.0000 - 0.3105i 0.0000 - 0.3106i 0.0000 - 0.3108i
Columns 337 through 342
0.0000 - 0.3109i 0.0000 - 0.3110i 0.0000 - 0.3112i 0.0000 - 0.3113i 0.0000 - 0.3114i 0.0000 - 0.3115i
Columns 343 through 348
0.0000 - 0.3116i 0.0000 - 0.3118i 0.0000 - 0.3119i 0.0000 - 0.3120i 0.0000 - 0.3121i 0.0000 - 0.3122i
Columns 349 through 354
0.0000 - 0.3123i 0.0000 - 0.3124i 0.0000 - 0.3125i 0.0000 - 0.3126i 0.0000 - 0.3127i 0.0000 - 0.3128i
Columns 355 through 360
0.0000 - 0.3129i 0.0000 - 0.3130i 0.0000 - 0.3130i 0.0000 - 0.3131i 0.0000 - 0.3132i 0.0000 - 0.3133i
Columns 361 through 366
0.0000 - 0.3133i 0.0000 - 0.3134i 0.0000 - 0.3135i 0.0000 - 0.3135i 0.0000 - 0.3136i 0.0000 - 0.3136i
Columns 367 through 372
0.0000 - 0.3137i 0.0000 - 0.3137i 0.0000 - 0.3138i 0.0000 - 0.3138i 0.0000 - 0.3139i 0.0000 - 0.3139i
Columns 373 through 378
0.0000 - 0.3139i 0.0000 - 0.3139i 0.0000 - 0.3140i 0.0000 - 0.3140i 0.0000 - 0.3140i 0.0000 - 0.3140i
Columns 379 through 384
0.0000 - 0.3140i 0.0000 - 0.3140i 0.0000 - 0.3140i 0.0000 - 0.3140i 0.0000 - 0.3139i 0.0000 - 0.3139i
Columns 385 through 390
0.0000 - 0.3139i 0.0000 - 0.3139i 0.0000 - 0.3138i 0.0000 - 0.3138i 0.0000 - 0.3137i 0.0000 - 0.3137i
Columns 391 through 396
0.0000 - 0.3136i 0.0000 - 0.3136i 0.0000 - 0.3135i 0.0000 - 0.3134i 0.0000 - 0.3133i 0.0000 - 0.3133i
Columns 397 through 401
0.0000 - 0.3132i 0.0000 - 0.3131i 0.0000 - 0.3130i 0.0000 - 0.3128i 0.0000 - 0.3127i
ydn = eval(yd_ltx);
% 7. lets put the result on the graph
plot(x,yn,x,ydn)
[Warning: Imaginary parts of complex X and/or Y arguments ignored]
% 8. lets annotate the graph
y_latex = latex(y);
yd_latex = latex(yd);
h = legend(['$',y_latex,'$'],['$',yd_latex,'$']);
[Warning: Ignoring extra legend entries.]
[> In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('legend>set_children_and_strings', '/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p', 646)" style="font-weight:bold">legend>set_children_and_strings</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p',646,0)">line 646</a>)
In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('legend>make_legend', '/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p', 316)" style="font-weight:bold">legend>make_legend</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p',316,0)">line 316</a>)
In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('legend', '/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p', 259)" style="font-weight:bold">legend</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p',259,0)">line 259</a>)]
set(h,'Interpreter','latex')
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('matlab.graphics.illustration.Legend/set')" style="font-weight:bold">matlab.graphics.illustration.Legend/set</a>
Invalid or deleted object.
}
h = legend(['$',y_latex,'$'],['$',yd_latex,'$']);
[Warning: Ignoring extra legend entries.]
[> In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('legend>set_children_and_strings', '/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p', 646)" style="font-weight:bold">legend>set_children_and_strings</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p',646,0)">line 646</a>)
In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('legend>make_legend', '/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p', 316)" style="font-weight:bold">legend>make_legend</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p',316,0)">line 316</a>)
In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('legend', '/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p', 259)" style="font-weight:bold">legend</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/matlab/scribe/legend.p',259,0)">line 259</a>)]
set(h,'Interpreter','latex')
syms b, a, x
a =
3.1416
x =
Columns 1 through 12
-4.0000 -3.9900 -3.9800 -3.9700 -3.9600 -3.9500 -3.9400 -3.9300 -3.9200 -3.9100 -3.9000 -3.8900
Columns 13 through 24
-3.8800 -3.8700 -3.8600 -3.8500 -3.8400 -3.8300 -3.8200 -3.8100 -3.8000 -3.7900 -3.7800 -3.7700
Columns 25 through 36
-3.7600 -3.7500 -3.7400 -3.7300 -3.7200 -3.7100 -3.7000 -3.6900 -3.6800 -3.6700 -3.6600 -3.6500
Columns 37 through 48
-3.6400 -3.6300 -3.6200 -3.6100 -3.6000 -3.5900 -3.5800 -3.5700 -3.5600 -3.5500 -3.5400 -3.5300
Columns 49 through 60
-3.5200 -3.5100 -3.5000 -3.4900 -3.4800 -3.4700 -3.4600 -3.4500 -3.4400 -3.4300 -3.4200 -3.4100
Columns 61 through 72
-3.4000 -3.3900 -3.3800 -3.3700 -3.3600 -3.3500 -3.3400 -3.3300 -3.3200 -3.3100 -3.3000 -3.2900
Columns 73 through 84
-3.2800 -3.2700 -3.2600 -3.2500 -3.2400 -3.2300 -3.2200 -3.2100 -3.2000 -3.1900 -3.1800 -3.1700
Columns 85 through 96
-3.1600 -3.1500 -3.1400 -3.1300 -3.1200 -3.1100 -3.1000 -3.0900 -3.0800 -3.0700 -3.0600 -3.0500
Columns 97 through 108
-3.0400 -3.0300 -3.0200 -3.0100 -3.0000 -2.9900 -2.9800 -2.9700 -2.9600 -2.9500 -2.9400 -2.9300
Columns 109 through 120
-2.9200 -2.9100 -2.9000 -2.8900 -2.8800 -2.8700 -2.8600 -2.8500 -2.8400 -2.8300 -2.8200 -2.8100
Columns 121 through 132
-2.8000 -2.7900 -2.7800 -2.7700 -2.7600 -2.7500 -2.7400 -2.7300 -2.7200 -2.7100 -2.7000 -2.6900
Columns 133 through 144
-2.6800 -2.6700 -2.6600 -2.6500 -2.6400 -2.6300 -2.6200 -2.6100 -2.6000 -2.5900 -2.5800 -2.5700
Columns 145 through 156
-2.5600 -2.5500 -2.5400 -2.5300 -2.5200 -2.5100 -2.5000 -2.4900 -2.4800 -2.4700 -2.4600 -2.4500
Columns 157 through 168
-2.4400 -2.4300 -2.4200 -2.4100 -2.4000 -2.3900 -2.3800 -2.3700 -2.3600 -2.3500 -2.3400 -2.3300
Columns 169 through 180
-2.3200 -2.3100 -2.3000 -2.2900 -2.2800 -2.2700 -2.2600 -2.2500 -2.2400 -2.2300 -2.2200 -2.2100
Columns 181 through 192
-2.2000 -2.1900 -2.1800 -2.1700 -2.1600 -2.1500 -2.1400 -2.1300 -2.1200 -2.1100 -2.1000 -2.0900
Columns 193 through 204
-2.0800 -2.0700 -2.0600 -2.0500 -2.0400 -2.0300 -2.0200 -2.0100 -2.0000 -1.9900 -1.9800 -1.9700
Columns 205 through 216
-1.9600 -1.9500 -1.9400 -1.9300 -1.9200 -1.9100 -1.9000 -1.8900 -1.8800 -1.8700 -1.8600 -1.8500
Columns 217 through 228
-1.8400 -1.8300 -1.8200 -1.8100 -1.8000 -1.7900 -1.7800 -1.7700 -1.7600 -1.7500 -1.7400 -1.7300
Columns 229 through 240
-1.7200 -1.7100 -1.7000 -1.6900 -1.6800 -1.6700 -1.6600 -1.6500 -1.6400 -1.6300 -1.6200 -1.6100
Columns 241 through 252
-1.6000 -1.5900 -1.5800 -1.5700 -1.5600 -1.5500 -1.5400 -1.5300 -1.5200 -1.5100 -1.5000 -1.4900
Columns 253 through 264
-1.4800 -1.4700 -1.4600 -1.4500 -1.4400 -1.4300 -1.4200 -1.4100 -1.4000 -1.3900 -1.3800 -1.3700
Columns 265 through 276
-1.3600 -1.3500 -1.3400 -1.3300 -1.3200 -1.3100 -1.3000 -1.2900 -1.2800 -1.2700 -1.2600 -1.2500
Columns 277 through 288
-1.2400 -1.2300 -1.2200 -1.2100 -1.2000 -1.1900 -1.1800 -1.1700 -1.1600 -1.1500 -1.1400 -1.1300
Columns 289 through 300
-1.1200 -1.1100 -1.1000 -1.0900 -1.0800 -1.0700 -1.0600 -1.0500 -1.0400 -1.0300 -1.0200 -1.0100
Columns 301 through 312
-1.0000 -0.9900 -0.9800 -0.9700 -0.9600 -0.9500 -0.9400 -0.9300 -0.9200 -0.9100 -0.9000 -0.8900
Columns 313 through 324
-0.8800 -0.8700 -0.8600 -0.8500 -0.8400 -0.8300 -0.8200 -0.8100 -0.8000 -0.7900 -0.7800 -0.7700
Columns 325 through 336
-0.7600 -0.7500 -0.7400 -0.7300 -0.7200 -0.7100 -0.7000 -0.6900 -0.6800 -0.6700 -0.6600 -0.6500
Columns 337 through 348
-0.6400 -0.6300 -0.6200 -0.6100 -0.6000 -0.5900 -0.5800 -0.5700 -0.5600 -0.5500 -0.5400 -0.5300
Columns 349 through 360
-0.5200 -0.5100 -0.5000 -0.4900 -0.4800 -0.4700 -0.4600 -0.4500 -0.4400 -0.4300 -0.4200 -0.4100
Columns 361 through 372
-0.4000 -0.3900 -0.3800 -0.3700 -0.3600 -0.3500 -0.3400 -0.3300 -0.3200 -0.3100 -0.3000 -0.2900
Columns 373 through 384
-0.2800 -0.2700 -0.2600 -0.2500 -0.2400 -0.2300 -0.2200 -0.2100 -0.2000 -0.1900 -0.1800 -0.1700
Columns 385 through 396
-0.1600 -0.1500 -0.1400 -0.1300 -0.1200 -0.1100 -0.1000 -0.0900 -0.0800 -0.0700 -0.0600 -0.0500
Columns 397 through 401
-0.0400 -0.0300 -0.0200 -0.0100 0
solve(e^(b*x^2-x) + a == 100,x)
{Undefined function or variable 'e'.
}
syms e
e = exp(1)
e =
2.7183
solve(e^(b*x^2-x) + a == 100,x)
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('mpower')" style="font-weight:bold"> ^ </a>
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform
elementwise matrix powers, use '.^'.
}
solve(e.^(b*x.^2-x) + a == 100,x)
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('sym.getEqnsVars>checkVariables', '/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/@sym/getEqnsVars.m', 92)" style="font-weight:bold">sym.getEqnsVars>checkVariables</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/@sym/getEqnsVars.m',92,0)">line 92</a>)
Second argument must be a vector of symbolic variables.
Error in <a href="matlab:matlab.internal.language.introspective.errorDocCallback('sym.getEqnsVars', '/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/@sym/getEqnsVars.m', 54)" style="font-weight:bold">sym.getEqnsVars</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/@sym/getEqnsVars.m',54,0)">line 54</a>)
checkVariables(vars);
Error in <a href="matlab:matlab.internal.language.introspective.errorDocCallback('solve>getEqns', '/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m', 429)" style="font-weight:bold">solve>getEqns</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m',429,0)">line 429</a>)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in <a href="matlab:matlab.internal.language.introspective.errorDocCallback('solve', '/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m', 226)" style="font-weight:bold">solve</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m',226,0)">line 226</a>)
[eqns,vars,options] = getEqns(varargin{:});
}
syms x
solve(e.^(b*x.^2-x) + a == 100,x)
[Warning: Solutions are parameterized by the symbols: k. To include parameters and conditions in the solution, specify the
'ReturnConditions' value as 'true'.]
[> In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('solve>warnIfParams', '/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m', 475)" style="font-weight:bold">solve>warnIfParams</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m',475,0)">line 475</a>)
In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('solve', '/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m', 357)" style="font-weight:bold">solve</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m',357,0)">line 357</a>)]
[Warning: Solutions are valid under the following conditions: ((18.293*b - b*k*25.133i + 1.0)^(1/2) - 1.0)/b < 0 & in(k,
'integer');
0 < ((18.293*b - b*k*25.133i + 1.0)^(1/2) + 1.0)/b & in(k, 'integer'). To include parameters and conditions in the solution,
specify the 'ReturnConditions' value as 'true'.]
[> In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('solve>warnIfParams', '/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m', 482)" style="font-weight:bold">solve>warnIfParams</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m',482,0)">line 482</a>)
In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('solve', '/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m', 357)" style="font-weight:bold">solve</a> (<a href="matlab: opentoline('/usr/local/MATLAB/R2018a/toolbox/symbolic/symbolic/solve.m',357,0)">line 357</a>)]
ans =
-(0.5*((18.293*b - b*k*25.133i + 1.0)^(1/2) - 1.0))/b
(0.5*((18.293*b - b*k*25.133i + 1.0)^(1/2) + 1.0))/b
e
e =
2.7183
syms x
y = x/(sqrt(x^2+1)*(2+x^2))
y =
x/((x^2 + 1)^(1/2)*(x^2 + 2))
yi = int(y,x)
yi =
- (log(x - 2^(1/2)*1i)*1i)/2 - (log(x + 2^(1/2)*1i)*1i)/2 + (log(1 + (x^2 + 1)^(1/2)*1i - 2^(1/2)*x*1i)*1i)/2 + (log((x^2 + 1)^(1/2)*1i + 1 + 2^(1/2)*x*1i)*1i)/2
yi = simplify(yi)
yi =
- (log(x - 2^(1/2)*1i)*1i)/2 - (log(x + 2^(1/2)*1i)*1i)/2 + (log(1 + (x^2 + 1)^(1/2)*1i - 2^(1/2)*x*1i)*1i)/2 + (log((x^2 + 1)^(1/2)*1i + 1 + 2^(1/2)*x*1i)*1i)/2
x = -20:0.01:20
x =
Columns 1 through 12
-20.0000 -19.9900 -19.9800 -19.9700 -19.9600 -19.9500 -19.9400 -19.9300 -19.9200 -19.9100 -19.9000 -19.8900
Columns 13 through 24
-19.8800 -19.8700 -19.8600 -19.8500 -19.8400 -19.8300 -19.8200 -19.8100 -19.8000 -19.7900 -19.7800 -19.7700
Columns 25 through 36
-19.7600 -19.7500 -19.7400 -19.7300 -19.7200 -19.7100 -19.7000 -19.6900 -19.6800 -19.6700 -19.6600 -19.6500
Columns 37 through 48
-19.6400 -19.6300 -19.6200 -19.6100 -19.6000 -19.5900 -19.5800 -19.5700 -19.5600 -19.5500 -19.5400 -19.5300
Columns 49 through 60
-19.5200 -19.5100 -19.5000 -19.4900 -19.4800 -19.4700 -19.4600 -19.4500 -19.4400 -19.4300 -19.4200 -19.4100
Columns 61 through 72
-19.4000 -19.3900 -19.3800 -19.3700 -19.3600 -19.3500 -19.3400 -19.3300 -19.3200 -19.3100 -19.3000 -19.2900
Columns 73 through 84
-19.2800 -19.2700 -19.2600 -19.2500 -19.2400 -19.2300 -19.2200 -19.2100 -19.2000 -19.1900 -19.1800 -19.1700
Columns 85 through 96
-19.1600 -19.1500 -19.1400 -19.1300 -19.1200 -19.1100 -19.1000 -19.0900 -19.0800 -19.0700 -19.0600 -19.0500
Columns 97 through 108
-19.0400 -19.0300 -19.0200 -19.0100 -19.0000 -18.9900 -18.9800 -18.9700 -18.9600 -18.9500 -18.9400 -18.9300
Columns 109 through 120
-18.9200 -18.9100 -18.9000 -18.8900 -18.8800 -18.8700 -18.8600 -18.8500 -18.8400 -18.8300 -18.8200 -18.8100
Columns 121 through 132
-18.8000 -18.7900 -18.7800 -18.7700 -18.7600 -18.7500 -18.7400 -18.7300 -18.7200 -18.7100 -18.7000 -18.6900
Columns 133 through 144
-18.6800 -18.6700 -18.6600 -18.6500 -18.6400 -18.6300 -18.6200 -18.6100 -18.6000 -18.5900 -18.5800 -18.5700
Columns 145 through 156
-18.5600 -18.5500 -18.5400 -18.5300 -18.5200 -18.5100 -18.5000 -18.4900 -18.4800 -18.4700 -18.4600 -18.4500
Columns 157 through 168
-18.4400 -18.4300 -18.4200 -18.4100 -18.4000 -18.3900 -18.3800 -18.3700 -18.3600 -18.3500 -18.3400 -18.3300
Columns 169 through 180
-18.3200 -18.3100 -18.3000 -18.2900 -18.2800 -18.2700 -18.2600 -18.2500 -18.2400 -18.2300 -18.2200 -18.2100
Columns 181 through 192
-18.2000 -18.1900 -18.1800 -18.1700 -18.1600 -18.1500 -18.1400 -18.1300 -18.1200 -18.1100 -18.1000 -18.0900
Columns 193 through 204
-18.0800 -18.0700 -18.0600 -18.0500 -18.0400 -18.0300 -18.0200 -18.0100 -18.0000 -17.9900 -17.9800 -17.9700
Columns 205 through 216
-17.9600 -17.9500 -17.9400 -17.9300 -17.9200 -17.9100 -17.9000 -17.8900 -17.8800 -17.8700 -17.8600 -17.8500
Columns 217 through 228
-17.8400 -17.8300 -17.8200 -17.8100 -17.8000 -17.7900 -17.7800 -17.7700 -17.7600 -17.7500 -17.7400 -17.7300