|
From: Raymond T. <toy...@gm...> - 2021-02-26 22:54:55
|
>>>>> "Richard" == Richard Fateman <fa...@gm...> writes:
>>
>> Perhaps because simp-%acos looks for special args?
>> acos(sqrt(3)/2) is a something that we'd want to be simplified to
>> %pi/6.
Richard> it should not have to re-simplify sqrt(3)/2 ..
Yeah. When I do (trace simplifya alike1), we get a trace like:
1: (SIMPLIFYA ((MEXPT) 3 ((RAT SIMP) 1 2)) NIL)
2: (SIMPLIFYA 3 NIL)
2: SIMPLIFYA returned 3
2: (SIMPLIFYA ((RAT SIMP) 1 2) NIL)
2: SIMPLIFYA returned ((RAT SIMP) 1 2)
2: (SIMPLIFYA ((MTIMES) ((MEXPT) 3 1)) NIL)
3: (SIMPLIFYA ((MEXPT) 3 1) NIL)
4: (SIMPLIFYA 3 NIL)
4: SIMPLIFYA returned 3
4: (SIMPLIFYA 1 NIL)
4: SIMPLIFYA returned 1
3: SIMPLIFYA returned 3
2: SIMPLIFYA returned 3
2: (ALIKE1 3 $%I)
2: ALIKE1 returned NIL
2: (SIMPLIFYA ((MEXPT) 3 ((RAT) 1 2)) NIL)
3: (SIMPLIFYA 3 NIL)
3: SIMPLIFYA returned 3
3: (SIMPLIFYA ((RAT) 1 2) NIL)
3: SIMPLIFYA returned ((RAT SIMP) 1 2)
2: SIMPLIFYA returned ((MEXPT SIMP) 3 ((RAT SIMP) 1 2))
2: (SIMPLIFYA ((MTIMES) ((MEXPT SIMP) 3 ((RAT SIMP) 1 2)) 1) NIL)
3: (SIMPLIFYA ((MEXPT SIMP) 3 ((RAT SIMP) 1 2)) NIL)
3: SIMPLIFYA returned ((MEXPT SIMP) 3 ((RAT SIMP) 1 2))
3: (ALIKE1 3 3)
3: ALIKE1 returned T
3: (ALIKE1 ((RAT SIMP) 1 2) ((RAT SIMP) 1 2))
3: ALIKE1 returned T
3: (SIMPLIFYA 1 NIL)
3: SIMPLIFYA returned 1
3: (ALIKE1 1 3)
3: ALIKE1 returned NIL
2: SIMPLIFYA returned ((MEXPT SIMP) 3 ((RAT SIMP) 1 2))
I think that all comes from (alike1 y (div (power* 3 1//2) 2)) in
simp-%acos. I guess this happens because we compute sqrt(3)/2 at
runtime. Perhaps it would be worthwhile not to do that at runtime.
After all We have the symbol '1//2 that is equal to ((rat simp) 1 2).
>>
>> Maybe the code for this should check to see if the arg is an atom
>> (and not +/-1) and bypass all the tests for special args? That
>> would slightly speed up things like acos(z).
Richard> That would be a simple check..
I think so.
|