summarylogtreecommitdiffstats
path: root/maxima-5.48.patch
blob: b81ed79a8d8c2dada3cbf916fa069618c7839cd0 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
From 8844bedf1f439261ae9280c6931702a98d2d15be Mon Sep 17 00:00:00 2001
From: cxzhong <chenxin.zhong@outlook.com>
Date: Tue, 14 Apr 2026 21:27:15 +0800
Subject: [PATCH] Upgrade to Maxima 5.49 and ECL 26.3.27

- Upgrade Maxima to 5.49 and ECL to 26.3.27
- Enhance robustness of *maxima-objdir* directory creation in maxima_lib.py
- Add warnings for fallback to ecl_lib in meson.build to improve ECL build reliability
- Format meson.build
- Align ECL first_env to 65536 bytes to fix flaky mprotect EINVAL crash
  (ECL 26.3.27 changed the main thread env from mmap-allocated to a static
  struct; mprotect() requires page alignment, which mmap() guaranteed but
  a static variable does not)

Co-authored-by: arojas <arojas@archlinux.org>
---
 .github/workflows/build.yml                   |   8 +-
 build/pkgs/ecl/checksums.ini                  |   4 +-
 build/pkgs/ecl/package-version.txt            |   2 +-
 ...8f741f69fd736f020b7fe4d3afc33e60ae6a.patch | 171 ------------------
 ...ed9777c43df20021788d2a4bfc0e9c6b4566.patch |  14 --
 .../patches/first_env_page_alignment.patch    |  24 +++
 build/pkgs/ecl/patches/write_error.patch      |  11 +-
 build/pkgs/ecl/spkg-configure.m4              |   2 +-
 build/pkgs/maxima/checksums.ini               |   4 +-
 build/pkgs/maxima/package-version.txt         |   2 +-
 build/pkgs/maxima/spkg-configure.m4           |   2 +-
 environment-3.12-linux-aarch64.yml            |  56 +++---
 environment-3.12-linux.yml                    |  58 +++---
 environment-3.12-macos-x86_64.yml             |  48 ++---
 environment-3.12-macos.yml                    |  48 ++---
 environment-3.12-win.yml                      |  58 +++---
 environment-3.13-linux-aarch64.yml            |  58 +++---
 environment-3.13-linux.yml                    |  58 +++---
 environment-3.13-macos-x86_64.yml             |  48 ++---
 environment-3.13-macos.yml                    |  48 ++---
 environment-3.13-win.yml                      |  58 +++---
 environment-3.14-linux-aarch64.yml            |  58 +++---
 environment-3.14-linux.yml                    |  58 +++---
 environment-3.14-macos-x86_64.yml             |  48 ++---
 environment-3.14-macos.yml                    |  48 ++---
 environment-3.14-win.yml                      |  58 +++---
 src/doc/en/constructions/calculus.rst         |   5 +-
 src/doc/zh/constructions/calculus.rst         |   5 +-
 src/sage/calculus/calculus.py                 |   6 +-
 src/sage/calculus/test_sympy.py               |   2 +-
 src/sage/calculus/tests.py                    |   2 +-
 src/sage/functions/bessel.py                  |   6 +-
 src/sage/interfaces/maxima.py                 |  33 ++--
 src/sage/interfaces/maxima_abstract.py        |  38 ++--
 src/sage/interfaces/maxima_lib.py             |  27 ++-
 src/sage/libs/meson.build                     |  35 +++-
 src/sage/manifolds/chart.py                   |   6 +-
 src/sage/manifolds/continuous_map.py          |  10 +-
 .../differentiable/automorphismfield_group.py |   3 +-
 src/sage/manifolds/differentiable/curve.py    |   2 +-
 src/sage/manifolds/differentiable/metric.py   |   8 +-
 .../pseudo_riemannian_submanifold.py          |   3 +-
 src/sage/manifolds/utilities.py               |  16 +-
 src/sage/matrix/matrix2.pyx                   |   4 +-
 src/sage/misc/functional.py                   |   6 +-
 src/sage/symbolic/expression.pyx              |   8 +-
 src/sage/symbolic/integration/external.py     |   7 +-
 src/sage/symbolic/integration/integral.py     |   9 +-
 src/sage/symbolic/relation.py                 |  14 --
 .../calculus_doctest.py                       |   2 +-
 subprojects/maxima.wrap                       |   8 +-
 .../packagefiles/maxima/configure.patch       |   2 +-
 subprojects/packagefiles/maxima/infodir.patch |   2 +-
 .../maxima/maxima_prefix_bin.patch            |  10 +-
 tools/update-conda.py                         |   4 +-
 55 files changed, 596 insertions(+), 739 deletions(-)
 delete mode 100644 build/pkgs/ecl/patches/1aec8f741f69fd736f020b7fe4d3afc33e60ae6a.patch
 delete mode 100644 build/pkgs/ecl/patches/f69ded9777c43df20021788d2a4bfc0e9c6b4566.patch
 create mode 100644 build/pkgs/ecl/patches/first_env_page_alignment.patch

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0da3b074c3a..aec51a9d9b1 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -29,7 +29,7 @@ concurrency:
 #
 # The three workflows:
 #
-#  - build.yml (with jobs test-new, test-long),
+#  - build.yml (with job test-long),
 #  - doc-build.yml,
 #  - doc-build-pdf.yml
 #
@@ -50,7 +50,7 @@ concurrency:
 # This baseline is transparently improved by our use of the GH Actions cache,
 # see https://docs.docker.com/build/ci/github-actions/cache/#cache-backend-api.
 #
-# Jobs test-long is only started after test-new completed;
+# Job test-long builds Sage and runs tests;
 # but the workflows doc-build.yml and doc-build-pdf.yml are started independently.
 #
 #  - When nothing is cached and the 3 workflows are launched in parallel,
@@ -156,7 +156,7 @@ jobs:
             NUMPROC=6
             USE_MAKEFLAGS=-k V=0 SAGE_NUM_THREADS=4 --output-sync=recurse
             TARGETS_PRE=build/make/Makefile
-            TARGETS=${{ needs.test-new.outputs.build_targets }}
+            TARGETS=build
 
       - name: Start container
         id: container
@@ -273,7 +273,7 @@ jobs:
             NUMPROC=6
             USE_MAKEFLAGS=-k V=0 SAGE_NUM_THREADS=4 --output-sync=recurse
             TARGETS_PRE=build/make/Makefile
-            TARGETS=${{ needs.test-new.outputs.build_targets }}
+            TARGETS=build
 
       - name: Start container
         id: container
diff --git a/build/pkgs/ecl/checksums.ini b/build/pkgs/ecl/checksums.ini
index 637bca10244..e57f69ab6d1 100644
--- a/build/pkgs/ecl/checksums.ini
+++ b/build/pkgs/ecl/checksums.ini
@@ -1,4 +1,4 @@
 tarball=ecl-VERSION.tgz
-sha1=b1641a3ecff85133bd0bd324bd0b611fb40f75cb
-sha256=e4ea65bb1861e0e495386bfa8bc673bd014e96d3cf9d91e9038f91435cbe622b
+sha1=fba3b9f358f38634d553540708d2409ed5c3562a
+sha256=416d5707bf11d2b3d8d33d6791419a786e4cc59ac0cc3ec505ee59b51a9f5c9a
 upstream_url=https://common-lisp.net/project/ecl/static/files/release/ecl-VERSION.tgz
diff --git a/build/pkgs/ecl/package-version.txt b/build/pkgs/ecl/package-version.txt
index f7f0d3a615c..84df5ab6743 100644
--- a/build/pkgs/ecl/package-version.txt
+++ b/build/pkgs/ecl/package-version.txt
@@ -1 +1 @@
-24.5.10
+26.3.27
diff --git a/build/pkgs/ecl/patches/1aec8f741f69fd736f020b7fe4d3afc33e60ae6a.patch b/build/pkgs/ecl/patches/1aec8f741f69fd736f020b7fe4d3afc33e60ae6a.patch
deleted file mode 100644
index 5e5287b1a61..00000000000
--- a/build/pkgs/ecl/patches/1aec8f741f69fd736f020b7fe4d3afc33e60ae6a.patch
+++ /dev/null
@@ -1,171 +0,0 @@
-diff --git a/src/c/backq.d b/src/c/backq.d
-index 973d5b9227af057d79a737f081d7d1064aded678..02c3cfbd44789cd4ac30a120704da4d92a6b47b7 100644
---- a/src/c/backq.d
-+++ b/src/c/backq.d
-@@ -259,5 +259,5 @@ quasiquote_macro(cl_object whole, cl_object env)
- void
- init_backq(void)
- {
--  ecl_def_c_macro(@'si::quasiquote', quasiquote_macro, 2);
-+  ecl_def_c_macro(@'si::quasiquote', (cl_objectfn_fixed)quasiquote_macro, 2);
- }
-diff --git a/src/c/cinit.d b/src/c/cinit.d
-index 54ac36abbfe8207c869ebd135a83daa6ec6e4f15..8f81d28d462a342857a0d5cf9810f7ce9a80e00a 100644
---- a/src/c/cinit.d
-+++ b/src/c/cinit.d
-@@ -188,7 +188,7 @@ main(int argc, char **args)
- #endif
-   ECL_SET(@'*features*', features);
-   top_level = _ecl_intern("TOP-LEVEL", cl_core.system_package);
--  ecl_def_c_function(top_level, si_simple_toplevel, 0);
-+  ecl_def_c_function(top_level, (cl_objectfn_fixed)si_simple_toplevel, 0);
-   _ecl_funcall1(top_level);
-   return(0);
- }
-diff --git a/src/c/dpp.c b/src/c/dpp.c
-index 462361f9fc7c4ed4cebab9c30a8f2c4b3f576ad3..82c86fedfe9cc2f4dfc22ae3e8b58e55cec84d8d 100644
---- a/src/c/dpp.c
-+++ b/src/c/dpp.c
-@@ -85,10 +85,7 @@
- #include <ctype.h>
- #include <string.h>
- #include <stdarg.h>
--
--#if defined(_MSC_VER) && (_MSC_VER >= 1800)
- #include <stdbool.h> 
--#endif
- 
- #define DPP
- #include <ecl/config.h>
-@@ -106,13 +103,6 @@
- #define TRUE            1
- #define FALSE           0
- 
--#ifndef __cplusplus
--#if ! ( defined(__bool_true_false_are_defined) \
--        &&__bool_true_false_are_defined )
--typedef int bool;
--#endif
--#endif
--
- FILE *in, *out;
- 
- char filename[BUFSIZ];
-diff --git a/src/c/file.d b/src/c/file.d
-index 6d0d4785bea79f677d1e82f82df713249570c5f0..798b0a37faf690f372266ca8b4fadfe0dbf61421 100644
---- a/src/c/file.d
-+++ b/src/c/file.d
-@@ -5166,7 +5166,7 @@ ecl_unread_char(ecl_character c, cl_object strm)
-   stream_dispatch_table(strm)->unread_char(strm, c);
- }
- 
--bool
-+int
- ecl_listen_stream(cl_object strm)
- {
-   return stream_dispatch_table(strm)->listen(strm);
-diff --git a/src/c/macros.d b/src/c/macros.d
-index 1a356241ee53741b0f2db71e92311dce474bdc45..d1cf7002216664bfb08012e993099abf254e93f1 100644
---- a/src/c/macros.d
-+++ b/src/c/macros.d
-@@ -179,7 +179,7 @@ void
- init_macros(void)
- {
-   ECL_SET(@'*macroexpand-hook*', @'funcall');
--  ecl_def_c_macro(@'or', or_macro, 2);
--  ecl_def_c_macro(@'and', and_macro, 2);
--  ecl_def_c_macro(@'when', when_macro, 2);
-+  ecl_def_c_macro(@'or', (cl_objectfn_fixed)or_macro, 2);
-+  ecl_def_c_macro(@'and', (cl_objectfn_fixed)and_macro, 2);
-+  ecl_def_c_macro(@'when', (cl_objectfn_fixed)when_macro, 2);
- }
-diff --git a/src/c/read.d b/src/c/read.d
-index 4fba0b93bde1a1434dffd2e5b421404774641401..356b94826433584133494621432d7b8367eaec11 100644
---- a/src/c/read.d
-+++ b/src/c/read.d
-@@ -2019,8 +2019,8 @@ extra_argument(int c, cl_object stream, cl_object d)
- }
- 
- 
--#define make_cf2(f)     ecl_make_cfun((f), ECL_NIL, NULL, 2)
--#define make_cf3(f)     ecl_make_cfun((f), ECL_NIL, NULL, 3)
-+#define make_cf2(f)     ecl_make_cfun((cl_objectfn_fixed)(f), ECL_NIL, NULL, 2)
-+#define make_cf3(f)     ecl_make_cfun((cl_objectfn_fixed)(f), ECL_NIL, NULL, 3)
- 
- void
- init_read(void)
-diff --git a/src/c/tcp.d b/src/c/tcp.d
-index f26275516e320363c72ab19f5a3f5f3c0d5be65a..8325b131db819bbfd673a07574436e8a5740a7af 100644
---- a/src/c/tcp.d
-+++ b/src/c/tcp.d
-@@ -32,6 +32,7 @@ extern int errno;
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <unistd.h>
-+#include <stdlib.h>
- #endif
- #include <string.h>
- 
-@@ -86,10 +87,6 @@ int connect_to_server(char *host, int port)
-   struct sockaddr *addr;        /* address to connect to */
-   struct hostent *host_ptr;
-   int addrlen;                  /* length of address */
--#if !defined(ECL_MS_WINDOWS_HOST)
--  extern char *getenv();
--  extern struct hostent *gethostbyname();
--#endif
-   int fd;                       /* Network socket */
- 
-   INIT_TCP
-diff --git a/src/h/ecl.h b/src/h/ecl.h
-index 42e7b1dc2f3e701f85009dd3f13797f18c0c09db..ee1fca141717954f15ae349ad7689bf8132959f1 100644
---- a/src/h/ecl.h
-+++ b/src/h/ecl.h
-@@ -22,6 +22,7 @@
- #include <stdarg.h>             /* va_list */
- #include <setjmp.h>             /* setjmp and buffers */
- #include <stdio.h>              /* FILE */
-+#include <stdbool.h>
- /* Microsoft VC++ does not have va_copy() */
- #if ( defined(_MSC_VER) && (_MSC_VER < 1800) ) || !defined(va_copy)
- #define va_copy(dst, src) \
-diff --git a/src/h/external.h b/src/h/external.h
-index a0276837dbfe6494071a032d874b30800008d89d..99b924344830d9c89378c50d3d428c305e93b601 100755
---- a/src/h/external.h
-+++ b/src/h/external.h
-@@ -744,7 +744,7 @@ extern ECL_API void ecl_force_output(cl_object strm);
- extern ECL_API void ecl_finish_output(cl_object strm);
- extern ECL_API void ecl_clear_input(cl_object strm);
- extern ECL_API void ecl_clear_output(cl_object strm);
--extern ECL_API bool ecl_listen_stream(cl_object strm);
-+extern ECL_API int ecl_listen_stream(cl_object strm);
- extern ECL_API cl_object ecl_file_position(cl_object strm);
- extern ECL_API cl_object ecl_file_position_set(cl_object strm, cl_object disp);
- extern ECL_API cl_object ecl_file_length(cl_object strm);
-diff --git a/src/h/internal.h b/src/h/internal.h
-index 2c9bec5c36a701efe0c0036d7e1b421d13397db5..b6d64e0ccc74279012ebd088665ef20190af6d65 100755
---- a/src/h/internal.h
-+++ b/src/h/internal.h
-@@ -468,7 +468,7 @@ extern void ecl_clear_bignum_registers(cl_env_ptr env);
- 
- /* threads/mutex.d */
- 
--extern cl_object si_mutex_timeout();
-+extern cl_object si_mutex_timeout(cl_object process, cl_object lock, cl_object timeout);
- 
- /* print.d */
- 
-diff --git a/src/h/object.h b/src/h/object.h
-index 1f9b581a22fbec2eab9bf8d24b9507714618f92a..bbf82bdb46f6ca59af35948ffca744cd93ee147d 100644
---- a/src/h/object.h
-+++ b/src/h/object.h
-@@ -23,9 +23,6 @@ extern "C" {
- #define TRUE            1       /*  boolean true value  */
- #define FALSE           0       /*  boolean false value  */
- 
--#if !defined(__cplusplus) && !defined(bool)
--typedef int bool;
--#endif
- typedef unsigned char byte;
- 
- /*
diff --git a/build/pkgs/ecl/patches/f69ded9777c43df20021788d2a4bfc0e9c6b4566.patch b/build/pkgs/ecl/patches/f69ded9777c43df20021788d2a4bfc0e9c6b4566.patch
deleted file mode 100644
index 1bc47ff6a5b..00000000000
--- a/build/pkgs/ecl/patches/f69ded9777c43df20021788d2a4bfc0e9c6b4566.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-diff --git a/src/c/ffi/libraries.d b/src/c/ffi/libraries.d
-index 9973ae457181db24a128496faa73284bfd484809..098cd483d41c32f2e93eccbf25f3f9276a424016 100644
---- a/src/c/ffi/libraries.d
-+++ b/src/c/ffi/libraries.d
-@@ -44,9 +44,6 @@
- # ifdef HAVE_DLFCN_H
- #  include <dlfcn.h>
- #  define INIT_PREFIX "init_fas_"
--#  ifdef bool
--#   undef bool
--#  endif
- # endif
- # ifdef HAVE_MACH_O_DYLD_H
- #  include <mach-o/dyld.h>
diff --git a/build/pkgs/ecl/patches/first_env_page_alignment.patch b/build/pkgs/ecl/patches/first_env_page_alignment.patch
new file mode 100644
index 00000000000..020e56b1510
--- /dev/null
+++ b/build/pkgs/ecl/patches/first_env_page_alignment.patch
@@ -0,0 +1,24 @@
+ECL 26.3.27 changed the main thread environment from mmap-allocated
+(page-aligned) to a static struct first_env. The ECL_USE_MPROTECT fast
+interrupt dispatch calls mprotect() on this struct, which requires the
+address to be page-aligned. The unaligned static variable causes
+mprotect() to fail with EINVAL when a signal arrives while interrupts
+are disabled (e.g. inside ecl_cons), crashing with "Unable to mprotect
+environment". Align first_env to 65536 bytes (covers 4K/16K/64K pages).
+See https://github.com/sagemath/sage/pulls/41879
+
+diff --git a/src/c/main.d b/src/c/main.d
+--- a/src/c/main.d
++++ b/src/c/main.d
+@@ -49,7 +49,12 @@
+ 
+ const char *ecl_self;
+-static struct cl_env_struct first_env;
++/* Align to page boundary: ECL_USE_MPROTECT calls mprotect() on this
++   struct for fast interrupt dispatch, which requires a page-aligned
++   address. Use 65536 to cover all common page sizes (4K/16K/64K).
++   Prior ECL versions allocated this via mmap() which is always
++   page-aligned; this was changed to a static variable in 26.3.27. */
++static struct cl_env_struct __attribute__((aligned(65536))) first_env;
+ 
+ /************************ GLOBAL INITIALIZATION ***********************/
diff --git a/build/pkgs/ecl/patches/write_error.patch b/build/pkgs/ecl/patches/write_error.patch
index 769187fc9ef..47a60a7497a 100644
--- a/build/pkgs/ecl/patches/write_error.patch
+++ b/build/pkgs/ecl/patches/write_error.patch
@@ -1,8 +1,7 @@
-diff --git a/src/c/file.d b/src/c/file.d
-index 2d15d50f8..199f24c4f 100755
---- a/src/c/file.d
-+++ b/src/c/file.d
-@@ -3536,7 +3536,8 @@ output_stream_write_byte8(cl_object strm, unsigned char *c, cl_index n)
+diff --git a/src/c/streams/strm_os.d b/src/c/streams/strm_os.d
+--- a/src/c/streams/strm_os.d
++++ b/src/c/streams/strm_os.d
+@@ -784,7 +784,8 @@ output_stream_write_byte8(cl_object strm, unsigned char *c, cl_index n)
    ecl_disable_interrupts();
    do {
      out = fwrite(c, sizeof(char), n, IO_STREAM_FILE(strm));
@@ -12,6 +11,4 @@ index 2d15d50f8..199f24c4f 100755
    ecl_enable_interrupts();
    return out;
  }
--- 
-2.20.1
 
diff --git a/build/pkgs/ecl/spkg-configure.m4 b/build/pkgs/ecl/spkg-configure.m4
index 7dbcfa6377b..7b9c11668bd 100644
--- a/build/pkgs/ecl/spkg-configure.m4
+++ b/build/pkgs/ecl/spkg-configure.m4
@@ -15,7 +15,7 @@ SAGE_SPKG_CONFIGURE([ecl], [
       AC_RUN_IFELSE([AC_LANG_PROGRAM([[
         #include <ecl/config.h>
       ]],[[
-        if (ECL_VERSION_NUMBER < 210201) { return 1; }
+        if (ECL_VERSION_NUMBER < 240510) { return 1; }
       ]])],
       [
         sage_spkg_install_ecl=no
diff --git a/build/pkgs/maxima/checksums.ini b/build/pkgs/maxima/checksums.ini
index 2b0e2828df0..f5590e9d2d5 100644
--- a/build/pkgs/maxima/checksums.ini
+++ b/build/pkgs/maxima/checksums.ini
@@ -1,4 +1,4 @@
 tarball=maxima-VERSION.tar.gz
-sha1=fff13f4c010e6daab65fbc8a6895c2bd79925177
-sha256=9104021b24fd53e8c03a983509cb42e937a925e8c0c85c335d7709a14fd40f7a
+sha1=d487e477030cfad6b3ab0ed2e2fcc88e553ce1fd
+sha256=6d401a4aa307cd3a5a9cadca4fa96c4ef0e24ff95a18bb6a8f803e3d2114adee
 upstream_url=https://sourceforge.net/projects/maxima/files/Maxima-source/VERSION-source/maxima-VERSION.tar.gz/download
diff --git a/build/pkgs/maxima/package-version.txt b/build/pkgs/maxima/package-version.txt
index 5ddc1d087c6..357e1c72e86 100644
--- a/build/pkgs/maxima/package-version.txt
+++ b/build/pkgs/maxima/package-version.txt
@@ -1 +1 @@
-5.47.0
+5.49.0
diff --git a/build/pkgs/maxima/spkg-configure.m4 b/build/pkgs/maxima/spkg-configure.m4
index 76c0373205a..0aff2fbb5cf 100644
--- a/build/pkgs/maxima/spkg-configure.m4
+++ b/build/pkgs/maxima/spkg-configure.m4
@@ -1,5 +1,5 @@
 SAGE_SPKG_CONFIGURE([maxima], [
-  m4_pushdef([SAGE_MAXIMA_MINVER],[5.45.0])dnl this version and higher allowed
+  m4_pushdef([SAGE_MAXIMA_MINVER],[5.48.0])dnl this version and higher allowed
   SAGE_SPKG_DEPCHECK([ecl], [
     dnl First check for the "maxima" executable in the user's PATH, because
     dnl we still use pexpect to communicate with it in a few places.
diff --git a/src/doc/en/constructions/calculus.rst b/src/doc/en/constructions/calculus.rst
index b6243b64dbc..fb7339ba0b1 100644
--- a/src/doc/en/constructions/calculus.rst
+++ b/src/doc/en/constructions/calculus.rst
@@ -155,7 +155,7 @@ Sage can also compute symbolic definite integrals involving limits.
     (x, k, w)
     sage: f = x^3 * e^(k*x) * sin(w*x)
     sage: f.integrate(x)
-    ((24*k^3*w - 24*k*w^3 - (k^6*w + 3*k^4*w^3 + 3*k^2*w^5 + w^7)*x^3 + 6*(k^5*w + 2*k^3*w^3 + k*w^5)*x^2 - 6*(3*k^4*w + 2*k^2*w^3 - w^5)*x)*cos(w*x)*e^(k*x) - (6*k^4 - 36*k^2*w^2 + 6*w^4 - (k^7 + 3*k^5*w^2 + 3*k^3*w^4 + k*w^6)*x^3 + 3*(k^6 + k^4*w^2 - k^2*w^4 - w^6)*x^2 - 6*(k^5 - 2*k^3*w^2 - 3*k*w^4)*x)*e^(k*x)*sin(w*x))/(k^8 + 4*k^6*w^2 + 6*k^4*w^4 + 4*k^2*w^6 + w^8)
+    ((24*k^3*w*e^(k*x) - 24*k*w^3*e^(k*x) - (k^6*w*e^(k*x) + 3*k^4*w^3*e^(k*x) + 3*k^2*w^5*e^(k*x) + w^7*e^(k*x))*x^3 + 6*(k^5*w*e^(k*x) + 2*k^3*w^3*e^(k*x) + k*w^5*e^(k*x))*x^2 - 6*(3*k^4*w*e^(k*x) + 2*k^2*w^3*e^(k*x) - w^5*e^(k*x))*x)*cos(w*x) - (6*k^4*e^(k*x) - 36*k^2*w^2*e^(k*x) + 6*w^4*e^(k*x) - (k^7*e^(k*x) + 3*k^5*w^2*e^(k*x) + 3*k^3*w^4*e^(k*x) + k*w^6*e^(k*x))*x^3 + 3*(k^6*e^(k*x) + k^4*w^2*e^(k*x) - k^2*w^4*e^(k*x) - w^6*e^(k*x))*x^2 - 6*(k^5*e^(k*x) - 2*k^3*w^2*e^(k*x) - 3*k*w^4*e^(k*x))*x)*sin(w*x))/(k^8 + 4*k^6*w^2 + 6*k^4*w^4 + 4*k^2*w^6 + w^8)
     sage: integrate(1/x^2, x, 1, infinity)
     1
 
@@ -257,8 +257,7 @@ is one way to compute LT's and
     (s, t)
     sage: f = t^5*exp(t)*sin(t)
     sage: L = laplace(f, t, s); L
-    3840*(s - 1)^5/(s^2 - 2*s + 2)^6 - 3840*(s - 1)^3/(s^2 - 2*s + 2)^5 +
-    720*(s - 1)/(s^2 - 2*s + 2)^4
+    240*(3*s^5 - 15*s^4 + 20*s^3 - 12*s + 4)/(s^12 - 12*s^11 + 72*s^10 - 280*s^9 + 780*s^8 - 1632*s^7 + 2624*s^6 - 3264*s^5 + 3120*s^4 - 2240*s^3 + 1152*s^2 - 384*s + 64)
 
 is another way.
 
diff --git a/src/doc/zh/constructions/calculus.rst b/src/doc/zh/constructions/calculus.rst
index 9f896a4658b..2b83dc19b45 100644
--- a/src/doc/zh/constructions/calculus.rst
+++ b/src/doc/zh/constructions/calculus.rst
@@ -148,7 +148,7 @@ Sage 还可以计算涉及极限的符号定积分。
     (x, k, w)
     sage: f = x^3 * e^(k*x) * sin(w*x)
     sage: f.integrate(x)
-    ((24*k^3*w - 24*k*w^3 - (k^6*w + 3*k^4*w^3 + 3*k^2*w^5 + w^7)*x^3 + 6*(k^5*w + 2*k^3*w^3 + k*w^5)*x^2 - 6*(3*k^4*w + 2*k^2*w^3 - w^5)*x)*cos(w*x)*e^(k*x) - (6*k^4 - 36*k^2*w^2 + 6*w^4 - (k^7 + 3*k^5*w^2 + 3*k^3*w^4 + k*w^6)*x^3 + 3*(k^6 + k^4*w^2 - k^2*w^4 - w^6)*x^2 - 6*(k^5 - 2*k^3*w^2 - 3*k*w^4)*x)*e^(k*x)*sin(w*x))/(k^8 + 4*k^6*w^2 + 6*k^4*w^4 + 4*k^2*w^6 + w^8)
+    ((24*k^3*w*e^(k*x) - 24*k*w^3*e^(k*x) - (k^6*w*e^(k*x) + 3*k^4*w^3*e^(k*x) + 3*k^2*w^5*e^(k*x) + w^7*e^(k*x))*x^3 + 6*(k^5*w*e^(k*x) + 2*k^3*w^3*e^(k*x) + k*w^5*e^(k*x))*x^2 - 6*(3*k^4*w*e^(k*x) + 2*k^2*w^3*e^(k*x) - w^5*e^(k*x))*x)*cos(w*x) - (6*k^4*e^(k*x) - 36*k^2*w^2*e^(k*x) + 6*w^4*e^(k*x) - (k^7*e^(k*x) + 3*k^5*w^2*e^(k*x) + 3*k^3*w^4*e^(k*x) + k*w^6*e^(k*x))*x^3 + 3*(k^6*e^(k*x) + k^4*w^2*e^(k*x) - k^2*w^4*e^(k*x) - w^6*e^(k*x))*x^2 - 6*(k^5*e^(k*x) - 2*k^3*w^2*e^(k*x) - 3*k*w^4*e^(k*x))*x)*sin(w*x))/(k^8 + 4*k^6*w^2 + 6*k^4*w^4 + 4*k^2*w^6 + w^8)
     sage: integrate(1/x^2, x, 1, infinity)
     1
 
@@ -241,8 +241,7 @@ Sage 还可以计算涉及极限的符号定积分。
     (s, t)
     sage: f = t^5*exp(t)*sin(t)
     sage: L = laplace(f, t, s); L
-    3840*(s - 1)^5/(s^2 - 2*s + 2)^6 - 3840*(s - 1)^3/(s^2 - 2*s + 2)^5 +
-    720*(s - 1)/(s^2 - 2*s + 2)^4
+    240*(3*s^5 - 15*s^4 + 20*s^3 - 12*s + 4)/(s^12 - 12*s^11 + 72*s^10 - 280*s^9 + 780*s^8 - 1632*s^7 + 2624*s^6 - 3264*s^5 + 3120*s^4 - 2240*s^3 + 1152*s^2 - 384*s + 64)
 
 上面是另一种方法。
 
diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
index ce06cc41157..629beed1115 100644
--- a/src/sage/calculus/calculus.py
+++ b/src/sage/calculus/calculus.py
@@ -133,8 +133,8 @@
     [x^2 + x   2*x^3]
     [      2 x^2 + x]
     sage: e^M
-    [          1/2*(e^(2*sqrt(x)) + 1)*e^(x - sqrt(x)) 1/2*(x*e^(2*sqrt(x)) - x)*sqrt(x)*e^(x - sqrt(x))]
-    [  1/2*(e^(2*sqrt(x)) - 1)*e^(x - sqrt(x))/x^(3/2)           1/2*(e^(2*sqrt(x)) + 1)*e^(x - sqrt(x))]
+    [        1/2*(e^(2*sqrt(x)) + 1)*e^(x - sqrt(x)) 1/2*x^(3/2)*(e^(2*sqrt(x)) - 1)*e^(x - sqrt(x))]
+    [1/2*(e^(2*sqrt(x)) - 1)*e^(x - sqrt(x))/x^(3/2)         1/2*(e^(2*sqrt(x)) + 1)*e^(x - sqrt(x))]
 
 Complex exponentiation works, but may require a patched version of
 maxima (:issue:`32898`) for now::
@@ -1247,7 +1247,7 @@ def limit(ex, *args, dir=None, taylor=False, algorithm='maxima', **kwargs):
 
         sage: limit(sin(x)/x, x, 0, algorithm='sympy')
         1
-        sage: limit(sin(x)/x, x, 0, algorithm='giac') # needs sage.libs.giac
+        sage: limit(sin(x)/x, x, 0, algorithm='giac')                                   # needs sage.libs.giac
         1
         sage: limit(x^x, x, 0, dir='+', algorithm='fricas') # optional - fricas
         1
diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
index aa084799a10..e081e9674d9 100644
--- a/src/sage/calculus/test_sympy.py
+++ b/src/sage/calculus/test_sympy.py
@@ -63,7 +63,7 @@
     sage: diff(tan(x), x)
     tan(x)^2 + 1
     sage: limit((tan(x+y) - tan(x))/y, y=0)
-    cos(x)^(-2)
+    tan(x)^2 + 1
     sage: diff(sin(2*x), x, 1)
     2*cos(2*x)
     sage: diff(sin(2*x), x, 2)
diff --git a/src/sage/calculus/tests.py b/src/sage/calculus/tests.py
index 905a0e5782f..59e43bb46d6 100644
--- a/src/sage/calculus/tests.py
+++ b/src/sage/calculus/tests.py
@@ -119,7 +119,7 @@
     sage: integrate(exp(1-x^2),x)
     1/2*sqrt(pi)*erf(x)*e
     sage: integrate(sin(x^2),x)
-    1/16*sqrt(pi)*((I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x) + (I - 1)*sqrt(2)*erf((1/2*I - 1/2)*sqrt(2)*x) - (I - 1)*sqrt(2)*erf(sqrt(-I)*x) + (I + 1)*sqrt(2)*erf((-1)^(1/4)*x))
+    1/16*sqrt(pi)*((I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x) - (I - 1)*sqrt(2)*erf(sqrt(-I)*x) - 2*sqrt(2)*imag_part(erf((-1)^(1/4)*x)) + 2*sqrt(2)*real_part(erf((-1)^(1/4)*x)))
 
     sage: integrate((1-x^2)^n,x)  # long time
     x*hypergeometric((1/2, -n), (3/2,), x^2*exp_polar(2*I*pi))
diff --git a/src/sage/functions/bessel.py b/src/sage/functions/bessel.py
index b1ad8028bde..79bf12575fe 100644
--- a/src/sage/functions/bessel.py
+++ b/src/sage/functions/bessel.py
@@ -1855,7 +1855,7 @@ class SphericalHankel1(BuiltinFunction):
         sage: spherical_hankel1(3 + 0.2 * I, 3)
         0.201654587512037 - 0.531281544239273*I
         sage: spherical_hankel1(1, x).simplify()
-        -(x + I)*e^(I*x)/x^2
+        -I*(-I*x + 1)*e^(I*x)/x^2
         sage: spherical_hankel1(3 + 2 * I, 5 - 0.2 * I)
         1.25375216869913 - 0.518011435921789*I
         sage: integrate(spherical_hankel1(3, x), x)
@@ -1952,11 +1952,11 @@ class SphericalHankel2(BuiltinFunction):
         sage: spherical_hankel2(3 + 0.2 * I, 3)
         0.0998874108557565 + 0.479149050937147*I
         sage: spherical_hankel2(1, x).simplify()
-        -(x - I)*e^(-I*x)/x^2
+        I*(I*x + 1)*e^(-I*x)/x^2
         sage: spherical_hankel2(2,i).simplify()
         -e
         sage: spherical_hankel2(2,x).simplify()
-        (-I*x^2 - 3*x + 3*I)*e^(-I*x)/x^3
+        -I*(x^2 - 3*I*x - 3)*e^(-I*x)/x^3
         sage: spherical_hankel2(3 + 2*I, 5 - 0.2*I)
         0.0217627632692163 + 0.0224001906110906*I
         sage: integrate(spherical_hankel2(3, x), x)
diff --git a/src/sage/interfaces/maxima.py b/src/sage/interfaces/maxima.py
index 73dc7b08014..0483c86a96b 100644
--- a/src/sage/interfaces/maxima.py
+++ b/src/sage/interfaces/maxima.py
@@ -194,7 +194,7 @@
 You can even nicely typeset the solution in latex::
 
     sage: latex(s)
-    \left[ \left[ a=-...{{\sqrt{79}\,i-11}\over{4}}... , b={{...\sqrt{79}\,i+9...}\over{4}} , c={{\sqrt{79}\,i+1}\over{10}} \right]  , \left[ a={{...\sqrt{79}\,i+11}\over{4}} , b=-...{{\sqrt{79}\,i-9...}\over{4}}... , c=-...{{...\sqrt{79}\,i-1}\over{10}}... \right]  \right]
+    \left[ \left[ a=-\left({{\sqrt{79}\,i-11}\over{4}}\right) , b={{\sqrt{79}\,i  +9}\over{4}} , c={{\sqrt{79}\,i+1}\over{10}} \right]  , \left[ a={{\sqrt{79}  \,i+11}\over{4}} , b=-\left({{\sqrt{79}\,i-9}\over{4}}\right) , c=-\left({{  \sqrt{79}\,i-1}\over{10}}\right) \right]  \right]
 
 To have the above appear onscreen via ``xdvi``, type
 ``view(s)``. (TODO: For OS X should create pdf output
@@ -216,11 +216,11 @@
 ::
 
     sage: f = maxima('x^3 * %e^(k*x) * sin(w*x)'); f
-    x^3*%e^(k*x)*sin(w*x)
+    %e^(k*x)*x^3*sin(w*x)
     sage: f.diff('x')
-    k*x^3*%e^(k*x)*sin(w*x)+3*x^2*%e^(k*x)*sin(w*x)+w*x^3*%e^(k*x) *cos(w*x)
+    %e^(k*x)*k*x^3*sin(w*x)+3*%e^(k*x)*x^2*sin(w*x)+%e^(k*x)*w*x^3 *cos(w*x)
     sage: f.integrate('x')
-    (((k*w^6+3*k^3*w^4+3*k^5*w^2+k^7)*x^3 +(3*w^6+3*k^2*w^4-3*k^4*w^2-3*k^6)*x^2+(...-...18*k*w^4)-12*k^3*w^2+6*k^5)*x-6*w^4 +36*k^2*w^2-6*k^4) *%e^(k*x)*sin(w*x) +((...-w^7...-3*k^2*w^5-3*k^4*w^3-k^6*w)*x^3...+(6*k*w^5+12*k^3*w^3+6*k^5*w)*x^2...+(6*w^5-12*k^2*w^3-18*k^4*w)*x-24*k*w^3 +24*k^3*w) *%e^(k*x)*cos(w*x)) /(w^8+4*k^2*w^6+6*k^4*w^4+4*k^6*w^2+k^8)
+    (((%e^(k*x)*k*w^6+3*%e^(k*x)*k^3*w^4+3*%e^(k*x)*k^5*w^2+%e^(k*x)*k^7)*x ^3 +(3*%e^(k*x)*w^6+3*%e^(k*x)*k^2*w^4-3*%e^(k*x)*k^4*w^2-3*%e^(k*x)*k^6)*x^2 +(-(18*%e^(k*x)*k*w^4)-12*%e^(k*x)*k^3*w^2+6*%e^(k*x)*k^5)*x-6*%e^(k*x)*w^4 +36*%e^(k*x)*k^2*w^2-6*%e^(k*x)*k^4) *sin(w*x) +((-(%e^(k*x)*w^7)-3*%e^(k*x)*k^2*w^5-3*%e^(k*x)*k^4*w^3-%e^(k*x)*k^6*w)*x^3 +(6*%e^(k*x)*k*w^5+12*%e^(k*x)*k^3*w^3+6*%e^(k*x)*k^5*w)*x^2 +(6*%e^(k*x)*w^5-12*%e^(k*x)*k^2*w^3-18*%e^(k*x)*k^4*w)*x-24*%e^(k*x)*k*w^3 +24*%e^(k*x)*k^3*w) *cos(w*x)) /(w^8+4*k^2*w^6+6*k^4*w^4+4*k^6*w^2+k^8)
 
 ::
 
@@ -291,13 +291,14 @@
 
     sage: _ = maxima.eval("f(t) := t^5*exp(t)*sin(t)")
     sage: maxima("laplace(f(t),t,s)")
-    (360*(2*s-2))/(s^2-2*s+2)^4-(480*(2*s-2)^3)/(s^2-2*s+2)^5 +(120*(2*s-2)^5)/(s^2-2*s+2)^6
+    (720*s^5-3600*s^4+4800*s^3-2880*s+960) /(s^12-12*s^11+72*s^10-280*s^9+780*s^8-1632*s^7+2624*s^6-3264*s^5+3120*s^4 -2240*s^3+1152*s^2-384*s+64)
     sage: print(maxima("laplace(f(t),t,s)"))
-                                             3                 5
-               360 (2 s - 2)    480 (2 s - 2)     120 (2 s - 2)
-              --------------- - --------------- + ---------------
-                2           4     2           5     2           6
-              (s  - 2 s + 2)    (s  - 2 s + 2)    (s  - 2 s + 2)
+                                                   5         4         3
+                                             (720 s  - 3600 s  + 4800 s  - 2880 s + 960)
+                                                12       11       10        9        8         7         6         5
+                                             /(s   - 12 s   + 72 s   - 280 s  + 780 s  - 1632 s  + 2624 s  - 3264 s
+                                                      4         3         2
+                                              + 3120 s  - 2240 s  + 1152 s  - 384 s + 64)
 
 ::
 
@@ -363,11 +364,11 @@
 
     sage: S = maxima('nusum(exp(1+2*i/n),i,1,n)')
     sage: print(S)
-                            2/n + 3                   2/n + 1
-                          %e                        %e
-                   ----------------------- - -----------------------
-                      1/n         1/n           1/n         1/n
-                   (%e    - 1) (%e    + 1)   (%e    - 1) (%e    + 1)
+                                     2/n + 3                   2/n + 1
+                                   %e                        %e
+                            ─────────────────────── - ───────────────────────
+                               1/n         1/n           1/n         1/n
+                            (%e    - 1) (%e    + 1)   (%e    - 1) (%e    + 1)
 
 We formally compute the limit as `n\to\infty` of
 `2S/n` as follows::
@@ -418,7 +419,7 @@
     sage: from sage.interfaces.maxima import maxima
     sage: g = maxima('exp(3*%i*x)/(6*%i) + exp(%i*x)/(2*%i) + c')
     sage: latex(g)
-    -...{{i\,e^{3\,i\,x}}\over{6}}...-{{i\,e^{i\,x}}\over{2}}+c
+    c-{{e^{3\,i\,x}\,i}\over{6}}-{{e^{i\,x}\,i}\over{2}}
 
 Long Input
 ----------
diff --git a/src/sage/interfaces/maxima_abstract.py b/src/sage/interfaces/maxima_abstract.py
index 7de873341b2..7f01255aa5f 100644
--- a/src/sage/interfaces/maxima_abstract.py
+++ b/src/sage/interfaces/maxima_abstract.py
@@ -864,11 +864,11 @@ def de_solve(self, de, vars, ics=None):
             sage: maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y'], [1,1,1])
             y = 3*x-2*%e^(x-1)
             sage: maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y'])
-            y = %k1*%e^x+%k2*%e^-x+3*x
+            y = 3*x+%e^-x*%k2+%e^x*%k1
             sage: maxima.de_solve('diff(y,x) + 3*x = y', ['x','y'])
-            y = (%c-3*(...-x...-1)*%e^-x)*%e^x
+            y = %e^x*(%c-3*%e^-x*(-x-1))
             sage: maxima.de_solve('diff(y,x) + 3*x = y', ['x','y'],[1,1])
-            y = -...%e^-1*(5*%e^x-3*%e*x-3*%e)...
+            y = %e^-1*(3*%e*x-5*%e^x+3*%e)
         """
         if not isinstance(vars, str):
             str_vars = '%s, %s' % (vars[1], vars[0])
@@ -908,20 +908,20 @@ def de_solve_laplace(self, de, vars, ics=None):
             sage: from sage.interfaces.maxima_lib import maxima
             sage: maxima.clear('x'); maxima.clear('f')
             sage: maxima.de_solve_laplace("diff(f(x),x,2) = 2*diff(f(x),x)-f(x)", ["x","f"], [0,1,2])
-            f(x) = x*%e^x+%e^x
+            f(x) = %e^x*x+%e^x
 
         ::
 
             sage: maxima.clear('x'); maxima.clear('f')
             sage: f = maxima.de_solve_laplace("diff(f(x),x,2) = 2*diff(f(x),x)-f(x)", ["x","f"])
             sage: f
-            f(x) = x*%e^x*('at('diff(f(x),x,1),x = 0))-f(0)*x*%e^x+f(0)*%e^x
+            f(x) = %e^x*x*('at('diff(f(x),x,1),x = 0))-%e^x*f(0)*x+%e^x*f(0)
             sage: print(f)
-                                               !
-                                   x  d        !                  x          x
-                        f(x) = x %e  (-- (f(x))!     ) - f(0) x %e  + f(0) %e
-                                      dx       !
-                                               !x = 0
+                                                                      │
+                                                        x    d        │           x            x
+                                               f(x) = %e  x (── (f(x))│     ) - %e  f(0) x + %e  f(0)
+                                                             dx       │
+                                                                      │x = 0
 
         .. NOTE::
 
@@ -1134,10 +1134,10 @@ def __str__(self):
             sage: f = maxima('1/(x-1)^3'); f
             1/(x-1)^3
             sage: print(f)
-                                                  1
-                                               --------
-                                                      3
-                                               (x - 1)
+                                                     1
+                                                  ────────
+                                                         3
+                                                  (x - 1)
         """
         return self.display2d(onscreen=False)
 
@@ -1793,9 +1793,9 @@ def _latex_(self):
             sage: y,d = var('y,d')
             sage: f = function('f')
             sage: latex(maxima(derivative(f(x*y), x)))
-            \left(\left.{{{\it \partial}}\over{{\it \partial}\,  {\it \_symbol}_{0}}}\,f\left(  {\it \_symbol}_{0}\right)\right|_{  {\it \_symbol}_{0}={\it x}\,  {\it y}}\right)\,{\it y}
+            \left(\left.{{{\it \partial}}\over{{\it \partial}\,  {\it \_symbol}_{0}}}\,f\left({\it \_symbol}_{0}  \right)\right|_{{\it \_symbol}_{0}={\it x}\,  {\it y}}\right)\,{\it y}
             sage: latex(maxima(derivative(f(x,y,d), d,x,x,y)))
-            {{{\it \partial}^4}\over{{\it \partial}\,{\it d}\,  {\it \partial}\,{\it x}^2\,{\it \partial}\,  {\it y}}}\,f\left({\it x} ,  {\it y} , {\it d}\right)
+            {{{\it \partial}^4}\over{{\it \partial}\,{\it d}\,  {\it \partial}\,{\it x}^2\,{\it \partial}\,{\it y}  }}\,f\left({\it x} , {\it y} , {\it d}  \right)
             sage: latex(maxima(d/(d-2)))
             {{{\it d}}\over{{\it d}-2}}
         """
@@ -1924,9 +1924,9 @@ def partial_fraction_decomposition(self, var='x'):
             sage: f.partial_fraction_decomposition('x')
             1/(2*(x-1))-1/(2*(x+1))
             sage: print(f.partial_fraction_decomposition('x'))
-                                 1           1
-                             --------- - ---------
-                             2 (x - 1)   2 (x + 1)
+                                     1           1
+                                 ───────── - ─────────
+                                 2 (x - 1)   2 (x + 1)
         """
         return self.partfrac(var)
 
diff --git a/src/sage/interfaces/maxima_lib.py b/src/sage/interfaces/maxima_lib.py
index 3fab1719223..b9ade64ea23 100644
--- a/src/sage/interfaces/maxima_lib.py
+++ b/src/sage/interfaces/maxima_lib.py
@@ -159,16 +159,21 @@
     # subject to the same race condition and since `*maxima-objdir*`
     # has multiple components this is quite plausible to happen.
     maxima_objdir = ecl_eval("*maxima-objdir*").python()[1:-1]
-    import os
     os.makedirs(maxima_objdir, exist_ok=True)
     # Call `(set-pathnames)` again to complete its job.
     ecl_eval("(set-pathnames)")
 
+# Always ensure *maxima-objdir* exists using Python's os.makedirs,
+# which is more robust than ECL's ensure-directories-exist on some
+# platforms (see :issue:`26968`).
+maxima_objdir = ecl_eval("*maxima-objdir*").python()[1:-1]
+os.makedirs(maxima_objdir, exist_ok=True)
+
 ecl_eval("(initialize-runtime-globals)")
 ecl_eval("(setq $nolabels t))")
 ecl_eval("(defun add-lineinfo (x) x)")
 ecl_eval(r"(defun tex-derivative (x l r) (tex (if $derivabbrev (tex-dabbrev x) (tex-d x '\\partial)) l r lop rop ))")
-ecl_eval('(defun principal nil (cond ($noprincipal (diverg)) ((not pcprntd) (merror "Divergent Integral"))))')
+ecl_eval('(defun principal nil (cond ($noprincipal (diverg)) ((not *pcprntd*) (merror "Divergent Integral"))))')
 ecl_eval("(remprop 'mfactorial 'grind)")  # don't use ! for factorials (#11539)
 ecl_eval("(setf $errormsg nil)")
 
@@ -233,7 +238,21 @@
 # See trac # 6818.
 init_code.append('nolabels : true')
 for l in init_code:
-    ecl_eval("#$%s$" % l)
+    try:
+        ecl_eval("#$%s$" % l)
+    except RuntimeError as e:
+        # When Maxima compiles share packages (e.g. linearalgebra) for the
+        # first time, it stores compiled binaries in subdirectories of
+        # *maxima-objdir*.  ECL's ensure-directories-exist may fail to
+        # create these subdirectories on some platforms; if so, create
+        # the missing directory with Python and retry.
+        import re
+        m = re.search(r'Cannot open #P"([^"]+)"', str(e))
+        if m:
+            os.makedirs(os.path.dirname(m.group(1)), exist_ok=True)
+            ecl_eval("#$%s$" % l)
+        else:
+            raise
 # To get more debug information uncomment the next line
 # should allow to do this through a method
 # ecl_eval("(setf *standard-output* original-standard-output)")
@@ -1228,6 +1247,8 @@ def reduce_load_MaximaLib():
     sage.functions.error.erf: "%ERF",
     sage.functions.gamma.gamma_inc: "%GAMMA_INCOMPLETE",
     sage.functions.other.conjugate: "$CONJUGATE",
+    sage.functions.other.imag_part: "%IMAGPART",
+    sage.functions.other.real_part: "%REALPART",
 }
 # we compile the dictionary
 sage_op_dict = {k: EclObject(sage_op_dict[k]) for k in sage_op_dict}
diff --git a/src/sage/libs/meson.build b/src/sage/libs/meson.build
index 85db5911c38..f775921cd59 100644
--- a/src/sage/libs/meson.build
+++ b/src/sage/libs/meson.build
@@ -7,11 +7,40 @@ if not sirocco.found()
     disabler: true,
   )
 endif
-# cannot be found via pkg-config
-ecl = cc.find_library('ecl', required: false, disabler: true)
-if not ecl.found() and not is_windows
+# ECL cannot be found via pkg-config; use ecl-config to get include dirs
+ecl_lib = cc.find_library('ecl', required: false, disabler: true)
+if ecl_lib.found()
+  ecl_config = find_program('ecl-config', required: false)
+  if ecl_config.found()
+    ecl_cflags = run_command(ecl_config, '--cflags', check: false)
+    if ecl_cflags.returncode() == 0
+      ecl_inc_args = []
+      foreach arg : ecl_cflags.stdout().strip().split()
+        if arg.startswith('-I')
+          ecl_inc_args += arg
+        endif
+      endforeach
+      ecl = declare_dependency(
+        dependencies: ecl_lib,
+        compile_args: ecl_inc_args,
+      )
+    else
+      warning(
+        'ecl-config --cflags failed; falling back to ecl_lib without include dirs. This may cause ECL to not work correctly in some incremental builds.',
+      )
+      ecl = ecl_lib
+    endif
+  else
+    warning(
+      'ecl-config not found; falling back to ecl_lib without include dirs. This may cause ECL to not work correctly in some incremental builds.',
+    )
+    ecl = ecl_lib
+  endif
+elif not is_windows
   ecl_proj = subproject('ecl')
   ecl = ecl_proj.get_variable('ecl_dep')
+else
+  ecl = ecl_lib
 endif
 ecl_bin = find_program('ecl', required: false)
 if ecl_bin.found()
diff --git a/src/sage/manifolds/chart.py b/src/sage/manifolds/chart.py
index fd0d0d0d83b..e8dc33dfa0d 100644
--- a/src/sage/manifolds/chart.py
+++ b/src/sage/manifolds/chart.py
@@ -3754,7 +3754,7 @@ def set_inverse(self, *transformations, **kwds):
             sage: spher_to_cart.set_inverse(sqrt(x^2+y^2), atan2(y,x))
             Check of the inverse coordinate transformation:
               r == r  *passed*
-              ph == arctan2(r*sin(ph), r*cos(ph))  **failed**
+              ph == -2*pi*ceil(-1/2*(pi - ph)/pi) + ph  **failed**
               x == x  *passed*
               y == y  *passed*
             NB: a failed report can reflect a mere lack of simplification.
@@ -3791,8 +3791,8 @@ def set_inverse(self, *transformations, **kwds):
 
             sage: spher_to_cart.set_inverse(sqrt(x^3+y^2), atan2(y,x))
             Check of the inverse coordinate transformation:
-              r == sqrt(r*cos(ph)^3 + sin(ph)^2)*r  **failed**
-              ph == arctan2(r*sin(ph), r*cos(ph))  **failed**
+              r == r*sqrt(abs(r*cos(ph)^3 + sin(ph)^2))  **failed**
+              ph == -2*pi*ceil(-1/2*(pi - ph)/pi) + ph  **failed**
               x == sqrt(x^3 + y^2)*x/sqrt(x^2 + y^2)  **failed**
               y == sqrt(x^3 + y^2)*y/sqrt(x^2 + y^2)  **failed**
             NB: a failed report can reflect a mere lack of simplification.
diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
index d407e448c91..44955d190f5 100644
--- a/src/sage/manifolds/continuous_map.py
+++ b/src/sage/manifolds/continuous_map.py
@@ -1576,7 +1576,7 @@ def expr(self, chart1=None, chart2=None):
             sage: ch_spher_cart.set_inverse(sqrt(x^2+y^2), atan2(y,x))
             Check of the inverse coordinate transformation:
               r == r  *passed*
-              ph == arctan2(r*sin(ph), r*cos(ph))  **failed**
+              ph == -2*pi*ceil(-1/2*(pi - ph)/pi) + ph  **failed**
               x == x  *passed*
               y == y  *passed*
             NB: a failed report can reflect a mere lack of simplification.
@@ -1625,7 +1625,7 @@ def set_expr(self, chart1, chart2, coord_functions):
               x == x  *passed*
               y == y  *passed*
               r == r  *passed*
-              ph == arctan2(r*sin(ph), r*cos(ph))  **failed**
+              ph == -2*pi*ceil(-1/2*(pi - ph)/pi) + ph  **failed**
             NB: a failed report can reflect a mere lack of simplification.
             sage: rot = U.continuous_map(U, ((x - sqrt(3)*y)/2, (sqrt(3)*x + y)/2),
             ....:                        name='R')
@@ -1679,7 +1679,7 @@ def set_expr(self, chart1, chart2, coord_functions):
               x == x  *passed*
               y == y  *passed*
               r == r  *passed*
-              ph == arctan2(r*sin(ph), r*cos(ph))  **failed**
+              ph == -2*pi*ceil(-1/2*(pi - ph)/pi) + ph  **failed**
             NB: a failed report can reflect a mere lack of simplification.
             sage: rot = U.continuous_map(U, ((x - sqrt(3)*y)/2, (sqrt(3)*x + y)/2),
             ....:                        name='R')
@@ -1768,7 +1768,7 @@ def add_expr(self, chart1, chart2, coord_functions):
               x == x  *passed*
               y == y  *passed*
               r == r  *passed*
-              ph == arctan2(r*sin(ph), r*cos(ph))  **failed**
+              ph == -2*pi*ceil(-1/2*(pi - ph)/pi) + ph  **failed**
             NB: a failed report can reflect a mere lack of simplification.
             sage: rot = U.continuous_map(U, ((x - sqrt(3)*y)/2, (sqrt(3)*x + y)/2),
             ....:                        name='R')
@@ -1782,7 +1782,7 @@ def add_expr(self, chart1, chart2, coord_functions):
 
             sage: rot.display(c_spher, c_spher)
             R: U → U
-               (r, ph) ↦ (r, arctan2(1/2*(sqrt(3)*cos(ph) + sin(ph))*r, -1/2*(sqrt(3)*sin(ph) - cos(ph))*r))
+               (r, ph) ↦ (r, arctan2(1/2*sqrt(3)*cos(ph) + 1/2*sin(ph), -1/2*sqrt(3)*sin(ph) + 1/2*cos(ph)))
 
         Therefore, we use the method :meth:`add_expr` to set the
         spherical-coordinate expression by hand::
diff --git a/src/sage/manifolds/differentiable/automorphismfield_group.py b/src/sage/manifolds/differentiable/automorphismfield_group.py
index 45a2fad087a..11a548a0317 100644
--- a/src/sage/manifolds/differentiable/automorphismfield_group.py
+++ b/src/sage/manifolds/differentiable/automorphismfield_group.py
@@ -535,8 +535,7 @@ class AutomorphismFieldParalGroup(FreeModuleLinearGroup):
         Field of tangent-space automorphisms t^(-1) on the 2-dimensional
          differentiable manifold M
         sage: (t1^(-1)).display()
-        t^(-1) = 1/(e^y + 1) ∂/∂x⊗dx - x*y/(x^2 + (x^2 + 1)*e^y + 1) ∂/∂x⊗dy
-         + 1/(x^2 + 1) ∂/∂y⊗dy
+        t^(-1) = 1/(e^y + 1) ∂/∂x⊗dx - x*y/(x^2*(e^y + 1) + e^y + 1) ∂/∂x⊗dy + 1/(x^2 + 1) ∂/∂y⊗dy
 
     Since any automorphism field can be considered as a tensor field of
     type-`(1,1)` on ``M``, there is a coercion map from ``G`` to the
diff --git a/src/sage/manifolds/differentiable/curve.py b/src/sage/manifolds/differentiable/curve.py
index 8a1cfc2e77e..9c1d518acc3 100644
--- a/src/sage/manifolds/differentiable/curve.py
+++ b/src/sage/manifolds/differentiable/curve.py
@@ -466,7 +466,7 @@ def coord_expr(self, chart=None):
               x == x  *passed*
               y == y  *passed*
               r == r  *passed*
-              ph == arctan2(r*sin(ph), r*cos(ph))  **failed**
+              ph == -2*pi*ceil(-1/2*(pi - ph)/pi) + ph  **failed**
             NB: a failed report can reflect a mere lack of simplification.
             sage: R.<t> = manifolds.RealLine()
             sage: c = U.curve({c_spher: (1,t)}, (t, 0, 2*pi), name='c')
diff --git a/src/sage/manifolds/differentiable/metric.py b/src/sage/manifolds/differentiable/metric.py
index 01b48ef9724..43758ba7e73 100644
--- a/src/sage/manifolds/differentiable/metric.py
+++ b/src/sage/manifolds/differentiable/metric.py
@@ -1556,9 +1556,9 @@ def sqrt_abs_det(self, frame=None):
             [ 1/8*u^2 - 1/8*v^2 + 1/4*v + 1/2                            1/4*u]
             [                           1/4*u -1/8*u^2 + 1/8*v^2 + 1/4*v + 1/2]
             sage: g.sqrt_abs_det(Y.frame()).expr()
-            1/2*sqrt(-x^2*y^2 - (x + 1)*y + x + 1)
+            1/2*sqrt(abs(x^2*y^2 + (x + 1)*y - x - 1))
             sage: g.sqrt_abs_det(Y.frame()).expr(Y)
-            1/8*sqrt(-u^4 - v^4 + 2*(u^2 + 2)*v^2 - 4*u^2 + 16*v + 16)
+            1/8*sqrt(abs(u^4 + v^4 - 2*(u^2 + 2)*v^2 + 4*u^2 - 16*v - 16))
 
         A chart can be passed instead of a frame::
 
@@ -1578,9 +1578,9 @@ def sqrt_abs_det(self, frame=None):
             sage: g.sqrt_abs_det().expr()
             sqrt(-x**2*y**2 - x*y + x - y + 1)
             sage: g.sqrt_abs_det(Y.frame()).expr()
-            sqrt(-x**2*y**2 - x*y + x - y + 1)/2
+            sqrt(Abs(x**2*y**2 + x*y - x + y - 1))/2
             sage: g.sqrt_abs_det(Y.frame()).expr(Y)
-            sqrt(-u**4 + 2*u**2*v**2 - 4*u**2 - v**4 + 4*v**2 + 16*v + 16)/8
+            sqrt(Abs(-u**4 + 2*u**2*v**2 - 4*u**2 - v**4 + 4*v**2 + 16*v + 16))/8
         """
         dom = self._domain
         if frame is None:
diff --git a/src/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py b/src/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py
index 57dc1c99862..e7c7aaebeea 100644
--- a/src/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py
+++ b/src/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py
@@ -819,8 +819,7 @@ def normal(self):
             ....:                              atan2(-y,-x)+pi)
             Check of the inverse coordinate transformation:
               the == 2*arctan(sqrt(-cos(the) + 1)/sqrt(cos(the) + 1))  **failed**
-              phi == pi + arctan2(sin(phi)*sin(the)/(cos(the) - 1),
-                                  cos(phi)*sin(the)/(cos(the) - 1))  **failed**
+              phi == pi + arctan2(cos(the)*sin(phi) - sin(phi), cos(phi)*cos(the) - cos(phi))  **failed**
               x == x  *passed*
               y == y  *passed*
             NB: a failed report can reflect a mere lack of simplification.
diff --git a/src/sage/manifolds/utilities.py b/src/sage/manifolds/utilities.py
index 8adfe33b991..693d01736b8 100644
--- a/src/sage/manifolds/utilities.py
+++ b/src/sage/manifolds/utilities.py
@@ -226,10 +226,10 @@ class SimplifyAbsTrig(ExpressionTreeWalker):
         sage: a = abs(cos(x)) + abs(sin(x))
 
     The method :meth:`~sage.symbolic.expression.Expression.simplify_full()`
-    is ineffective on such an expression::
+    works on such an expression::
 
         sage: a.simplify_full()
-        abs(cos(x)) + abs(sin(x))
+        -cos(x) + sin(x)
 
     We construct a :class:`SimplifyAbsTrig` object ``s`` from the symbolic
     expression ``a``::
@@ -437,9 +437,9 @@ def simplify_abs_trig(expr):
 
         sage: s = abs(sin(x)) + abs(sin(y)) + abs(sin(3*z))
         sage: s.simplify_trig()
-        abs(4*cos(-z)^2 - 1)*abs(sin(-z)) + abs(sin(x)) + abs(sin(y))
+        -4*sin(-z)^3 + abs(sin(x)) + sin(y) + 3*sin(-z)
         sage: s.simplify_full()
-        abs(4*cos(-z)^2 - 1)*abs(sin(-z)) + abs(sin(x)) + abs(sin(y))
+        -4*sin(-z)^3 + abs(sin(x)) + sin(y) + 3*sin(-z)
 
     despite the following assumptions hold::
 
@@ -572,10 +572,10 @@ def simplify_chain_real(expr):
         sage: s = abs(sin(pi*x))
         sage: simplify_chain_real(s)  # correct output since x in (0,1)
         sin(pi*x)
-        sage: s.simplify_real()  # unsimplified output
-        abs(sin(pi*x))
-        sage: s.simplify_full()  # unsimplified output
-        abs(sin(pi*x))
+        sage: s.simplify_real()  # simplified output with maxima>=5.48
+        sin(pi*x)
+        sage: s.simplify_full()  # simplified output with maxima>=5.48
+        sin(pi*x)
 
     ::
 
diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
index e5afd226aee..5cb158c18e7 100644
--- a/src/sage/matrix/matrix2.pyx
+++ b/src/sage/matrix/matrix2.pyx
@@ -16531,8 +16531,8 @@ cdef class Matrix(Matrix1):
 
             sage: a = matrix([[1,2], [3,4]])
             sage: a.exp()
-            [-1/22*((sqrt(33) - 11)*e^sqrt(33) - sqrt(33) - 11)*e^(-1/2*sqrt(33) + 5/2)              2/33*(sqrt(33)*e^sqrt(33) - sqrt(33))*e^(-1/2*sqrt(33) + 5/2)]
-            [             1/11*(sqrt(33)*e^sqrt(33) - sqrt(33))*e^(-1/2*sqrt(33) + 5/2)  1/22*((sqrt(33) + 11)*e^sqrt(33) - sqrt(33) + 11)*e^(-1/2*sqrt(33) + 5/2)]
+            [ 1/22*((sqrt(33) + 11)*e^2 - (sqrt(33) - 11)*e^(sqrt(33) + 2))*e^(-1/2*sqrt(33) + 1/2)               -2/33*(sqrt(33)*e^2 - sqrt(33)*e^(sqrt(33) + 2))*e^(-1/2*sqrt(33) + 1/2)]
+            [              -1/11*(sqrt(33)*e^2 - sqrt(33)*e^(sqrt(33) + 2))*e^(-1/2*sqrt(33) + 1/2) -1/22*((sqrt(33) - 11)*e^2 - (sqrt(33) + 11)*e^(sqrt(33) + 2))*e^(-1/2*sqrt(33) + 1/2)]
 
             sage: type(a.exp())                                                         # needs sage.symbolic
             <class 'sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense'>
diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
index cc854cb0d7b..eeff8ac6186 100644
--- a/src/sage/misc/functional.py
+++ b/src/sage/misc/functional.py
@@ -719,9 +719,7 @@ def integral(x, *args, **kwds):
         real
         sage: f = exp(-x) * sinh(sqrt(x))
         sage: t = integrate(f, x, 0, Infinity); t           # long time
-        1/4*sqrt(pi)*(erf(1) - 1)*e^(1/4)
-         - 1/4*(sqrt(pi)*(erf(1) - 1) - sqrt(pi) + 2*e^(-1) - 2)*e^(1/4)
-         + 1/4*sqrt(pi)*e^(1/4) - 1/2*e^(1/4) + 1/2*e^(-3/4)
+        1/2*sqrt(pi)*e^(1/4)
         sage: t.canonicalize_radical()                      # long time
         1/2*sqrt(pi)*e^(1/4)
         sage: sage.calculus.calculus.maxima('domain: complex')
@@ -929,7 +927,7 @@ def krull_dimension(x):
         0
         sage: ZZ.krull_dimension()
         1
-        sage: ZZ[sqrt(5)].krull_dimension()                                              # needs sage.rings.number_field sage.symbolic
+        sage: ZZ[sqrt(5)].krull_dimension()                                             # needs sage.rings.number_field sage.symbolic
         1
         sage: U.<x,y,z> = PolynomialRing(ZZ, 3); U
         Multivariate Polynomial Ring in x, y, z over Integer Ring
diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
index 103cd40eed5..07d1b8dbb80 100644
--- a/src/sage/symbolic/expression.pyx
+++ b/src/sage/symbolic/expression.pyx
@@ -13019,21 +13019,21 @@ cdef class Expression(Expression_abc):
         Check that the sum in :issue:`10682` is done right::
 
             sage: sum(binomial(n,k)*k^2, k, 2, n)
-            1/4*(n^2 + n)*2^n - n
+            1/4*2^n*n^2 + 1/4*(2^n - 4)*n
 
         This sum used to give a wrong result (:issue:`9635`) but
         now gives correct results with all relevant assumptions::
 
             sage: (n,k,j)=var('n,k,j')
             sage: sum(binomial(n,k)*binomial(k-1,j)*(-1)**(k-1-j),k,j+1,n)
-            -(-1)^j*sum((-1)^k*binomial(k - 1, j)*binomial(n, k), k, j + 1, n)
+            -sum((-1)^(-j + k)*binomial(k - 1, j)*binomial(n, k), k, j + 1, n)
             sage: assume(j>-1)
             sage: sum(binomial(n,k)*binomial(k-1,j)*(-1)**(k-1-j),k,j+1,n)
             1
             sage: forget()
             sage: assume(n>=j)
             sage: sum(binomial(n,k)*binomial(k-1,j)*(-1)**(k-1-j),k,j+1,n)
-            -(-1)^j*sum((-1)^k*binomial(k - 1, j)*binomial(n, k), k, j + 1, n)
+            -sum((-1)^(-j + k)*binomial(k - 1, j)*binomial(n, k), k, j + 1, n)
             sage: forget()
             sage: assume(j==-1)
             sage: sum(binomial(n,k)*binomial(k-1,j)*(-1)**(k-1-j),k,j+1,n)
@@ -13041,7 +13041,7 @@ cdef class Expression(Expression_abc):
             sage: forget()
             sage: assume(j<-1)
             sage: sum(binomial(n,k)*binomial(k-1,j)*(-1)**(k-1-j),k,j+1,n)
-            -(-1)^j*sum((-1)^k*binomial(k - 1, j)*binomial(n, k), k, j + 1, n)
+            -sum((-1)^(-j + k)*binomial(k - 1, j)*binomial(n, k), k, j + 1, n)
             sage: forget()
 
         Check that :issue:`16176` is fixed::
diff --git a/src/sage/symbolic/integration/external.py b/src/sage/symbolic/integration/external.py
index 17f11b63779..a990791ac06 100644
--- a/src/sage/symbolic/integration/external.py
+++ b/src/sage/symbolic/integration/external.py
@@ -31,12 +31,7 @@ def maxima_integrator(expression, v, a=None, b=None):
     Check that :issue:`25817` is fixed::
 
         sage: maxima_integrator(log(e^x*log(x)*sin(x))/x^2, x)
-        1/2*(x*(Ei(-log(x)) + conjugate(Ei(-log(x))))
-        - 2*x*integrate(sin(x)/(x*cos(x)^2 + x*sin(x)^2
-        + 2*x*cos(x) + x), x) + 2*x*integrate(sin(x)/(x*cos(x)^2
-        + x*sin(x)^2 - 2*x*cos(x) + x), x) + 2*x*log(x) + 2*log(2)
-        - log(cos(x)^2 + sin(x)^2 + 2*cos(x) + 1) - log(cos(x)^2
-        + sin(x)^2 - 2*cos(x) + 1) - 2*log(log(x)))/x
+        -1/2*(2*x*integrate(sin(x)/(x*cos(x)^2 + x*sin(x)^2 + 2*x*cos(x) + x), x) - 2*x*integrate(sin(x)/(x*cos(x)^2 + x*sin(x)^2 - 2*x*cos(x) + x), x) - 2*x*log(x) - 2*x*real_part(Ei(-log(x))) - 2*log(2) + log(cos(x)^2 + sin(x)^2 + 2*cos(x) + 1) + log(cos(x)^2 + sin(x)^2 - 2*cos(x) + 1) + 2*log(log(x)))/x
     """
     from sage.calculus.calculus import maxima
     if not isinstance(expression, Expression):
diff --git a/src/sage/symbolic/integration/integral.py b/src/sage/symbolic/integration/integral.py
index dfdb0dd07b7..251f52f155f 100644
--- a/src/sage/symbolic/integration/integral.py
+++ b/src/sage/symbolic/integration/integral.py
@@ -612,10 +612,7 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None, hold=False):
                  x y  + Sqrt[--] FresnelS[Sqrt[--] x]
                              2                 Pi
         sage: print(f.integral(x))
-        x*y^z + 1/16*sqrt(pi)*((I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x)
-                                + (I - 1)*sqrt(2)*erf((1/2*I - 1/2)*sqrt(2)*x)
-                                - (I - 1)*sqrt(2)*erf(sqrt(-I)*x)
-                                + (I + 1)*sqrt(2)*erf((-1)^(1/4)*x))
+        x*y^z + 1/16*sqrt(pi)*((I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x) - (I - 1)*sqrt(2)*erf(sqrt(-I)*x) - 2*sqrt(2)*imag_part(erf((-1)^(1/4)*x)) + 2*sqrt(2)*real_part(erf((-1)^(1/4)*x)))
 
     Alternatively, just use algorithm='mathematica_free' to integrate via Mathematica
     over the internet (does NOT require a Mathematica license!)::
@@ -1011,8 +1008,8 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None, hold=False):
         sage: f = log(sin(x))*sin(x)^2
         sage: g = integrate(f, x) ; g
         1/4*I*x^2
+        - 1/2*I*x*arctan2(-sin(x), -cos(x) + 1)
         - 1/2*I*x*arctan2(sin(x), cos(x) + 1)
-        + 1/2*I*x*arctan2(sin(x), -cos(x) + 1)
         - 1/4*x*log(cos(x)^2 + sin(x)^2 + 2*cos(x) + 1)
         - 1/4*x*log(cos(x)^2 + sin(x)^2 - 2*cos(x) + 1)
         + 1/4*(2*x - sin(2*x))*log(sin(x))
@@ -1036,7 +1033,7 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None, hold=False):
         sage: assume(a > 0)
         sage: assume(a < 1)
         sage: integrate(x*log(1/(a*x+(1-x)^2)), x, 0, 1, algorithm='maxima')
-        1/4*a^2*log(a) + 1/2*sqrt(-a^2 + 4*a)*a*arctan(sqrt(-a^2 + 4*a)*(a - 2)/(a^2 - 4*a)) - 1/2*sqrt(-a^2 + 4*a)*a*arctan(sqrt(-a^2 + 4*a)/(a - 4)) - a*log(a) - sqrt(-a^2 + 4*a)*arctan(sqrt(-a^2 + 4*a)*(a - 2)/(a^2 - 4*a)) + sqrt(-a^2 + 4*a)*arctan(sqrt(-a^2 + 4*a)/(a - 4)) - 1/2*a + 3/2
+        1/4*a^2*log(a) - 1/2*sqrt(-a^2 + 4*a)*a*arctan(sqrt(-a^2 + 4*a)/(a - 4)) + 1/2*sqrt(-a^2 + 4*a)*a*arctan(sqrt(-a^2 + 4*a)*(a - 2)/((a - 4)*a)) - a*log(a) + sqrt(-a^2 + 4*a)*arctan(sqrt(-a^2 + 4*a)/(a - 4)) - sqrt(-a^2 + 4*a)*arctan(sqrt(-a^2 + 4*a)*(a - 2)/((a - 4)*a)) - 1/2*a + 3/2
 
     Check that :issue:`25905` is fixed::
 
diff --git a/src/sage/symbolic/relation.py b/src/sage/symbolic/relation.py
index f2478769d70..1aa8438cdc1 100644
--- a/src/sage/symbolic/relation.py
+++ b/src/sage/symbolic/relation.py
@@ -1332,20 +1332,6 @@ def _solve_expression(f, x, explicit_solutions, multiplicities,
         sage: (x^2>1).solve(x)
         [[x < -1], [x > 1]]
 
-    Catch error message from Maxima::
-
-        sage: solve(acot(x),x)
-        Traceback (most recent call last):
-        ...
-        TypeError: ECL says: cot: argument 0 isn't in the domain of cot.
-
-    ::
-
-        sage: solve(acot(x),x,to_poly_solve=True)
-        Traceback (most recent call last):
-        ...
-        TypeError: ECL says: cot: argument 0 isn't in the domain of cot.
-
     :issue:`7491` fixed::
 
         sage: y = var('y')
diff --git a/src/sage/tests/books/computational_mathematics_with_sagemath/calculus_doctest.py b/src/sage/tests/books/computational_mathematics_with_sagemath/calculus_doctest.py
index b5531b112b4..15f74fe5779 100644
--- a/src/sage/tests/books/computational_mathematics_with_sagemath/calculus_doctest.py
+++ b/src/sage/tests/books/computational_mathematics_with_sagemath/calculus_doctest.py
@@ -256,7 +256,7 @@
 Sage example in ./calculus.tex, line 1086::
 
   sage: solve(x^(1/x)==(1/x)^x, x)
-  [(1/x)^x == x^(1/x)]
+    [x^(1/x) == (1/x)^x]
 
 Sage example in ./calculus.tex, line 1124::
 
diff --git a/subprojects/maxima.wrap b/subprojects/maxima.wrap
index 6a9c8359de1..c28f6b13cf0 100644
--- a/subprojects/maxima.wrap
+++ b/subprojects/maxima.wrap
@@ -1,8 +1,8 @@
 [wrap-file]
-source_url = https://sourceforge.net/projects/maxima/files/Maxima-source/5.47.0-source/maxima-5.47.0.tar.gz/download
-source_hash = 9104021b24fd53e8c03a983509cb42e937a925e8c0c85c335d7709a14fd40f7a
-source_filename = maxima-5.47.0.tar.gz
-directory = maxima-5.47.0
+source_url = https://sourceforge.net/projects/maxima/files/Maxima-source/5.49.0-source/maxima-5.49.0.tar.gz/download
+source_hash = 6d401a4aa307cd3a5a9cadca4fa96c4ef0e24ff95a18bb6a8f803e3d2114adee
+source_filename = maxima-5.49.0.tar.gz
+directory = maxima-5.49.0
 patch_directory = maxima
 diff_files = maxima/configure.patch, maxima/infodir.patch, maxima/maxima_prefix_bin.patch
 
diff --git a/subprojects/packagefiles/maxima/configure.patch b/subprojects/packagefiles/maxima/configure.patch
index 5e8af2db461..f04c46b52d8 100644
--- a/subprojects/packagefiles/maxima/configure.patch
+++ b/subprojects/packagefiles/maxima/configure.patch
@@ -4,7 +4,7 @@ new mode 100644
 index 6716f3a04a6..732dcfeae8b
 --- a/configure
 +++ b/configure
-@@ -7092,15 +7092,6 @@ if test x"${ccl64}" = xtrue ; then
+@@ -7039,15 +7039,6 @@ if test x"${ccl64}" = xtrue ; then
  	fi
  fi
  
diff --git a/subprojects/packagefiles/maxima/infodir.patch b/subprojects/packagefiles/maxima/infodir.patch
index a4c037bb848..8018f2d0057 100644
--- a/subprojects/packagefiles/maxima/infodir.patch
+++ b/subprojects/packagefiles/maxima/infodir.patch
@@ -2,7 +2,7 @@ diff --git a/src/init-cl.lisp b/src/init-cl.lisp
 index 0e1f18b..125f449 100644
 --- a/src/init-cl.lisp
 +++ b/src/init-cl.lisp
-@@ -134,7 +134,7 @@ When one changes, the other does too."
+@@ -91,7 +91,7 @@ When one changes, the other does too.
  	  (setq libdir     (combine-path maxima-prefix-env "lib"))
  	  (setq libexecdir (combine-path maxima-prefix-env "libexec"))
  	  (setq datadir    (combine-path maxima-prefix-env "share"))
diff --git a/subprojects/packagefiles/maxima/maxima_prefix_bin.patch b/subprojects/packagefiles/maxima/maxima_prefix_bin.patch
index 0fced388ea9..3df3c2b1af8 100644
--- a/subprojects/packagefiles/maxima/maxima_prefix_bin.patch
+++ b/subprojects/packagefiles/maxima/maxima_prefix_bin.patch
@@ -1,13 +1,13 @@
 diff --git a/src/maxima.in b/src/maxima.in
-index ce84356a622..6af4c055238 100755
+index 2cf379cd4..a7608b065 100755
 --- a/src/maxima.in
 +++ b/src/maxima.in
 @@ -28,7 +28,7 @@ setup_vars() {
        MAXIMA_IMAGESDIR="$MAXIMA_DEFAULT_IMAGESDIR"
    else
        if [ "$layout_autotools" = "true" ]; then
--         MAXIMA_IMAGESDIR=`unixize "$MAXIMA_PREFIX"`/lib/$PACKAGE/$MAXIMA_VERSION
-+         MAXIMA_IMAGESDIR=`unixize "$MAXIMA_PREFIX"`/lib/x86_64-linux-gnu/$PACKAGE/$MAXIMA_VERSION
+-	  MAXIMA_IMAGESDIR=$(unixize "$MAXIMA_PREFIX")/lib/$PACKAGE/$MAXIMA_VERSION
++	  MAXIMA_IMAGESDIR=$(unixize "$MAXIMA_PREFIX")/lib/x86_64-linux-gnu/$PACKAGE/$MAXIMA_VERSION
        else
-          MAXIMA_IMAGESDIR=`unixize "$MAXIMA_PREFIX"`/src
-       fi 
+ 	  MAXIMA_IMAGESDIR=$(unixize "$MAXIMA_PREFIX")/src
+       fi