Maple: command to simplify fraction - maple

Why doesn't Maple simplify a fraction like
-sqrt(5)*(5+sqrt(5))/120
to (-1-sqrt(5))/24 ?
Are there any commands to do this?

A suitable command for this is radnormal.
ee:=-sqrt(5)*(5+sqrt(5))/120;
1 (1/2) / (1/2)\
ee := - --- 5 \5 + 5 /
120
radnormal( ee );
1 1 (1/2)
- -- - -- 5
24 24
There are a few others which can get the form (at least for this particular example).
expand( ee );
1 1 (1/2)
- -- - -- 5
24 24
evala(Normal( ee ));
1 1 (1/2)
- -- - -- 5
24 24
Note that the distribution of the factor 1/24 is done here by Maple as an automatic simplification (and which is usually difficult to disable or awkward to avoid). Notice how delayed evaluation won't prevent it.
'(-1-sqrt(5))/24';
1 1
- -- - -- sqrt(5)
24 24

Related

TAP plugin for Jenkins

I am trying to get the TAP plugin for jenkins working to consume a stream from perl/prove. I have the TAP plugin installed and also the junit plugin. I am not sure where or how to install the tap4j jar and I am not sure how to tell the TAP plugin where the stream files are written.
Following the documentation for the TAP plugin I am calling "prove t/ --archive output" which is writing the stream to a file in output/t:
1..73
ok 1 - use Records;
ok 2 - An object of class 'Relationship' isa 'Relationship'
ok 3 - Relationship->can('rel_insert')
ok 4 - Relationship->can('rel_get')
ok 5 - An object of class 'Records' isa 'Records'
ok 6 - Records->can('IPND_read_file')
ok 7 - Records->can('IPND_read_all_files')
ok 8 - Records->can('IPND_get_our_numbers')
ok 9 - Records->can('IPND_get_tpg_names')
ok 10 - Records->can('IPND_get_tpg_addresses')
ok 11 - Records->can('IPND_sentence_records')
ok 12 - Records->can('IPND_sentence_a_record')
ok 13 - Records->can('IPND_analyse_count')
ok 14 - Records->can('IPND_match_numbers')
ok 15 - Records->can('IPND_dump_to_json')
ok 16 - Records->can('IPND_read_from_json')
ok 17 - Records->can('IPND_dump_sentence')
ok 18 - Records->can('IPND_report_sentence')
ok 19 - Records->can('IPND_report_categories')
ok 20 - Testing listing status: no bits set
ok 21 - Testing listing status: directory bit set
ok 22 - Testing listing status: directory and suppress bits set
ok 23 - Testing listing status: suppress bit set
ok 24 - Testing Installed status: not a number
ok 25 - Testing Installed status: 0
ok 26 - Testing Installed status: just below range
ok 27 - Testing Installed status: range boundary
ok 28 - Testing Installed status: just above range boundary
ok 29 - Testing Installed status: middle of range
ok 30 - Testing Installed status: just before end of range
ok 31 - Testing Installed status: end of range
ok 32 - Testing Installed status: just after range
ok 33 - Testing Installed status: after range
ok 34 - Testing pair exists: both exist
ok 35 - Testing pair exists: first exists
ok 36 - Testing pair exists: second exists
ok 37 - Testing pair exists: neither exists
ok 38 - Testing pair exists: empty hash
ok 39 - Testing cmp_numbers: same number
ok 40 - Testing cmp_numbers: different number
ok 41 - Testing cmp_strings: same string
ok 42 - Testing cmp_strings: different strings
ok 43 - Testing cmp_strings: same string, different case
ok 44 - Testing cmp_strings: different strings, different case
ok 45 - Testing cmp_strings: same string, different case
ok 46 - Testing cmp_strings: different strings, different case
ok 47 - Testing cmp_strings: same string, different case
ok 48 - Testing _cmp_date: first is undef
ok 49 - Testing _cmp_date: second is undef
ok 50 - Testing _cmp_date: both undef
ok 51 - Testing _cmp_date: first is 0
ok 52 - Testing _cmp_date: second is 0
ok 53 - Testing _cmp_date: both 0
ok 54 - Testing _cmp_date: first dashes
ok 55 - Testing _cmp_date: second dashes
ok 56 - Testing _cmp_date: both dashes
ok 57 - Testing _cmp_date: neither dashes
ok 58 - Testing _cmp_date: dieing on first string
ok 59 - Testing _cmp_date: dieing on second string
ok 60 - Testing _cmp_date: dieing on both strings
ok 61 - Testing _cmp_date: less than
ok 62 - Testing _cmp_date: more than
ok 63 - Testing _cmp_date: equal
ok 64 - Testing _bool_to_text: 0
ok 65 - Testing _bool_to_text: 1
ok 66 - Testing _bool_to_text: -1
ok 67 - Testing _bool_to_text: 250
ok 68 - Testing _functionize_params
ok 69 - Testing _Rtrim: space on end
ok 70 - Testing _Rtrim: tab on end
ok 71 - Testing _Rtrim: space on end and beginning
ok 72 - Testing _Rtrim: space on end and tab on beginning
ok 73 - Testing _extract_field
I have failed to find any configuration file for the TAP plugin. I have also just realized that tap4j is an external jar file rather than another jenkins plugin. I have downloaded the jar but now don't know where to put it.
in Summary:
where is the TAP plugin config file
how do I point the TAP plugin at my stream in output/t
where do I put the tap4j.jar file for TAP plugin to use.
OK obscure as - ie lots and lots of assumed knowledge but:
I don't know that there is a config file - haven't found one anyway.
In my case the TAP stream files were off the root of the workspace in output/t. In my Jenkins file I placed a stage:
stage('Report') {
steps {
step([$class: "TapPublisher", testResults: "**/output/t/*"])
}
}
The key is the last bit which tells the plugin where to find the streams. Literally the first ** says look everywhere for "output/t" - ie a directory path snippet - and then under there treat everything - the last "*" - as a stream file.
There may be many places to plonk the jar file but I put it in "/plugins/tap/". In my case on Ubuntu 20.04 that was /var/lib/jenkins/plugins/tap.

*Excruciatingly* slow (over ten seconds for `(+ 1 1)`) with language "How To Design Programs - Beginning Student"

I just installed DrRacket, and tried out the language "How To Design Programs - Beginning Student".
Racket - A programmable programming language
Racket - Getting Started
I run (+ 1 1), and it takes over ten seconds for this to show up:
Welcome to DrRacket, version 6.5 [3m].
Language: Beginning Student; memory limit: 128 MB.
2
>
As far as I can tell, my installation is pretty much "out of the box".
What I'm wondering is if my experience is unusual,
and if there's any obvious way to troubleshoot it if so
(I've looked around the settings and didn't find anything obvious to tweak),
or if maybe the whole HTDP language was quietly abandoned or something...?
EDIT 1
I have these files:
/usr/share/racket $
find -iname "*htdp*.zo"
./pkgs/htdp-lib/lang/private/compiled/create-htdp-executable_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-reader_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-beginner-abbr-reader_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-langs-save-file-prefix_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-advanced-reader_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-intermediate-lambda-reader_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-advanced_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-beginner-abbr_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-intermediate_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-intermediate-reader_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-langs_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-beginner_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-intermediate-lambda_rkt.zo
./pkgs/htdp-lib/lang/compiled/htdp-beginner-reader_rkt.zo
./pkgs/htdp-doc/scribblings/htdp-langs/compiled/htdp-langs_scrbl.zo
./pkgs/htdp-doc/scribblings/htdp-langs/compiled/htdp-ptr_scrbl.zo
./pkgs/htdp-doc/htdp/compiled/htdp_scrbl.zo
./pkgs/htdp-doc/htdp/compiled/htdp-lib_scrbl.zo
./pkgs/htdp-doc/teachpack/htdp/scribblings/compiled/htdp_scrbl.zo
./pkgs/htdp-doc/teachpack/2htdp/scribblings/compiled/2htdp_scrbl.zo
EDIT 2 - cpu and harddrive specs
CPU
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 28
model name : Intel(R) Atom(TM) CPU N450 # 1.66GHz
stepping : 10
microcode : 0x107
cpu MHz : 1000.000
cache size : 512 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm movbe lahf_lm dtherm
bugs :
bogomips : 3325.00
clflush size : 64
cache_alignment : 64
address sizes : 32 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 28
model name : Intel(R) Atom(TM) CPU N450 # 1.66GHz
stepping : 10
microcode : 0x107
cpu MHz : 1000.000
cache size : 512 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm movbe lahf_lm dtherm
bugs :
bogomips : 3325.00
clflush size : 64
cache_alignment : 64
address sizes : 32 bits physical, 48 bits virtual
power management:
HD
$ sudo hdparm -I /dev/sda
/dev/sda:
ATA device, with non-removable media
Model Number: Hitachi HTS545016B9A300
Serial Number: 100324PBPB06ECC0K6XL
Firmware Revision: PBBOC60F
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6; Revision: ATA8-AST T13 Project D1697 Revision 0b
Standards:
Used: unknown (minor revision code 0x0028)
Supported: 8 7 6 5
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 312581808
Logical/Physical Sector size: 512 bytes
device size with M = 1024*1024: 152627 MBytes
device size with M = 1000*1000: 160041 MBytes (160 GB)
cache/buffer size = 7208 KBytes (type=DualPortCache)
Form Factor: 2.5 inch
Nominal Media Rotation Rate: 5400
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Vendor, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = 16
Advanced power management level: 254
Recommended acoustic management value: 128, current value: 254
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* NOP cmd
* DOWNLOAD_MICROCODE
* Advanced Power Management feature set
Power-Up In Standby feature set
* SET_FEATURES required to spinup after power up
SET_MAX security extension
Automatic Acoustic Management feature set
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* WRITE_{DMA|MULTIPLE}_FUA_EXT
* 64-bit World wide name
* IDLE_IMMEDIATE with UNLOAD
* WRITE_UNCORRECTABLE_EXT command
* {READ,WRITE}_DMA_EXT_GPL commands
* Segmented DOWNLOAD_MICROCODE
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Native Command Queueing (NCQ)
* Host-initiated interface power management
* Phy event counters
* NCQ priority information
Non-Zero buffer offsets in DMA Setup FIS
* DMA Setup Auto-Activate optimization
Device-initiated interface power management
In-order data delivery
* Software settings preservation
* SMART Command Transport (SCT) feature set
* SCT Write Same (AC2)
* SCT Error Recovery Control (AC3)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
Security:
Master password revision code = 65534
supported
not enabled
not locked
frozen
not expired: security count
supported: enhanced erase
64min for SECURITY ERASE UNIT. 66min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5000cca5ffc040a7
NAA : 5
IEEE OUI : 000cca
Unique ID : 5ffc040a7
Checksum: correct
EDIT 3 command-line times
ran (+ 1 1) in HTDP-beginner 3 times -- Over 5 seconds.
$ time racket -t racket_HTDP_beginner.rkt
2
5.60user 1.04system 0:08.46elapsed 78%CPU (0avgtext+0avgdata 127968maxresident)k
5496inputs+0outputs (46major+40955minor)pagefaults 0swaps
$ time racket -t racket_HTDP_beginner.rkt
2
5.51user 0.67system 0:06.71elapsed 92%CPU (0avgtext+0avgdata 128124maxresident)k
24inputs+0outputs (0major+41790minor)pagefaults 0swaps
$ time racket -t racket_HTDP_beginner.rkt
2
5.41user 0.67system 0:06.55elapsed 92%CPU (0avgtext+0avgdata 128180maxresident)k
0inputs+0outputs (0major+36683minor)pagefaults 0swaps
ran (+ 1 1) in #lang racket 3 times -- A bit over 2 seconds.
$ time racket -t racket_lang_racket.rkt
2
2.13user 0.25system 0:02.71elapsed 87%CPU (0avgtext+0avgdata 64996maxresident)k
0inputs+0outputs (0major+12437minor)pagefaults 0swaps
$ time racket -t racket_lang_racket.rkt
2
2.15user 0.25system 0:02.63elapsed 91%CPU (0avgtext+0avgdata 61700maxresident)k
0inputs+0outputs (0major+15853minor)pagefaults 0swaps
$ time racket -t racket_lang_racket.rkt
2
2.28user 0.29system 0:02.89elapsed 89%CPU (0avgtext+0avgdata 61500maxresident)k
0inputs+0outputs (0major+15015minor)pagefaults 0swaps
EDIT 4
Running free -h every second while DrRacket is running (+ 1 1) in lang HTDP-beginner
(not running any other applications besides DrRacket and my basic system (ie window manager etc))
(this is fish shell, by the way):
http://pastebin.com/2RdZAuXj
At that point I had to kill DrRacket cuz everything was freezing up.
Anyway, yeah, it's leaking, obviously.
Everytime I re-ran the code in DrRacket, memory usage went up and stayed up.
I had only run it about twenty...two-ish (?) more times
(so maybe thirty-ish in total?)
by the point where it started getting near the limit
and I killed it to unfreeze the system.
I guess I should try this with normal #lang racket and see what happens...
EDIT 5
Yup, it leaks the same way:
http://pastebin.com/373PNnY7
I am 90% sure that the reason you had to wait was that your installation of Racket wasn't done properly.
During installation the program setup-plt needs to be run. It precompiles all racket files (.rkt) into so-called zo-files. If this step is omitted, then
DrRacket do the compilation for you the first time a file is needed.
In your case (I am guessing) it it your first time using the Beginner language, so all files relating to it needs to be compiled. And that takes a while.
The best solution is to use the official installers from http://download.racket-lang.org/ they all include precompiled zo-files.
If you happen to have used such an installer, then try again - and if the problem persist - do file a bug report (use the bug report in the Help menu in DrRacket).

Xvnc process at 100% CPU when idle

I have a very annyoing problem when running TigerVNC 1.3.1 in a Debian 7 virtual machine. After about one minute doing nothing in the VNC window, the Xvnc process goes up to 100% CPU usage. Once I move my mouse into the VNC window again, the CPU usage returns to normal. I believe that the function call select() is the culprit. Doing an "strace -p " gives me tons of this:
select(256, [0 1 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], NULL, NULL, {0, 0}) = 0 (Timeout)
And "strace -c -p ":
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
78.19 0.001760 0 98445 select
21.81 0.000491 0 196889 setitimer
------ ----------- ----------- --------- --------- ----------------
100.00 0.002251 295334 total
I'm not an expert on system function calls, but all other processes I checked with these commands do not show that kind of behavior. Is it a bug in the tigervnc code or is there a way I can fix it?
I'd recommend you reset to default settings to see if everything becomes fine. I was a tightvnc user for a long time, until I switched to RealVNC (free edition). I'd suggest you give a try of it. The settings are almost identical to tightvnc. And it supports real cross machine text copy-and-paste.

top CPU consumers using ps command

What is the difference between two commands, pls help to explain it.
ps -ef|sort +6|tail
oracle 55676 1 0 03:06:16 - 0:36 oracleprod (LOCAL=NO)
oracle 24876 1 0 02:52:56 - 0:40 oracleprod (LOCAL=NO)
oracle 41616 1 0 07:00:59 - 0:44 oracleprod (LOCAL=NO)
oracle 43460 1 0 02:45:05 - 0:53 oracleprod (LOCAL=NO)
oracle 25754 1 0 08:10:03 - 1:01 oracleprod (LOCAL=NO)
ps -ef|sort +5|tail
root 5440 2094 0 Nov 21 - 0:47 /usr/sbin/syslogd
root 9244 1 0 Nov 21 - 3:26 ./pcimapsvr.ip -D0
root 10782 1 0 Nov 21 - 4:41 ./pciconsvr.ip -D0
Why do both commands show different processes ? And if I keep on changing the value of 'sort +3' or reduce, the processes keeps on changing. What exactly is command all about ? Please help to explain.
You are sorting the wrong columns using both an obsolete syntax and a wrong method. No surprise random processes show up.
You'll get the top consumers that way:
ps -ef | sort -n -k8 | tail
-n means sort numerically
-k8 means sort the the eight column (cumulative execution time)

Comprehensive methods of viewing memory usage on Solaris [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
On Linux, the "top" command shows a detailed but high level overview of your memory usage, showing:
Total Memory, Used Memory, Free Memory, Buffer Usage, Cache Usage, Swap size and Swap Usage.
My question is, what commands are available to show these memory usage figures in a clear and simple way? Bonus points if they're present in the "Core" install of Solaris. 'sar' doesn't count :)
Here are the basics. I'm not sure that any of these count as "clear and simple" though.
ps(1)
For process-level view:
$ ps -opid,vsz,rss,osz,args
PID VSZ RSS SZ COMMAND
1831 1776 1008 222 ps -opid,vsz,rss,osz,args
1782 3464 2504 433 -bash
$
vsz/VSZ: total virtual process size (kb)
rss/RSS: resident set size (kb, may be inaccurate(!), see man)
osz/SZ: total size in memory (pages)
To compute byte size from pages:
$ sz_pages=$(ps -o osz -p $pid | grep -v SZ )
$ sz_bytes=$(( $sz_pages * $(pagesize) ))
$ sz_mbytes=$(( $sz_bytes / ( 1024 * 1024 ) ))
$ echo "$pid OSZ=$sz_mbytes MB"
vmstat(1M)
$ vmstat 5 5
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr rm s3 -- -- in sy cs us sy id
0 0 0 535832 219880 1 2 0 0 0 0 0 -0 0 0 0 402 19 97 0 1 99
0 0 0 514376 203648 1 4 0 0 0 0 0 0 0 0 0 402 19 96 0 1 99
^C
prstat(1M)
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
1852 martin 4840K 3600K cpu0 59 0 0:00:00 0.3% prstat/1
1780 martin 9384K 2920K sleep 59 0 0:00:00 0.0% sshd/1
...
swap(1)
"Long listing" and "summary" modes:
$ swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 256,1 16 1048560 1048560
$ swap -s
total: 42352k bytes allocated + 20192k reserved = 62544k used, 607672k available
$
top(1)
An older version (3.51) is available on the Solaris companion CD from Sun, with the disclaimer that this is "Community (not Sun) supported".
More recent binary packages available from sunfreeware.com or blastwave.org.
load averages: 0.02, 0.00, 0.00; up 2+12:31:38 08:53:58
31 processes: 30 sleeping, 1 on cpu
CPU states: 98.0% idle, 0.0% user, 2.0% kernel, 0.0% iowait, 0.0% swap
Memory: 1024M phys mem, 197M free mem, 512M total swap, 512M free swap
PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND
1898 martin 1 54 0 3336K 1808K cpu 0:00 0.96% top
7 root 11 59 0 10M 7912K sleep 0:09 0.02% svc.startd
sar(1M)
And just what's wrong with sar? :)
# echo ::memstat | mdb -k
Page Summary Pages MB %Tot
------------ ---------------- ---------------- ----
Kernel 7308 57 23%
Anon 9055 70 29%
Exec and libs 1968 15 6%
Page cache 2224 17 7%
Free (cachelist) 6470 50 20%
Free (freelist) 4641 36 15%
Total 31666 247
Physical 31256 244
"top" is usually available on Solaris.
If not then revert to "vmstat" which is available on most UNIX system.
It should look something like this (from an AIX box)
vmstat
System configuration: lcpu=4 mem=12288MB ent=2.00
kthr memory page faults cpu
----- ----------- ------------------------ ------------ -----------------------
r b avm fre re pi po fr sr cy in sy cs us sy id wa pc ec
2 1 1614644 585722 0 0 1 22 104 0 808 29047 2767 12 8 77 3 0.45 22.3
the colums "avm" and "fre" tell you the total memory and free memery.
a "man vmstat" should get you the gory details.
Top can be compiled from sources or downloaded from sunfreeware.com. As previously posted, vmstat is available (I believe it's in the core install?).
The command free is nice. Takes a short while to understand the "+/- buffers/cache", but the idea is that cache and buffers doesn't really count when evaluating "free", as it can be dumped right away. Therefore, to see how much free (and used) memory you have, you need to remove the cache/buffer usage - which is conveniently done for you.