mathpiper-0.81f+svn4469+dfsg3/ 0000755 0001750 0001750 00000000000 11722677373 016161 5 ustar giovanni giovanni mathpiper-0.81f+svn4469+dfsg3/docs/ 0000755 0001750 0001750 00000000000 11722677346 017111 5 ustar giovanni giovanni mathpiper-0.81f+svn4469+dfsg3/docs/functions_that_need_documentation.txt 0000644 0001750 0001750 00000013457 11523151705 026621 0 ustar giovanni giovanni The following functions and .mpw files need to be documented
(functions that start with * and are indented have already had documentation
added to them):
AddTerm.mpw
AddTerms.mpw
DivTermList.mpw
MultiDivTerm.mpw
MultiplySingleTerm.mpw
MultiplyTerms.mpw
SubtractTerms.mpw
AntiDeriv.mpw
//Tensor functions.
ApplyDelta.mpw
MoveDeltas.mpw
Delta.mpw
TD.mpw
TExplicitSum.mpw
TList.mpw
TRun.mpw
TSimplify.mpw
TSum.mpw
TSumRest.mpw
TSumSimplify.mpw
X.mpw
ApproxInfSum.mpw
ArcCosh.mpw
ArcCot.mpw
ArcCoth.mpw
ArcCsc.mpw
ArcCsch.mpw
ArcSec.mpw
ArcSech.mpw
ArcSinNum.mpw
ArcSinh.mpw
ArcTanN'Taylor.mpw
ArcTanNum.mpw
ArcTanh.mpw
Average.mpw
BSearch.mpw
BellNumber.mpw
BenchCall.mpw
BenchShow.mpw
Bernoulli1.mpw
BernoulliFracPart.mpw
BesselI.mpw
BesselJ.mpw
BesselJN.mpw
BesselJN0.mpw
BesselNsmall.mpw
BesselY.mpw
Beta.mpw
BinaryFactors.mpw
BisectSqrt.mpw
BitCount.java
BitsToDigits.java
BitsToDigits.mpw
BoundRealRoots.mpw
BrentLn.mpw
BuiltinAssoc.java
CNF.mpw
CanBeUni.mpw
CanonicalAdd.mpw
CatalanConstNum.mpw
ChartUtility.java
CheckIntPower.mpw
ChineseRemainderInteger.mpw
ChineseRemainderPoly.mpw
CommonLispTokenizer.java
CompilePatterns.mpw
Contradict.mpw
ControlChart.mpw
CosN'Doubling.mpw
CosN'Taylor.mpw
CosNum.mpw
Cosh.mpw
Cot.mpw
Coth.mpw
Csc.mpw
Csch.mpw
CustomEval.java
CustomEvalExpression.java
CustomEvalLocals.java
CustomEvalResult.java
CustomEvalStop.java
DawsonIntegral.mpw
DebugFile.java
DebugLine.java
DefLoadFunction.java
DefaultPrint.mpw
Deriv.mpw
DestructiveAppendList.mpw
Digamma.mpw
DigitalRoot.mpw
DigitsToBits.java
DigitsToBits.mpw
DirichletBeta.mpw
DirichletEta.mpw
DirichletLambda.mpw
DivPoly.mpw
DoUnitSubsumptionAndResolution.mpw
DropEndZeroes.mpw
EqualAsSets.mpw
Erf.mpw
Erfc.mpw
Erfi.mpw
EulerArray.mpw
Example.mpw
Exit.java
ExitRequested.java
ExpN'Doubling.mpw
ExpN'Taylor.mpw
ExpNum.mpw
ExpandFrac.mpw
ExpandSparseUniVar.mpw
ExpandUniVariate.mpw
ExpressionDepth.mpw
ExtendedEuclidean.mpw
ExtendedEuclideanMonic.mpw
FW.mpw
FWatom.mpw
FactorGaussianInteger.mpw
FactorQS.mpw
FactorUniVar.mpw
Factorial.java
FactorizeInt.mpw
FactorsBinomials.mpw
FastArcCos.java
FastArcSin.java
FastArcTan.java
FastCos.java
FastIsPrime.java
FastLog.java
FastPower.java
FastSin.java
FastTan.java
FileSize.java
FindIsq.mpw
FindPredicate.mpw
FindPrimeFactor.mpw
FindPrimeFactorSimple.mpw
FloatIsInt.mpw
ForEachExperimental.mpw
ForEachInArray.mpw
FresnelCos.mpw
FresnelSin.mpw
GammaConstNum.mpw
GarbageCollect.java
GaussianFactorPrime.mpw
GaussianMod.mpw
GcdN.mpw
GcdReduce.mpw
GeoGebra.mpw
GeoGebraHistogram.mpw
GeoGebraPlot.mpw
GeoGebraPoint.mpw
GetNumerDenom.mpw
GetPrimePower.mpw
Groebner.mpw
HighschoolForm.mpw
II.mpw
ImII.mpw
Import.java
InDebugMode.java
IncompleteGamma.mpw
Internal'BernoulliArray.mpw
Internal'BernoulliArray1.mpw
Internal'GammaNum.mpw
Internal'LnGammaNum.mpw
Internal'LnNum.mpw
IsBoolType.mpw
IsComplex.mpw
IsComplexII.mpw
IsNonNegativeInteger.mpw
IsNonNegativeNumber.mpw
IsNotComplex.mpw
IsOne.mpw
IsPerfect.mpw
IsRationalOrNumber.mpw
IsSubset.mpw
IsUniVar.mpw
IsVariable.mpw
JFreeChartHistogram.mpw
JavaAccess.mpw
LexCompare2.java
LexGreaterThan.java
LexLessThan.java
ListHasFuncSome.mpw
LnGamma.mpw
LogicCombine.mpw
LogicFindWith.mpw
LogicRemoveTautologies.mpw
LogicSimplify.mpw
MM.mpw
MacroMapArgs.mpw
MacroMapSingle.mpw
MacroSubstitute.mpw
Magnitude.mpw
MakeMultiNomial.mpw
MakeSparseUniVar.mpw
MakeUni.mpw
ManipEquations.mpw
Manipulate.mpw
MathBitCount.mpw
MathExpDoubling.mpw
MathExpTaylor.mpw
MathFloatPower.mpw
MathIntPower.mpw
MathIsSmall.java
MathLn'Doubling.mpw
MathLn'Taylor.mpw
MathMul2Exp.mpw
MathNegate.java
MathPi.mpw
MathSign.java
MathSqrtFloat.mpw
MatrixRowAndColumnOps.mpw
Maxima.java
MultiDivide.mpw
MultiGcd.mpw
MultiNomial.mpw
MultiSimp.mpw
NN.mpw
NewtonLn.mpw
NextPseudoPrime.mpw
NextTest.mpw
NormalForm.mpw
Nth.java
NumericEqual.mpw
OldCyclotomic.mpw
OptionsListToHash.mpw
PAdicExpandInternal.mpw
PSolve.mpw
PanAxiom.java
PartFracExpand.mpw
PartitionsP.mpw
PatternCreate.java
PatternMatches.java
PollardCombineLists.mpw
PollardMerge.mpw
PollardRhoFactorize.mpw
PolyLog.mpw
PositiveIntPower.mpw
Print.mpw
ProductPrimesTo257.mpw
RabinMiller.mpw
RationalForm.mpw
RationalizeNumber.mpw
ReII.mpw
Regress.mpw
Rem.mpw
RemoveRepeated.mpw
RepeatedSquaresMultiply.mpw
Repunit.mpw
Return.java
Ring.java
Roots.mpw
RootsWithMultiples.mpw
Sec.mpw
Sech.mpw
Series.mpw
Set.java
SetOrder.mpw
SetPlotColor.java
SetPlotWidth.java
ShowLine.mpw
ShuffledDeckNoSuits.mpw
SimpAdd.mpw
SimpDiv.mpw
SimpExpand.mpw
SimpFlatten.mpw
SimpImplode.mpw
SimpMul.mpw
SimulatorPlot.java
SinN'Taylor.mpw
SinN'Tripling.mpw
SinNum.mpw
Sinc.mpw
Sinh.mpw
SmallSort.mpw
SolveSetEqns.mpw
SolveSystem.mpw
SortFactorList.mpw
SparseUniVar.mpw
StackSize.java
StemAndLeaf.mpw
SturmSequence.mpw
SturmVariations.mpw
Substitute.mpw
Subsumes.mpw
SumFunc.mpw
TanNum.mpw
Tanh.mpw
Taylor2.mpw
Taylor3.mpw
TestEquivalent.mpw
Testing.mpw
Totient.mpw
TraceToStdio.java
TrialFactorize.mpw
Trigonometry.mpw
UniDivide.mpw
UniGCD.mpw
UniTaylor.mpw
UniVarList.mpw
UniVariate.mpw
UniVariateCyclotomic.mpw
VarListAll.mpw
ViewGeoGebra.java
ViewSimulator.java
WilkinsonMatrix.mpw
WriteDataItem.mpw
WriteN.mpw
backends.mpw
equals_greaterthan_operator.mpw
expthreshold.mpw
ggbLine.mpw
html.mpw
jFactorsPoly.mpw
jasFactorsInt.mpw
jas_test.mpw
lessthan_minus_operator.mpw
mathpiperinit.mpw
om.mpw
period_operator.mpw
pound_operator.mpw
randomtest.mpw
scopestack.mpw
sign'change.mpw
sparsenomial.mpw
sparsetree.mpw
stdopers.mpw
xFactor.mpw
xFactors.mpw
xFactorsBinomial.mpw
xFactorsResiduals.mpw
xSolvePoly.mpw
xSolveRational.mpw
xSolveReduce.mpw
xSolveSqrts.mpw
xSolveSystem.mpw
xTerms.mpw
zeta.mpw
The following functions have been categorized and have had documentation added to them.
*IntLog.mpw
*IntNthRoot.mpw
*IntPowerNum.mpw
*IsSumOfTerms.mpw
*MultiplyNum.mpw
*NetwonNum.mpw
*nthroot.mpw NthRoot
*numeric.mpw InNumericMode, NonN
*Remove.mpw
*SumTaylorNum.mpw
*ArithmeticGeometricMean.mpw
*ApplyFast.java
mathpiper-0.81f+svn4469+dfsg3/build.xml 0000644 0001750 0001750 00000025712 11563440436 020000 0 ustar giovanni giovanni
Build file for MathPiper.
mathpiper-0.81f+svn4469+dfsg3/nbproject/ 0000755 0001750 0001750 00000000000 11722677316 020144 5 ustar giovanni giovanni mathpiper-0.81f+svn4469+dfsg3/nbproject/genfiles.properties 0000644 0001750 0001750 00000000731 11503731314 024041 0 ustar giovanni giovanni nbbuild.xml.data.CRC32=3ff7be42
nbbuild.xml.script.CRC32=b1b8aa36
nbbuild.xml.stylesheet.CRC32=958a1d3e@1.26.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=3ff7be42
nbproject/build-impl.xml.script.CRC32=bf50b382
nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45
mathpiper-0.81f+svn4469+dfsg3/nbproject/build-impl.xml 0000644 0001750 0001750 00000136017 11503731314 022716 0 ustar giovanni giovanni
Must set src.src.dir
Must set src.tests.dir
Must set build.dir
Must set dist.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set build.test.classes.dir
Must set build.test.results.dir
Must set build.classes.excludes
Must set dist.jar
Must set javac.includes
Must select some files in the IDE or set javac.includes
To run this application from the command line without Ant, try:
java -cp "${run.classpath.with.dist.jar}" ${main.class}
To run this application from the command line without Ant, try:
java -jar "${dist.jar.resolved}"
To run this application from the command line without Ant, try:
java -jar "${dist.jar.resolved}"
Must select one file in the IDE or set run.class
Must select one file in the IDE or set run.class
Must select one file in the IDE or set debug.class
Must select one file in the IDE or set debug.class
Must set fix.includes
Must select some files in the IDE or set javac.includes
Some tests failed; see details above.
Must select some files in the IDE or set test.includes
Some tests failed; see details above.
Must select one file in the IDE or set test.class
Must select one file in the IDE or set applet.url
Must select one file in the IDE or set applet.url
mathpiper-0.81f+svn4469+dfsg3/nbproject/project.properties 0000644 0001750 0001750 00000007327 11523146134 023725 0 ustar giovanni giovanni annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.run.all.processors=true
application.title=mathpiper
application.vendor=tkosan
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
buildfile=nbbuild.xml
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/mathpiper.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.geogebra.jar=/home/tkosan/NetBeansProjects/lib/geogebra.jar
file.reference.geogebra_cas.jar=/home/tkosan/NetBeansProjects/lib/geogebra_cas.jar
file.reference.geogebra_export.jar=/home/tkosan/NetBeansProjects/lib/geogebra_export.jar
file.reference.geogebra_gui.jar=/home/tkosan/NetBeansProjects/lib/geogebra_gui.jar
file.reference.geogebra_javascript.jar=/home/tkosan/NetBeansProjects/lib/geogebra_javascript.jar
file.reference.geogebra_main.jar=/home/tkosan/NetBeansProjects/lib/geogebra_main.jar
file.reference.geogebra_properties.jar=/home/tkosan/NetBeansProjects/lib/geogebra_properties.jar
file.reference.jas.jar=/home/tkosan/NetBeansProjects/lib/jas.jar
file.reference.jcommon-1.0.16.jar=/home/tkosan/NetBeansProjects/lib/jcommon-1.0.16.jar
file.reference.jdom.jar=/home/tkosan/NetBeansProjects/lib/jdom.jar
file.reference.jfreechart-1.0.13.jar=/home/tkosan/NetBeansProjects/lib/jfreechart-1.0.13.jar
file.reference.NetBeansProjects-mathpiper=.
includes=**
jar.compress=false
javac.classpath=\
${file.reference.jcommon-1.0.16.jar}:\
${file.reference.jdom.jar}:\
${file.reference.jfreechart-1.0.13.jar}:\
${file.reference.geogebra.jar}:\
${file.reference.geogebra_cas.jar}:\
${file.reference.geogebra_export.jar}:\
${file.reference.geogebra_gui.jar}:\
${file.reference.geogebra_javascript.jar}:\
${file.reference.geogebra_main.jar}:\
${file.reference.geogebra_properties.jar}:\
${file.reference.jas.jar}
# Space-separated list of extra javac options
javac.compilerargs=-g
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.5
javac.target=1.5
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
${libs.junit.classpath}:\
${libs.junit_4.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=org.mathpiper.ui.text.consoles.Console
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
${file.reference.jcommon-1.0.16.jar}:\
${file.reference.jdom.jar}:\
${file.reference.jfreechart-1.0.13.jar}:\
${file.reference.NetBeansProjects-mathpiper}
# Space-separated list of JVM arguments used when running the project
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
# or test-sys-prop.name=value to set system properties for unit tests):
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.src.dir=src
src.tests.dir=tests
mathpiper-0.81f+svn4469+dfsg3/nbproject/project.xml 0000644 0001750 0001750 00000000742 11351304227 022321 0 ustar giovanni giovanni
org.netbeans.modules.java.j2seproject
mathpiper
mathpiper-0.81f+svn4469+dfsg3/tests/ 0000755 0001750 0001750 00000000000 11722677316 017320 5 ustar giovanni giovanni mathpiper-0.81f+svn4469+dfsg3/tests/win_test.bat 0000644 0001750 0001750 00000000052 11123262534 021624 0 ustar giovanni giovanni java -cp . org.mathpiper.test.RunTestSuite mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/ 0000755 0001750 0001750 00000000000 11722677314 022015 5 ustar giovanni giovanni mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/xTestSolve.mpw 0000644 0001750 0001750 00000012303 11316262063 024647 0 ustar giovanni giovanni %mathpiper,title="xTestSolve"
Use("proposed.rep/xSolve.mpi");
//########################################################################
// T E S T I N G T E S T I N G T E S T I N G
//########################################################################
iDebug := False;
//iDebug := True;
// a bunch of expressions for testing
expressions := {};
Push( expressions, {a,{}} );
Push( expressions, {0,{{x==x}}} );
Push( expressions, {x-5,{{x==5}}} );
Push( expressions, {x-a,{{x==a}}} );
Push( expressions, {12*x+5==29,{{x==2}}} );
Push( expressions, {5*x-15==5*(x-3),{x==x}} );
Push( expressions, {5*x-15==5*(x-4),{}} );
Push( expressions, {x^2-4,{x==2,x==(-2)}} );
Push( expressions, {x^2-a^2,{x==a,x==(-a)}} );
Push( expressions, {2*x^2+9*x==18,{x==3/2,x==(-6)}} );
Push( expressions, {5*x^2==25*x, {x==0,x==5}} );
Push( expressions, {2*x/5-x/3==2,{x==30}});
Push( expressions, {2/x-3/2==7/(2*x),{x==(-1)}});
Push( expressions, {2/(x-3)-3/(x+3)==12/(x^2-9),{}});
Push( expressions, {3/(x^2+x-2)-1/(x^2-1)==7/(2*(x^2+3*x+2)),{x==3}});
Push( expressions, {1+1/x==6/x^2,{x==2,x==(-3)}});
Push( expressions, {Sqrt(x)-3,{x==9}});
Push( expressions, {Sqrt(x-3),{x==3}});
Push( expressions, {Sqrt(x-3)==2, {x==7}});
Push( expressions, {Sqrt(2*x)==Sqrt(x+1), {x==1}});
Push( expressions, {Sqrt(x)==x, {x==1,x==0}});
Push( expressions, {Sqrt(x+2)-2*x==1,{x==1/4} } );
Push( expressions, {Sqrt(x+2)+2*x==1,{x==(5 - Sqrt(41))/8} } );
Push( expressions, {Sqrt(9*x^2+4)-3*x==1,{x==1/2} } );
Push( expressions, {Sqrt(x+1)-Sqrt(x)==-2,{} } );
Push( expressions, {Sqrt(3*x-5)-Sqrt(2*x+3)==-1,{x==3} } );
Push( expressions, {Exp(x)==4, {x==Ln(4)}});
Push( expressions, {Exp(x)==Abs(a), {x==Ln(Abs(a))}});
Push( expressions, {Ln(x)==4, {x==Exp(4)}});
Push( expressions, {Ln(x)==a, {x==Exp(a)}});
Push( expressions, {(x+6)/2-(3*x+36)/4==4, {x==-40} } );
Push( expressions, {(x-3)*(x-4)==x^2-2, {x==2} } );
Push( expressions, {a*x-2*b*c==d,{x==(2*b*c+d)/a} } );
Push( expressions, {(36-4*x)/(x^2-9)-(2+3*x)/(3-x)==(3*x-2)/(x+3),{x==-2} } );
Push( expressions, {(x^2-1)^(1/3)==2,{x==3,x==(-3)} } );
Push( expressions, {x^4-53*x^2+196==0, {x==(-7),x==(-2),x==2,x==7} } );
Push( expressions, {x^3-8==0, {x==2,x==-1+I*Sqrt(3),x==-1-I*Sqrt(3)} } );
Push( expressions, {x^(2/3)+x^(1/3)-2==0, {x==1,x==(-8)} } );
Push( expressions, {Sqrt(x)-(1/4)*x==1, {x==4} } );
Push( expressions, {(1/4)*x-Sqrt(x)==-1, {x==4} } );
Push( expressions, {{x-y==1,3*x+2*y==13}, {x==3,y==2} } );
Push( expressions, {{x-y-1==0,2*y+3*x-13==0}, {x==3,y==2} } );
//Push( expressions, {, {} } );
//Push( expressions, {,{{},{},{},{}}} );
NewLine(2); Tell("TEST xSolve()");
t1 := SystemTimer();
expressions := Reverse(expressions);
Local(i); i := 0;
Local(iCorrect); iCorrect := 0;
ForEach(q,expressions)
[
i := i + 1;
Check(i<100, ">>>>> FORCED STOP <<<<<");
f := q[1];
If( f = blank,
[
i := i - 1;
NewLine();
],
[
//If(i=23 Or i=26 Or i=40,iDebug:=True,iDebug:=False);
Local(vars);
g := q[2];
NewLine();
Tell(i,"-------------------------------");
Tell(">>> Test xSolve() on the expression: ",f);
stk := {};
vars := VarList(f);
If(IsList(f),
[
If(iDebug=True,Tell(" system"));
r := xSolve(f,vars);
SysOut(" xSolve(f,vars) ==> ",r);
],
[
If(iDebug=True,Tell(" single"));
r := xSolve(f,x);
SysOut(" xSolve(f,x) ==> ",r);
]
);
//If(IsList(f),Break());
rmg := Simplify(Expand(UnFlatten(r-g,"+",0)));
If(iDebug=True,Tell("rmg",rmg));
If(iDebug And IsList(rmg),Tell(Listify(rmg)));
If( IsZero(rmg) Or IsZeroVector(rmg),
[SysOut(" Answer is CORRECT"); iCorrect:=iCorrect+1;],
[
If(iDebug=True,Tell("check rmg a little more"));
Local(Lrmg,Lrmg2,Lrmg3);
Lrmg := Listify(rmg);
If(iDebug=True,Tell("Listify rmg",Lrmg));
If(Lrmg[1] != UnFlatten,
[
Lrmg2 := Listify(Lrmg[2]);
Lrmg3 := Listify(Lrmg[3]);
If(iDebug=True,Tell("LL",{Lrmg2,Lrmg3}));
If(CloseEnough(Lrmg2[3],Lrmg3[3],10),
[SysOut(" Answer is CORRECT"); iCorrect:=iCorrect+1;],
[SysOut(" Answer is WRONG: should be ",g );]
);
],
SysOut(" Answer is WRONG: should be ",g )
);
]
);
//SysOut(" Answer is WRONG: it should be ",g);
]
);
];
NewLine(2);
Tell("DONE",{iCorrect,i});
t2 := SystemTimer();
Echo("Time taken: ",N((t2-t1)/10^9)," sec");
%/mathpiper
mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/myMatch_new.mpi 0000644 0001750 0001750 00000002515 11166030403 024762 0 ustar giovanni giovanni
//Tell(a);
/////////////////////////////////////////////////////////////////
// my MatchLinear
/////////////////////////////////////////////////////////////////
10 # myMatchLinear(var_(Not IsAtom),expr) <-- List();
12 # myMatchLinear(_var,expr_CanBeUni) <--
[
Local(d,c);
d := myDegree(expr,var);
Tell(1,{expr,d});
If(d = 1, [c:=Coef(expr,var,{1,0}); Tell(ooo,{c}); c;], List() );
];
14 # myMatchLinear(_var,_expr) <-- List();
/////////////////////////////////////////////////////////////////
// my Degree
/////////////////////////////////////////////////////////////////
10 # myDegree(expr_CanBeUni,_var) <-- [Tell(D2,{expr,var}); Degree(expr,var);];
20 # myDegree(_expr,_var) <-- False;
Retract("tellMe",2);
Retract("trythis",2);
Clear(p1);
Clear(p2);
Clear(ss);
Clear(cc);
p1 := A*x+B;
p1 := x+B;
//p2 := A*x^2+B*x+C;
//ss := Sin(x);
//cc := 23;
10 # trythis(_var,_expr)_(mm:=myMatchLinear(var,expr)) <-- Tell("Here is the output: ",mm);
20 # trythis(_var,_expr) <-- Tell("NADA");
tellMe(_var,_expr) <--
[
Local(m,ccs);
Tell(CASE,expr);
m := myMatchLinear(var,expr);
Tell(1,m);
ccs := trythis(var,expr);
Tell(2,ccs);
];
//TraceOn();
tellMe(x,p1); NewLine();
//TraceOff();
/*tellMe(x,p2); NewLine();
tellMe(x,ss); NewLine();
tellMe(x,cc); NewLine();
*/
mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/factors_rational_number_bug.mpw 0000644 0001750 0001750 00000000305 11316262063 030265 0 ustar giovanni giovanni %mathpiper
10 # Factors(p_IsRational)_(Denominator(p) != 1) <-- {{Factor(Numerator(p)) / Factor(Denominator(p)) , 1}};
%/mathpiper
%output,preserve="false"
Result: True
. %/output
mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/resampling_statistics.mpw 0000644 0001750 0001750 00000033661 11316262063 027154 0 ustar giovanni giovanni
%mathpiper
Use("org/mathpiper/assembledscripts/proposed.rep/statistics.mpi");
Use("org/mathpiper/assembledscripts/proposed.rep/geogebra.mpi");
%/mathpiper
%output,preserve="false"
Result: True
. %/output
%mathpiper,title="two boys."
boysAndGirls := {};
ForEach(trial, 1 .. 100)
[
child1 := Round(Random());
child2 := Round(Random());
boysAndGirls := Append( boysAndGirls, {child1, child2} );
];
boysOnly := Remove(boysAndGirls,{0,0});
Echo("Trials :", boysOnly);
oneBoy := Count(boysOnly, {1,0}) + Count(boysOnly, {0,1});
twoBoys := Count(boysOnly, {1,1});
Echo("One boy: ", oneBoy);
Echo("Two boys: ", twoBoys);
Echo("At least one boy: ", Length(boysOnly),N( (oneBoy + twoBoys)/Length(boysAndGirls)));
N(twoBoys/ Length(boysOnly));
%/mathpiper
%output,preserve="false"
Result: 0.2564102564
Side Effects:
Trials :{{1,1},{0,1},{1,1},{0,1},{0,1},{0,1},{0,1},{1,1},{1,1},{1,1},{0,1},{1,1},{0,1},{0,1},{1,0},{1,1},{1,1},{1,0},{0,1},{0,1},{1,0},{1,0},{1,0},{1,0},{0,1},{0,1},{1,1},{1,1},{1,0},{1,0},{1,1},{1,0},{1,1},{1,0},{0,1},{0,1},{1,0},{0,1},{1,0},{0,1},{0,1},{1,0},{1,1},{0,1},{0,1},{1,0},{0,1},{0,1},{1,1},{0,1},{1,0},{0,1},{0,1},{1,0},{1,0},{0,1},{0,1},{1,0},{0,1},{0,1},{0,1},{1,0},{1,1},{1,0},{1,0},{1,0},{0,1},{1,0},{1,1},{1,0},{1,1},{0,1},{1,0},{0,1},{1,1},{1,1},{1,1},{1,0}}
One boy: 58
Two boys: 20
At least one boy: 78 0.78
. %/output
%mathpiper,title="Gold example on pp.82 chapter 6."
ships := {{gold, gold}, {gold, silver}, {silver, silver}};
score := {};
Repeat(1000)
[
ship := RandomPick(ships);
ship := Shuffle(ship);
If(Count(ship,gold) = 2, score := Append(score,success) );
If(Count(ship,silver) = 1,
If(ship[1] = gold, score := Append(score,failure))
);
];
initialGoldCount := Length(score);
goldGoldCount := Count(score,success);
result := N(goldGoldCount/initialGoldCount);
Echo(initialGoldCount,,,goldGoldCount,,,result);
%/mathpiper
%mathpiper,title="Three door problem pp.83 chapter 6."
firstPickScore := {};
secondPickScore := {};
Repeat(1000)
[
doors := Shuffle( {empty, prize, empty} );
firstPick := doors[1];
If(doors[2] = empty, secondPick := doors[3], secondPick := doors[2]);
firstPickScore := Append(firstPickScore, firstPick);
secondPickScore := Append(secondPickScore, secondPick);
];
Echo("First Pick: ", Count(firstPickScore,prize));
Echo("Second Pick: ", Count(secondPickScore,prize));
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
First Pick: 263
Second Pick: 737
. %/output
%mathpiper,title="Two of a kind problem pp.85 chapter 6."
pairsCount := 0;
deck := Concat(1 .. 13, 1 .. 13, 1 .. 13, 1 .. 13);
trials := 100;
Repeat(trials)
[
deck := Shuffle(deck);
hand := Take(deck,5);
//Echo(hand);
handPairCount := 0;
ForEach(card,1 .. 13)
[
If(Count(hand,card) = 2, handPairCount := handPairCount + 1);
];
If(handPairCount = 1, pairsCount := pairsCount + 1);
];
Echo("Probability of a single pair: ", N(pairsCount/trials) );
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
Probability of a single pair: 0.52
. %/output
%mathpiper,title="Two pairs vs. three of a kind problem pp.90 chapter 6."
pairsCount := 0;
threeOfAKindCount := 0;
deck := Concat(1 .. 13, 1 .. 13, 1 .. 13, 1 .. 13);
trials := 1000;
Repeat(trials)
[
deck := Shuffle(deck);
hand := Take(deck,5);
//Echo(hand);
handPairCount := 0;
handThreeOfAKindCount := 0;
ForEach(card,1 .. 13)
[
If(Count(hand,card) = 2, handPairCount := handPairCount + 1);
If(Count(hand,card) = 3, handThreeOfAKindCount := handThreeOfAKindCount + 1);
];
If(handPairCount = 2, pairsCount := pairsCount + 1);
If(handThreeOfAKindCount = 1, threeOfAKindCount := threeOfAKindCount + 1);
];
Echo("Probability of two pairs: ", N(pairsCount/trials) );
Echo("Probability of three of a kind: ", N(threeOfAKindCount/trials) );
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
Probability of two pairs: 0.052
Probability of three of a kind: 0.028
. %/output
%mathpiper,title="Birthday match from page 97 chapter 7."
birthdayMatchCounter := 0;
trials := 50;
Repeat(trials)
[
birthdays := RandomIntegerVector(25,1,365);
dayCounter := 1;
While(dayCounter <= 365)
[
If(Count(birthdays,dayCounter) >= 2, [birthdayMatchCounter := birthdayMatchCounter + 1; dayCounter := 366;]);
dayCounter := dayCounter + 1;
];
];
Echo(birthdayMatchCounter,,,trials);
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
31 , 50
. %/output
%mathpiper,title="Birthday the same as August 1st"
birthdayMatchCounter := 0;
trials := 1000;
Repeat(trials)
[
targetPersonBirthday := 213;
birthdays := RandomIntegerVector(25,1,365);
If( Contains(birthdays, targetPersonBirthday), birthdayMatchCounter++);
];
Echo(birthdayMatchCounter,,,trials,,,N(birthdayMatchCounter/trials));
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
81 , 1000 , 0.081
. %/output
%mathpiper,title="Three daughters example pp.97 chapter 7."
trials := 100;
successes := 0;
Repeat(trials)
[
sample := RandomSymbolVector( {{boy,1/2}, {girl,1/2} },4);
//Echo(sample);
If(Count(sample,girl) = 3, successes := successes + 1);
];
Echo(successes,,,trials);
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
27 , 100
. %/output
%mathpiper,title="5 shot basketball example pp.102 chapter 7."
trials := 100;
successes := 0;
Repeat(trials)
[
sample := RandomSymbolVector({{hit,1/4}, {miss,3/4}},5);
If(Count(sample,hit) >= 3, successes := successes + 1);
];
Echo(successes,,,trials);
%/mathpiper
%mathpiper,title="Archery example pp.104 chapter 7."
trials := 100;
successes := 0;
Repeat(trials)
[
sample := RandomSymbolVector({{black,10/100}, {white,60/100}, {miss,30/100}},3);
If(Count(sample,black)= 1 And Count(sample,white) = 2, successes := successes + 1);
];
Echo(successes,,,trials);
%/mathpiper
%mathpiper,title="Sum of hammers and handle lengths pp. 108"
sample := {};
trials := 100;
Repeat(trials)
[
handleLength := RandomSymbol({{10.0,20/100},{10.1,30/100},{10.2,30/100},{10.3,20/100}});
headLength := RandomSymbol({{2.0,20/100},{2.1,20/100},{2.2,30/100},{2.3,20/100},{2.4,10/100}});
totalLength := handleLength + headLength;
sample := Append(sample, totalLength);
];
givenLength := 12.4;
overOrEqual := 0;
ForEach(element, sample)
[
If(element >= givenLength, overOrEqual := overOrEqual + 1);
];
mean := Mean(sample);
Echo(overOrEqual,,,trials,,,mean);
%/mathpiper
%mathpiper,title="Flipping pennies pp.110 chapter 7."
trials := 2;
emptyCount := 0;
Repeat(trials)
[
stack1 := 10;
stack2 := 10;
iterations := Repeat(200)
[
flip := RandomSymbol({{head,1/2},{tail,1/2}});
If(flip = head, [stack1++; stack2--;], [stack1--; stack2++;] );
If(stack1 = 0 Or stack2 = 0, Break() );
];
Echo({stack1,,,stack2,,,iterations});
If(stack1 = 0 Or stack2 = 0, emptyCount++);
];
{emptyCount,trials};
%/mathpiper
%mathpiper,title="capacirators example pp. 112 chapter 7."
daysToEmptyList := {};
trials := 50;
Repeat(trials)
[
warehouseCount := 12;
dayCounter := 0;
daysToEmpty := Repeat()
[
morning := RandomSymbol({{used,6/10},{not_used,4/10}});
If(morning = used, warehouseCount--);
If(warehouseCount = 0, Break());
afternoon := RandomSymbol({{used,6/10},{not_used,4/10}});
If(afternoon = used, warehouseCount--);
If(warehouseCount = 0, Break());
If(Mod(dayCounter,3) = 0, warehouseCount := warehouseCount + 2);
//Echo(warehouseCount, dayCounter, Mod(dayCounter,3));
dayCounter++;
];
daysToEmptyList := Append(daysToEmptyList, daysToEmpty);
];
Echo("Average days to empty: ", Mean(daysToEmptyList));
%/mathpiper
%mathpiper,title="Random walk example at the end of chapter 7."
targetPositions := {{3,2}, {-1,-4}};
successCount := 0;
trials := 500;
Repeat(trials)
[
currentPosition := {0,0};
walkPath := {};
Repeat(12)
[
step:= RandomSymbol({{{1,0},1/4},{{-1,0},1/4},{{0,1},1/4},{{0,-1},1/4}});
currentPosition := currentPosition + step;
//walkPath := Append(walkPath,currentPosition);
If(Contains(targetPositions, currentPosition), [successCount++; Break();]);
];
//Write(walkPath);
];
{successCount, trials, N(successCount/trials)};
%/mathpiper
%output,preserve="false"
Result: {35,500,0.07}
. %/output
%mathpiper,title="case 1 example pp. 119 chapter 8."
balls := {1,2,3,4,5,6};
successCount := 0;
trials := 1000;
Repeat(trials)
[
sample := Sample(balls,3);
If(sample = {1,2,3}, successCount++);
];
Echo(successCount,,,trials,,,N(successCount/trials));
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
36 , 5000 , 0.0072
. %/output
%mathpiper,title="case 2 example pp. 120 chapter 8."
balls := {1,2,3,4,5,6};
successCount := 0;
trials := 1000;
Repeat(trials)
[
sample := Sample(balls,3);
If(IsSubset({1,2,3},sample), successCount++);
];
Echo(successCount,,,trials,,,N(successCount/trials));
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
49 , 1000 , 0.049
. %/output
%mathpiper,title="case 3 example pp. 121 chapter 8."
balls := {1,2,3,4,5,6};
successCount := 0;
trials := 1000;
Repeat(trials)
[
sample := Sample(balls,3);
If( (IsOdd(sample[1]) And IsEven(sample[2])) Or (IsOdd(sample[2]) And IsEven(sample[3])), successCount++);
];
Echo(successCount,,,trials,,,N(successCount/trials));
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
588 , 1000 , 0.588
. %/output
%mathpiper,title="case 4 example pp. 120 chapter 8."
balls := {1,2,3,4,5,6};
successCount := 0;
trials := 1000;
Repeat(trials)
[
sample := Sample(balls,3);
If(Length(Select("IsOdd",sample)) = 2, successCount++);
];
Echo(successCount,,,trials,,,N(successCount/trials));
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
423 , 1000 , 0.423
. %/output
%mathpiper,title="case 5a example pp. 121 chapter 8."
balls := {1,2,3,4,5,6};
successCount := 0;
trials := 1000;
Repeat(trials)
[
sample := Sample(balls,3);
If(sample[1] = 1 Or sample[2] = 2 Or sample[3] = 3, successCount++);
];
Echo(successCount,,,trials,,,N(successCount/trials));
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
421 , 1000 , 0.421
. %/output
%mathpiper,title="case 5b example pp. 121 chapter 8."
balls := {1,2,3,4,5,6};
successCount := 0;
trials := 10000;
Repeat(trials)
[
sample := Sample(balls,6);
If(sample = {1,2,3,4,5,6}, successCount++);
];
Echo(successCount,,,trials,,,N(successCount/trials));
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
19 , 10000 , 0.0019
. %/output
%mathpiper,title="example 8-1 50 girls and boys pp. 122."
class := Concat(FillList(boy,25), FillList(girl,25));
samples := {};
trials := 100;
Repeat(trials)
[
class := Shuffle(class);
sample := Take(class,5);
samples := Count(sample,girl) : samples;
];
successCount := Count(samples,4);
Echo(successCount,,,trials,,,N(successCount/trials));
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
14 , 100 , 0.14
. %/output
%mathpiper,title="Extra code for example 8-1"
GeoGebraHistogram(samples);
%/mathpiper
%output,preserve="false"
Result: true
. %/output
%mathpiper,title="Example 8-2 9 spades pp. 125"
samples := {};
trials := 100;
deck := Concat(FillList(spades,13), FillList(diamonds,13), FillList(hearts,13), FillList(clubs,13));
//test := {};
//counter := 0;
Repeat(trials)
[
(deck := Shuffle(deck));
(hand := Take(deck,13));
//test := Count(hand, spades) : test;
(If(Count(hand, spades) = 9, Count(hand, clubs) : samples));
//If(Mod(counter,100) = 0, SysOut("Trial # ",,, counter));
//counter++;
];
samples;
%/mathpiper
%output,preserve="false"
Result: {}
. %/output
%mathpiper,title="Extra code for example 8-2"
//The probability of obtaining 9 spades seems to be very low.
N( (Combinations(13,9) * Combinations(39,4)) / Combinations(52,13) );
%/mathpiper
%output,preserve="false"
Result: 0.00009261135311
. %/output
%mathpiper,title="Extra code for example 8-2"
GeoGebraHistogram(test);
%/mathpiper
%output,preserve="false"
Result: true
. %/output
mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/computer_algebra_cohen/ 0000755 0001750 0001750 00000000000 11722677314 026504 5 ustar giovanni giovanni mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/computer_algebra_cohen/ostrowsky/ 0000755 0001750 0001750 00000000000 11722677314 030570 5 ustar giovanni giovanni mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/computer_algebra_cohen/kosan/ 0000755 0001750 0001750 00000000000 11722677314 027617 5 ustar giovanni giovanni mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/computer_algebra_cohen/kosan/Kind.mpw 0000644 0001750 0001750 00000001677 11316262063 031232 0 ustar giovanni giovanni %mathpiper
/*
This is the beginnings of a Kind function which will return:
1) If u is an atomic expression, return the type of the expression.
2) If u is a compund expression, return the operator at the root of the
expression tree.
pp.104 "Computer Algebra And Symbolic Computation: Elementary Algorithms" Cohen.
*/
Retract("Kind",*);
RuleBase("Kind",{u});
//HoldArg("Kind",u);
10 # Kind(_u) <--
[
Write(u,,);
Local(result);
if(IsInteger(u))
[
result := integer;
Echo(1);
]
else if(IsString(u))
[
result := string;
Echo(2);
]
else if(IsList(u))
[
result := list;
Echo(3);
]
else if(Not IsBound(Eval(u)))
[
result := symbol;
Echo(10);
]
else
[
];
result;
];
Kind({3});
%/mathpiper
%output,preserve="false"
Result: list
Side Effects:
{3},3
. %/output
././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/computer_algebra_cohen/kosan/computer_algebra_elementary_algorithms_cohen.mpw mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/computer_algebra_cohen/kosan/computer_algebra_eleme0000644 0001750 0001750 00000006260 11316262063 034216 0 ustar giovanni giovanni
%mathpiper
CASCompare(expressions) :=
[
Local(count,e,me, answer);
count := 1;
ForEach(e,expressions)
[
If(IsList(e), [answer := e[2]; e := e[1];]);
Echo("#",count ,"Exercise: ",e, If(IsBound(answer),ToString()[WriteString(" Answer: " );Write(answer);Clear(answer);],"") );
//Echo("MathPiper: ",Simplify(Eval(FromString(e:";") Read())));
Echo("MathPiper: ",Eval(FromString(e:";") Read()));
//me := ToString()[WriteString("ratsimp(");Write(Atom(e));WriteString(")");];
me := ToString()[WriteString("(");Write(Atom(e));WriteString(")");];
Echo("Maxima:",Maxima(me));
count := count + 1;
];
];
%/mathpiper
%output,preserve="false"
Result: True
. %/output
%mathpiper,title="page 55 exercises 1a.
Echo("pp.55 exercises. 1a ");
NewLine();
expressions :={
{"x^2*x^3","x^5"},
{"x^(1/2)*x^(1/3)","x^(5/6)"},
{"x^a*x^b","x^(a+b)"},
{"(x^2)^3","x^6"},
{"(x^a)^2","x^(2*a)"},
{"(x^2)^(1/2)","|x|"},
{"(x^(1/2))^2","x"},
{"(x^2)^a","x^(2*a)"},
{"(x*y)^2","x^2*y^2"},
{"(x*y)^(1/3)","x^(1/3)*y^(1/3)"},
{"(x*y)^a","x^a*y^a"},
};
CASCompare(expressions);
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
pp.55 exercises. 1a
#1 Exercise: x^2*x^3 Answer: "x^5"
MathPiper: x^5
Maxima:(%o700) x^5
#2 Exercise: x^(1/2)*x^(1/3) Answer: "x^(5/6)"
MathPiper: Sqrt(x)*x^(1/3)
Maxima:(%o701) x^(5/6)
#3 Exercise: x^a*x^b Answer: "x^(a+b)"
MathPiper: x^(b+a)
Maxima:(%o702) x^(b+a)
#4 Exercise: (x^2)^3 Answer: "x^6"
MathPiper: x^6
Maxima:(%o703) x^6
#5 Exercise: (x^a)^2 Answer: "x^(2*a)"
MathPiper: x^a^2
Maxima:(%o704) x^(2*a)
#6 Exercise: (x^2)^(1/2) Answer: "|x|"
MathPiper: Sqrt(x^2)
Maxima:(%o705) abs(x)
#7 Exercise: (x^(1/2))^2 Answer: "x"
MathPiper: x
Maxima:(%o706) x
#8 Exercise: (x^2)^a Answer: "x^(2*a)"
MathPiper: x^2^a
Maxima:(%o707) abs(x)^(2*a)
#9 Exercise: (x*y)^2 Answer: "x^2*y^2"
MathPiper: (x*y)^2
Maxima:(%o708) x^2*y^2
#10 Exercise: (x*y)^(1/3) Answer: "x^(1/3)*y^(1/3)"
MathPiper: (x*y)^(1/3)
Maxima:(%o709) x^(1/3)*y^(1/3)
#11 Exercise: (x*y)^a Answer: "x^a*y^a"
MathPiper: (x*y)^a
Maxima:(%o710) (x*y)^a
. %/output
%mathpiper,title="page 55 exercises 2a.
Echo("pp.55 exercises. 1a ");
NewLine();
expressions :={
{"2*x+3*x","5*x"},
{"(1+x)+2*(1+x)","3*(1+x)"},
{"2*x+Sqrt(2)*x","(2+Sqrt(2))*x"},
{"a*x + b*x","(a+b)*x"},
{"(a+b)*x","a*x+b*x)"},
{"2*(x+y)","2*x+2*y"},
{"-(x+y)","-x-y"},
{"a*(x+y)","a*x+a*y"},
};
//CASCompare(expressions);
%/mathpiper
%output,preserve="false"
Result: {{"2*x+3*x","5*x"},{"(1+x)+2*(1+x)","3*(1+x)"},{"2*x+Sqrt(2)*x","(2+Sqrt(2))*x"},{"a*x + b*x","(a+b)*x"},{"(a+b)*x","a*x+b*x)"},{"2*(x+y)","2*x+2*y"},{"-(x+y)","-x-y"},{"a*(x+y)","a*x+a*y"}}
Side Effects:
pp.55 exercises. 1a
. %/output
mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/myMatch_new.mpt 0000644 0001750 0001750 00000040365 11417150721 025007 0 ustar giovanni giovanni init:
deps-jar:
compile-single:
run-single:
Maxima is initialized
Debug> Loading file"org/mathpiper/scripts/predicates.rep/code.mpi" for function IsMatrix
Debug> Finished loading file "org/mathpiper/scripts/predicates.rep/code.mpi"
Leave}(TraceOn(),True);
Enter{(tellMe,tellMe(x,p1));
Arg(x,x);
Arg(p1,x+B);
Enter{(Prog,[
Local(m,ccs);
Tell(CASE,expr);
m:=myMatchLinear(var,expr);
Tell(1,m);
ccs:=trythis(var,expr);
Tell(2,ccs);
]
);
Arg(Local(m,ccs),{Local(m,ccs),Tell(CASE,expr),m:=myMatchLinear(var,expr),Tell(1,m),ccs:=trythis(var,expr),Tell(2,ccs)});
Enter{(Local,Local(m,ccs));
Arg(m,{m,ccs});
Leave}(Local(m,ccs),True);
Debug> Loading file"org/mathpiper/scripts/testers.rep/code.mpi" for function Tell
Enter{(Function,Function(BenchCall,{expr})[
Echo({In> ,expr});
WriteString();
Eval(expr);
WriteString();
True;
]
);
Arg(BenchCall,BenchCall);
Arg({expr},{expr});
Arg([
Echo({In> ,expr});
WriteString();
Eval(expr);
WriteString();
True;
]
,[
Echo({In> ,expr});
WriteString();
Eval(expr);
WriteString();
True;
]
);
Enter{(And,GreaterThan(Length(args),1)And Equals(MathNth(args,Length(args)),Atom(...)));
Arg(GreaterThan(Length(args),1),{GreaterThan(Length(args),1),Equals(MathNth(args,Length(args)),Atom(...))});
Enter{(GreaterThan,GreaterThan(Length(args),1));
Enter{(Length,Length(args));
Leave}(Length(args),1);
Leave}(GreaterThan(Length(args),1),False);
Leave}(GreaterThan(Length(args),1)And Equals(MathNth(args,Length(args)),Atom(...)),False);
Enter{(Prog,[
Retract(oper,Length(args));
MacroRuleBase(oper,args);
MacroRule(oper,Length(args),1025,True)body;
]
);
Arg(Retract(oper,Length(args)),{Retract(oper,Length(args)),MacroRuleBase(oper,args),MacroRule(oper,Length(args),1025,True)body});
Enter{(Retract,Retract(oper,Length(args)));
Enter{(Length,Length(args));
Leave}(Length(args),1);
Leave}(Retract(oper,Length(args)),True);
Enter{(MacroRuleBase,MacroRuleBase(oper,args));
Leave}(MacroRuleBase(oper,args),True);
Enter{(MacroRule,MacroRule(oper,Length(args),1025,True)body);
Enter{(Length,Length(args));
Leave}(Length(args),1);
Leave}(MacroRule(oper,Length(args),1025,True)body,True);
Leave}([
Retract(oper,Length(args));
MacroRuleBase(oper,args);
MacroRule(oper,Length(args),1025,True)body;
]
,True);
Leave}(Function(BenchCall,{expr})[
Echo({In> ,expr});
WriteString();
Eval(expr);
WriteString();
True;
]
,True);
Enter{(HoldArg,HoldArg(BenchCall,expr));
Leave}(HoldArg(BenchCall,expr),True);
Enter{(Function,Function(BenchShow,{expr})[
Echo({In> ,expr});
WriteString( );
Echo({Out> ,Eval(expr),});
True;
]
);
Arg(BenchShow,BenchShow);
Arg({expr},{expr});
Arg([
Echo({In> ,expr});
WriteString( );
Echo({Out> ,Eval(expr),});
True;
]
,[
Echo({In> ,expr});
WriteString( );
Echo({Out> ,Eval(expr),});
True;
]
);
Enter{(And,GreaterThan(Length(args),1)And Equals(MathNth(args,Length(args)),Atom(...)));
Arg(GreaterThan(Length(args),1),{GreaterThan(Length(args),1),Equals(MathNth(args,Length(args)),Atom(...))});
Enter{(GreaterThan,GreaterThan(Length(args),1));
Enter{(Length,Length(args));
Leave}(Length(args),1);
Leave}(GreaterThan(Length(args),1),False);
Leave}(GreaterThan(Length(args),1)And Equals(MathNth(args,Length(args)),Atom(...)),False);
Enter{(Prog,[
Retract(oper,Length(args));
MacroRuleBase(oper,args);
MacroRule(oper,Length(args),1025,True)body;
]
);
Arg(Retract(oper,Length(args)),{Retract(oper,Length(args)),MacroRuleBase(oper,args),MacroRule(oper,Length(args),1025,True)body});
Enter{(Retract,Retract(oper,Length(args)));
Enter{(Length,Length(args));
Leave}(Length(args),1);
Leave}(Retract(oper,Length(args)),True);
Enter{(MacroRuleBase,MacroRuleBase(oper,args));
Leave}(MacroRuleBase(oper,args),True);
Enter{(MacroRule,MacroRule(oper,Length(args),1025,True)body);
Enter{(Length,Length(args));
Leave}(Length(args),1);
Leave}(MacroRule(oper,Length(args),1025,True)body,True);
Leave}([
Retract(oper,Length(args));
MacroRuleBase(oper,args);
MacroRule(oper,Length(args),1025,True)body;
]
,True);
Leave}(Function(BenchShow,{expr})[
Echo({In> ,expr});
WriteString( );
Echo({Out> ,Eval(expr),});
True;
]
,True);
Enter{(HoldArg,HoldArg(BenchShow,expr));
Leave}(HoldArg(BenchShow,expr),True);
Enter{(<--,10#EchoInternal(string _IsString)<--[
WriteString(string);
]
);
Arg(10#EchoInternal(string _IsString),10#EchoInternal(string _IsString));
Arg([
WriteString(string);
]
,[
WriteString(string);
]
);
Enter{(Equals,Equals(Type(patternleft),#));
Enter{(Type,Type(patternleft));
Leave}(Type(patternleft),#);
Leave}(Equals(Type(patternleft),#),True);
Enter{(Prog,[
DefinePattern(patternleft[2],patternright,patternleft[1],True);
]
);
Arg(DefinePattern(patternleft[2],patternright,patternleft[1],True),{DefinePattern(patternleft[2],patternright,patternleft[1],True)});
Enter{(DefinePattern,DefinePattern(patternleft[2],patternright,patternleft[1],True));
Enter{(Nth,patternleft[2]);
Arg(patternleft,10#EchoInternal(string _IsString));
Arg(2,2);
Enter{(And,And(Equals(IsFunction(alist),True),Equals(IsInteger(aindex),True),Not Equals(Head(Listify(alist)),Nth)));
Arg(Equals(IsFunction(alist),True),{Equals(IsFunction(alist),True),Equals(IsInteger(aindex),True),Not Equals(Head(Listify(alist)),Nth)});
Enter{(Equals,Equals(IsFunction(alist),True));
Enter{(IsFunction,IsFunction(alist));
Leave}(IsFunction(alist),True);
Leave}(Equals(IsFunction(alist),True),True);
Enter{(Equals,Equals(IsInteger(aindex),True));
Enter{(IsInteger,IsInteger(aindex));
Leave}(IsInteger(aindex),True);
Leave}(Equals(IsInteger(aindex),True),True);
Enter{(Not,Not Equals(Head(Listify(alist)),Nth));
Enter{(Equals,Equals(Head(Listify(alist)),Nth));
Enter{(Head,Head(Listify(alist)));
Enter{(Listify,Listify(alist));
Leave}(Listify(alist),{#,10,EchoInternal(string _IsString)});
Leave}(Head(Listify(alist)),#);
Leave}(Equals(Head(Listify(alist)),Nth),False);
Leave}(Not Equals(Head(Listify(alist)),Nth),True);
Leave}(And(Equals(IsFunction(alist),True),Equals(IsInteger(aindex),True),Not Equals(Head(Listify(alist)),Nth)),True);
Enter{(MathNth,MathNth(alist,aindex));
Leave}(MathNth(alist,aindex),EchoInternal(string _IsString));
Leave}(patternleft[2],EchoInternal(string _IsString));
Enter{(Nth,patternleft[1]);
Arg(patternleft,10#EchoInternal(string _IsString));
Arg(1,1);
Enter{(And,And(Equals(IsFunction(alist),True),Equals(IsInteger(aindex),True),Not Equals(Head(Listify(alist)),Nth)));
Arg(Equals(IsFunction(alist),True),{Equals(IsFunction(alist),True),Equals(IsInteger(aindex),True),Not Equals(Head(Listify(alist)),Nth)});
Enter{(Equals,Equals(IsFunction(alist),True));
Enter{(IsFunction,IsFunction(alist));
Leave}(IsFunction(alist),True);
Leave}(Equals(IsFunction(alist),True),True);
Enter{(Equals,Equals(IsInteger(aindex),True));
Enter{(IsInteger,IsInteger(aindex));
Leave}(IsInteger(aindex),True);
Leave}(Equals(IsInteger(aindex),True),True);
Enter{(Not,Not Equals(Head(Listify(alist)),Nth));
Enter{(Equals,Equals(Head(Listify(alist)),Nth));
Enter{(Head,Head(Listify(alist)));
Enter{(Listify,Listify(alist));
Leave}(Listify(alist),{#,10,EchoInternal(string _IsString)});
Leave}(Head(Listify(alist)),#);
Leave}(Equals(Head(Listify(alist)),Nth),False);
Leave}(Not Equals(Head(Listify(alist)),Nth),True);
Leave}(And(Equals(IsFunction(alist),True),Equals(IsInteger(aindex),True),Not Equals(Head(Listify(alist)),Nth)),True);
Enter{(MathNth,MathNth(alist,aindex));
Leave}(MathNth(alist,aindex),10);
Leave}(patternleft[1],10);
Arg(patternleft[2],EchoInternal(string _IsString));
Arg(patternright,[
WriteString(string);
]
);
Arg(patternleft[1],10);
Arg(True,True);
Enter{(Equals,Equals(Type(patternleft),_));
Enter{(Type,Type(patternleft));
Leave}(Type(patternleft),EchoInternal);
Leave}(Equals(Type(patternleft),_),False);
Enter{(Prog,[
Local(patternflat,patternvars,patt,patternoper,arity);
Set(patternflat,Listify(patternleft));
Set(patternvars,Tail(patternflat));
Set(patternoper,String(Head(patternflat)));
Set(arity,Length(patternvars));
DefLoadFunction(patternoper);
If(Not RuleBaseDefined(patternoper,arity),[
MacroRuleBase(patternoper,MakeVector(arg,arity));
]
);
Set(patt,PatternCreate(patternvars,postpredicate));
MacroRulePattern(patternoper,arity,patternprecedence,patt)patternright;
True;
]
);
Arg(Local(patternflat,patternvars,patt,patternoper,arity),{Local(patternflat,patternvars,patt,patternoper,arity),Set(patternflat,Listify(patternleft)),Set(patternvars,Tail(patternflat)),Set(patternoper,String(Head(patternflat))),Set(arity,Length(patternvars)),DefLoadFunction(patternoper),If(Not RuleBaseDefined(patternoper,arity),[
MacroRuleBase(patternoper,MakeVector(arg,arity));
]
),Set(patt,PatternCreate(patternvars,postpredicate)),MacroRulePattern(patternoper,arity,patternprecedence,patt)patternright,True});
Enter{(Local,Local(patternflat,patternvars,patt,patternoper,arity));
Arg(patternflat,{patternflat,patternvars,patt,patternoper,arity});
Leave}(Local(patternflat,patternvars,patt,patternoper,arity),True);
Enter{(Set,Set(patternflat,Listify(patternleft)));
Enter{(Listify,Listify(patternleft));
Leave}(Listify(patternleft),{EchoInternal,string _IsString});
Leave}(Set(patternflat,Listify(patternleft)),True);
Enter{(Set,Set(patternvars,Tail(patternflat)));
Enter{(Tail,Tail(patternflat));
Leave}(Tail(patternflat),{string _IsString});
Leave}(Set(patternvars,Tail(patternflat)),True);
Enter{(Set,Set(patternoper,String(Head(patternflat))));
Enter{(String,String(Head(patternflat)));
Enter{(Head,Head(patternflat));
Leave}(Head(patternflat),EchoInternal);
Leave}(String(Head(patternflat)),EchoInternal);
Leave}(Set(patternoper,String(Head(patternflat))),True);
Enter{(Set,Set(arity,Length(patternvars)));
Enter{(Length,Length(patternvars));
Leave}(Length(patternvars),1);
Leave}(Set(arity,Length(patternvars)),True);
Enter{(DefLoadFunction,DefLoadFunction(patternoper));
Leave}(DefLoadFunction(patternoper),True);
Enter{(If,If(Not RuleBaseDefined(patternoper,arity),[
MacroRuleBase(patternoper,MakeVector(arg,arity));
]
));
Arg(Not RuleBaseDefined(patternoper,arity),Not RuleBaseDefined(patternoper,arity));
Enter{(Not,Not RuleBaseDefined(patternoper,arity));
Enter{(RuleBaseDefined,RuleBaseDefined(patternoper,arity));
Leave}(RuleBaseDefined(patternoper,arity),False);
Leave}(Not RuleBaseDefined(patternoper,arity),True);
Enter{(Prog,[
MacroRuleBase(patternoper,MakeVector(arg,arity));
]
);
Arg(MacroRuleBase(patternoper,MakeVector(arg,arity)),{MacroRuleBase(patternoper,MakeVector(arg,arity))});
Enter{(MacroRuleBase,MacroRuleBase(patternoper,MakeVector(arg,arity)));
Enter{(MakeVector,MakeVector(arg,arity));
Arg(arg,arg);
Arg(arity,1);
Enter{(Prog,[
Local(res,i);
res:={};
i:=1;
Set(dimension,AddN(dimension,1));
While(LessThan(i,dimension))[
DestructiveInsert(res,1,Atom(ConcatStrings(String(vec),String(i))));
Set(i,AddN(i,1));
]
;
DestructiveReverse(res);
]
);
Arg(Local(res,i),{Local(res,i),res:={},i:=1,Set(dimension,AddN(dimension,1)),While(LessThan(i,dimension))[
DestructiveInsert(res,1,Atom(ConcatStrings(String(vec),String(i))));
Set(i,AddN(i,1));
]
,DestructiveReverse(res)});
Enter{(Local,Local(res,i));
Arg(res,{res,i});
Leave}(Local(res,i),True);
Enter{(:=,res:={});
Arg(res,res);
Arg({},{});
Enter{(IsList,IsList(aLeftAssign));
Leave}(IsList(aLeftAssign),False);
Enter{(IsAtom,IsAtom(aLeftAssign));
Leave}(IsAtom(aLeftAssign),True);
Enter{(Prog,[
MacroSet(aLeftAssign,Eval(aRightAssign));
Eval(aLeftAssign);
]
);
Arg(MacroSet(aLeftAssign,Eval(aRightAssign)),{MacroSet(aLeftAssign,Eval(aRightAssign)),Eval(aLeftAssign)});
Enter{(MacroSet,MacroSet(aLeftAssign,Eval(aRightAssign)));
Enter{(Eval,Eval(aRightAssign));
Enter{(List,{});
Arg(Load test: Result: True Side Effects: Tracing is on. Errors: Assertion failed.
BUILD SUCCESSFUL (total time: 1 second)
mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/geogebra_interaction.mpw 0000644 0001750 0001750 00000003570 11316262063 026707 0 ustar giovanni giovanni
%*
Create 3 points A, B and C in GeoGebra.
*/
%mathpiper,title=""
/*
The GeoGebra() function is used to tell the system which GeoGebra objects
should be inserted into the MathPiper environment. The names of the
objects are sent to the GeoGebra() function in a comma separated list.
*/
GeoGebra()["updateObjects"] := "A,B,C,f,g";
/*
GeoGebraPoint() is an experimental function which directly places points
into GeoGebra. The first parameter is the name of the point, the second
parameter is its x coordinate, and the third parameter is the name of
its y coordinate.
*/
GeoGebraPoint("A",1,2);
GeoGebraPoint("B",2,2);
GeoGebraPoint("C",1,1);
%/mathpiper
%output,preserve="false"
Result: java.lang.Boolean
. %/output
%mathpiper, output="latex"
ax := A["coords"]["x"];
ay := A["coords"]["y"];
bx := B["coords"]["x"];
by := B["coords"]["y"];
cx := C["coords"]["x"];
cy := C["coords"]["y"];
%/mathpiper
%hoteqn,preserve="false"
Result: 1.0
. %/hoteqn
%mathpiper, output="geogebra"
bez1(a,b,r) := a*(1-r)+b*r;
bez2(a,b,c,r) := bez1(a,b,r)*(1-r) + bez1(b,c,r)*r;
f(x) := Expand(bez2(ax,bx,cx,x));
f(x);
%/mathpiper
%geogebra,preserve="false"
Result: 2.0*x-2.0*x^2+1
. %/geogebra
%output,preserve="false"
GeoGebra updated.
. %/output
%mathpiper, output="geogebra"
g(x) := Expand(bez2(ay,by,cy,x));
g(x);
%/mathpiper
%geogebra,preserve="false"
Result: 2.0-x^2
. %/geogebra
%output,preserve="false"
GeoGebra updated.
. %/output
%geogebra, clear="false"
curve : curve[f(t),g(t),t,0,1]
%/geogebra
%output,preserve="false"
GeoGebra updated.
. %/output
%mathpiper, output="latex"
{f(x), g(x)};
%/mathpiper
%hoteqn,preserve="false"
Result: \left(2x-2x^{2}+1,2-x^{2}\right)
. %/hoteqn
%output,preserve="false"
HotEqn updated.
. %/output
mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/extra_parentheses.mpt 0000644 0001750 0001750 00000047704 11166031233 026261 0 ustar giovanni giovanni In> ee:=a*b*c/(d*e)
Result> (a*b*c)/(d*e)
In> TraceOn()
Result> True
Side Effects>
Tracing is on.
Leave}(TraceOn(),True);
In> ee:=a*b*c/(d*e)
Result> (a*b*c)/(d*e)
Side Effects>
Enter{(:=,ee:=a*b*c/(d*e));
Arg(ee,ee);
Arg(a*b*c/(d*e),a*b*c/(d*e));
Enter{(IsList,IsList(aLeftAssign));
Leave}(IsList(aLeftAssign),False);
Enter{(IsAtom,IsAtom(aLeftAssign));
Leave}(IsAtom(aLeftAssign),True);
Enter{(Prog,[
MacroSet(aLeftAssign,Eval(aRightAssign));
Eval(aLeftAssign);
]
);
Arg(MacroSet(aLeftAssign,Eval(aRightAssign)),{MacroSet(aLeftAssign,Eval(aRightAssign)),Eval(aLeftAssign)});
Enter{(MacroSet,MacroSet(aLeftAssign,Eval(aRightAssign)));
Enter{(Eval,Eval(aRightAssign));
Enter{(*,a*b*c/(d*e));
Enter{(*,a*b);
Arg(a,a);
Arg(b,b);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Enter{(IsMatrix,IsMatrix(x));
Arg(x,a);
Enter{(If,If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False));
Arg(IsList($x10)And Length($x10)>0,IsList($x10)And Length($x10)>0);
Enter{(And,IsList($x10)And Length($x10)>0);
Arg(IsList($x10),{IsList($x10),Length($x10)>0});
Enter{(IsList,IsList($x10));
Leave}(IsList($x10),False);
Leave}(IsList($x10)And Length($x10)>0,False);
Leave}(If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False),False);
Leave}(IsMatrix(x),False);
Enter{(IsMatrix,IsMatrix(x));
Arg(x,a);
Enter{(If,If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False));
Arg(IsList($x10)And Length($x10)>0,IsList($x10)And Length($x10)>0);
Enter{(And,IsList($x10)And Length($x10)>0);
Arg(IsList($x10),{IsList($x10),Length($x10)>0});
Enter{(IsList,IsList($x10));
Leave}(IsList($x10),False);
Leave}(IsList($x10)And Length($x10)>0,False);
Leave}(If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False),False);
Leave}(IsMatrix(x),False);
Enter{(IsList,IsList(x));
Leave}(IsList(x),False);
Enter{(IsNonObject,IsNonObject(x));
Arg(x,a);
Leave}(IsNonObject(x),True);
Enter{(IsList,IsList(y));
Leave}(IsList(y),False);
Enter{(IsNumber,IsNumber(y));
Leave}(IsNumber(y),False);
Enter{(=,f= -1);
Enter{(-,-1);
Arg(1,1);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),True);
Enter{(SubtractN,SubtractN(0,x));
Leave}(SubtractN(0,x),-1);
Leave}(-1,-1);
Leave}(f= -1,False);
Enter{(=,f= -1);
Enter{(-,-1);
Arg(1,1);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),True);
Enter{(SubtractN,SubtractN(0,x));
Leave}(SubtractN(0,x),-1);
Leave}(-1,-1);
Leave}(f= -1,False);
Enter{(IsList,IsList(aLeft));
Leave}(IsList(aLeft),False);
Enter{(IsInfinity,IsInfinity(x));
Arg(x,a);
Leave}(IsInfinity(x),False);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Leave}(a*b,a*b);
Enter{(/,c/(d*e));
Enter{(*,d*e);
Arg(d,d);
Arg(e,e);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Enter{(IsMatrix,IsMatrix(x));
Arg(x,d);
Enter{(If,If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False));
Arg(IsList($x10)And Length($x10)>0,IsList($x10)And Length($x10)>0);
Enter{(And,IsList($x10)And Length($x10)>0);
Arg(IsList($x10),{IsList($x10),Length($x10)>0});
Enter{(IsList,IsList($x10));
Leave}(IsList($x10),False);
Leave}(IsList($x10)And Length($x10)>0,False);
Leave}(If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False),False);
Leave}(IsMatrix(x),False);
Enter{(IsMatrix,IsMatrix(x));
Arg(x,d);
Enter{(If,If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False));
Arg(IsList($x10)And Length($x10)>0,IsList($x10)And Length($x10)>0);
Enter{(And,IsList($x10)And Length($x10)>0);
Arg(IsList($x10),{IsList($x10),Length($x10)>0});
Enter{(IsList,IsList($x10));
Leave}(IsList($x10),False);
Leave}(IsList($x10)And Length($x10)>0,False);
Leave}(If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False),False);
Leave}(IsMatrix(x),False);
Enter{(IsList,IsList(x));
Leave}(IsList(x),False);
Enter{(IsNonObject,IsNonObject(x));
Arg(x,d);
Leave}(IsNonObject(x),True);
Enter{(IsList,IsList(y));
Leave}(IsList(y),False);
Enter{(IsNumber,IsNumber(y));
Leave}(IsNumber(y),False);
Enter{(=,f= -1);
Enter{(-,-1);
Arg(1,1);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),True);
Enter{(SubtractN,SubtractN(0,x));
Leave}(SubtractN(0,x),-1);
Leave}(-1,-1);
Leave}(f= -1,False);
Enter{(=,f= -1);
Enter{(-,-1);
Arg(1,1);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),True);
Enter{(SubtractN,SubtractN(0,x));
Leave}(SubtractN(0,x),-1);
Leave}(-1,-1);
Leave}(f= -1,False);
Enter{(IsList,IsList(aLeft));
Leave}(IsList(aLeft),False);
Enter{(IsInfinity,IsInfinity(x));
Arg(x,d);
Leave}(IsInfinity(x),False);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Leave}(d*e,d*e);
Arg(c,c);
Arg(d*e,d*e);
Enter{(IsNumber,IsNumber(y));
Leave}(IsNumber(y),False);
Enter{(IsNonZeroInteger,IsNonZeroInteger(x));
Arg(x,c);
Enter{(And,IsInteger(x)And x!=0);
Arg(IsInteger(x),{IsInteger(x),x!=0});
Enter{(IsInteger,IsInteger(x));
Leave}(IsInteger(x),False);
Leave}(IsInteger(x)And x!=0,False);
Leave}(IsNonZeroInteger(x),False);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Enter{(IsInfinity,IsInfinity(x));
Arg(x,c);
Leave}(IsInfinity(x),False);
Enter{(IsInfinity,IsInfinity(x));
Arg(x,c);
Leave}(IsInfinity(x),False);
Enter{(IsInfinity,IsInfinity(x));
Arg(x,c);
Leave}(IsInfinity(x),False);
Enter{(IsNegativeNumber,IsNegativeNumber(y));
Arg(y,d*e);
Enter{(And,IsNumber(x)And x<0);
Arg(IsNumber(x),{IsNumber(x),x<0});
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Leave}(IsNumber(x)And x<0,False);
Leave}(IsNegativeNumber(y),False);
Enter{(IsList,IsList(xlist));
Leave}(IsList(xlist),False);
Enter{(IsList,IsList(y));
Leave}(IsList(y),False);
Enter{(IsList,IsList(x));
Leave}(IsList(x),False);
Leave}(c/(d*e),c/(d*e));
Arg(a*b,a*b);
Arg(c/(d*e),c/(d*e));
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Enter{(IsMatrix,IsMatrix(x));
Arg(x,a*b);
Enter{(If,If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False));
Arg(IsList($x10)And Length($x10)>0,IsList($x10)And Length($x10)>0);
Enter{(And,IsList($x10)And Length($x10)>0);
Arg(IsList($x10),{IsList($x10),Length($x10)>0});
Enter{(IsList,IsList($x10));
Leave}(IsList($x10),False);
Leave}(IsList($x10)And Length($x10)>0,False);
Leave}(If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False),False);
Leave}(IsMatrix(x),False);
Enter{(IsMatrix,IsMatrix(x));
Arg(x,a*b);
Enter{(If,If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False));
Arg(IsList($x10)And Length($x10)>0,IsList($x10)And Length($x10)>0);
Enter{(And,IsList($x10)And Length($x10)>0);
Arg(IsList($x10),{IsList($x10),Length($x10)>0});
Enter{(IsList,IsList($x10));
Leave}(IsList($x10),False);
Leave}(IsList($x10)And Length($x10)>0,False);
Leave}(If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False),False);
Leave}(IsMatrix(x),False);
Enter{(IsList,IsList(x));
Leave}(IsList(x),False);
Enter{(IsNonObject,IsNonObject(x));
Arg(x,a*b);
Leave}(IsNonObject(x),True);
Enter{(IsList,IsList(y));
Leave}(IsList(y),False);
Enter{(/,(x*y)/z);
Enter{(*,x*y);
Arg(x,a*b);
Arg(y,c);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Enter{(IsMatrix,IsMatrix(x));
Arg(x,a*b);
Enter{(If,If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False));
Arg(IsList($x10)And Length($x10)>0,IsList($x10)And Length($x10)>0);
Enter{(And,IsList($x10)And Length($x10)>0);
Arg(IsList($x10),{IsList($x10),Length($x10)>0});
Enter{(IsList,IsList($x10));
Leave}(IsList($x10),False);
Leave}(IsList($x10)And Length($x10)>0,False);
Leave}(If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False),False);
Leave}(IsMatrix(x),False);
Enter{(IsMatrix,IsMatrix(x));
Arg(x,a*b);
Enter{(If,If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False));
Arg(IsList($x10)And Length($x10)>0,IsList($x10)And Length($x10)>0);
Enter{(And,IsList($x10)And Length($x10)>0);
Arg(IsList($x10),{IsList($x10),Length($x10)>0});
Enter{(IsList,IsList($x10));
Leave}(IsList($x10),False);
Leave}(IsList($x10)And Length($x10)>0,False);
Leave}(If(IsList($x10)And Length($x10)>0,[
Local(n);
n:=Length($x10);
If(Length(Select(IsVector,$x10))=n,MapSingle(Length,$x10)=Length($x10[1])+ZeroVector(n),False);
]
,False),False);
Leave}(IsMatrix(x),False);
Enter{(IsList,IsList(x));
Leave}(IsList(x),False);
Enter{(IsNonObject,IsNonObject(x));
Arg(x,a*b);
Leave}(IsNonObject(x),True);
Enter{(IsList,IsList(y));
Leave}(IsList(y),False);
Enter{(IsNumber,IsNumber(y));
Leave}(IsNumber(y),False);
Enter{(=,f= -1);
Enter{(-,-1);
Arg(1,1);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),True);
Enter{(SubtractN,SubtractN(0,x));
Leave}(SubtractN(0,x),-1);
Leave}(-1,-1);
Leave}(f= -1,False);
Enter{(=,f= -1);
Enter{(-,-1);
Arg(1,1);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),True);
Enter{(SubtractN,SubtractN(0,x));
Leave}(SubtractN(0,x),-1);
Leave}(-1,-1);
Leave}(f= -1,False);
Enter{(IsList,IsList(aLeft));
Leave}(IsList(aLeft),False);
Enter{(IsInfinity,IsInfinity(x));
Arg(x,a*b);
Leave}(IsInfinity(x),False);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Leave}(x*y,a*b*c);
Arg(x*y,a*b*c);
Arg(z,d*e);
Enter{(IsNumber,IsNumber(y));
Leave}(IsNumber(y),False);
Enter{(IsNonZeroInteger,IsNonZeroInteger(x));
Arg(x,a*b*c);
Enter{(And,IsInteger(x)And x!=0);
Arg(IsInteger(x),{IsInteger(x),x!=0});
Enter{(IsInteger,IsInteger(x));
Leave}(IsInteger(x),False);
Leave}(IsInteger(x)And x!=0,False);
Leave}(IsNonZeroInteger(x),False);
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Enter{(IsInfinity,IsInfinity(x));
Arg(x,a*b*c);
Leave}(IsInfinity(x),False);
Enter{(IsInfinity,IsInfinity(x));
Arg(x,a*b*c);
Leave}(IsInfinity(x),False);
Enter{(IsInfinity,IsInfinity(x));
Arg(x,a*b*c);
Leave}(IsInfinity(x),False);
Enter{(IsNegativeNumber,IsNegativeNumber(y));
Arg(y,d*e);
Enter{(And,IsNumber(x)And x<0);
Arg(IsNumber(x),{IsNumber(x),x<0});
Enter{(IsNumber,IsNumber(x));
Leave}(IsNumber(x),False);
Leave}(IsNumber(x)And x<0,False);
Leave}(IsNegativeNumber(y),False);
Enter{(IsList,IsList(xlist));
Leave}(IsList(xlist),False);
Enter{(IsList,IsList(y));
Leave}(IsList(y),False);
Enter{(IsList,IsList(x));
Leave}(IsList(x),False);
Leave}((x*y)/z,(a*b*c)/(d*e));
Leave}(a*b*c/(d*e),(a*b*c)/(d*e));
Leave}(Eval(aRightAssign),(a*b*c)/(d*e));
Leave}(MacroSet(aLeftAssign,Eval(aRightAssign)),True);
Enter{(Eval,Eval(aLeftAssign));
Leave}(Eval(aLeftAssign),(a*b*c)/(d*e));
Leave}([
MacroSet(aLeftAssign,Eval(aRightAssign));
Eval(aLeftAssign);
]
,(a*b*c)/(d*e));
Leave}(ee:=a*b*c/(d*e),(a*b*c)/(d*e));
mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/high_school_tests.mpw 0000644 0001750 0001750 00000064471 11316262063 026254 0 ustar giovanni giovanni
%mathpiper
Echo("pp.100. Express the following in lowest terms. The letter symbols that appear represent positive integers.");
NewLine();
equations1 := {
{"18/48","3/8"},
"85/100",
{"56/-12","-14/3"},
"-91/49",
{"(32*a^2)/(16*a)","2*a"},
"(45*x^3*y)/(-15*y^2)",
{"(a*b*c)/(c*d)","a*b/d"},
"(2*x + 2)/(x + 1)",
{"(2*a - 1)/(b - 2*a*b)","-1/b"},
"(a*b)/(b*a)",
{"(6*a + 4)/(12*a)","(3*a+2)/(6*a)"},
"(a + 1)/(a*b + b)",
{"(14 - 7*x)/(21)","(2-x)/3"},
"(3*x - x^2)/(x^2 - x)",//x is not equal to 1.
{"(a^2 + 7*a)/(a^2)","(a+7)/a"},
"(x^2 - 3*x)/(6*x - 2*x^2)",//x is not equal to 3.
{"(5*a^2 - a)/(5*a - 1)","a"},
"(10*a^2 - 2*a)/(10*a^2 + 2*a)",
};
count := 1;
ForEach(e,equations1)
[
If(IsList(e), [answer := e[2]; e := e[1];]);
Echo("#",count ,"Problem: ",e, If(IsBound(answer),ToString()[WriteString(" Answer: " );Write(answer);Clear(answer);],"") );
//Echo(PrettyForm(e));
Echo("MathPiper: ",Simplify(Eval(FromString(e:";") Read())));
me := ToString()[WriteString("ratsimp(");Write(Atom(e));WriteString(")");];
Echo("Maxima:",Maxima(me));
count := count + 1;
];
count - 1;
%/mathpiper
%output,preserve="false"
Result: 18
Side Effects:
pp.100. Express the following in lowest terms. The letter symbols that appear represent positive integers.
#1 Problem: 18/48 Answer: "3/8"
MathPiper: 3/8
Maxima:(%o543) 3/8
#2 Problem: 85/100
MathPiper: 17/20
Maxima:(%o544) 17/20
#3 Problem: 56/-12 Answer: "-14/3"
MathPiper: (-14)/3
Maxima:(%o545) -14/3
#4 Problem: -91/49
MathPiper: (-13)/7
Maxima:(%o546) -13/7
#5 Problem: (32*a^2)/(16*a) Answer: "2*a"
MathPiper: 2*a
Maxima:(%o547) 2*a
#6 Problem: (45*x^3*y)/(-15*y^2)
MathPiper: (-3*x^3)/y
Maxima:(%o548) -3*x^3/y
#7 Problem: (a*b*c)/(c*d) Answer: "a*b/d"
MathPiper: (a*b)/d
Maxima:(%o549) a*b/d
#8 Problem: (2*x + 2)/(x + 1)
MathPiper: 2
Maxima:(%o550) 2
#9 Problem: (2*a - 1)/(b - 2*a*b) Answer: "-1/b"
MathPiper: (2*a-1)/(b*(1-2*a))
Maxima:(%o551) -1/b
#10 Problem: (a*b)/(b*a)
MathPiper: 1
Maxima:(%o552) 1
#11 Problem: (6*a + 4)/(12*a) Answer: "(3*a+2)/(6*a)"
MathPiper: (3*a+2)/(6*a)
Maxima:(%o553) (3*a+2)/(6*a)
#12 Problem: (a + 1)/(a*b + b)
MathPiper: 1/b
Maxima:(%o554) 1/b
#13 Problem: (14 - 7*x)/(21) Answer: "(2-x)/3"
MathPiper: (2-x)/3
Maxima:(%o555) -(x-2)/3
#14 Problem: (3*x - x^2)/(x^2 - x)
MathPiper: (3-x)/(x-1)
Maxima:(%o556) -(x-3)/(x-1)
#15 Problem: (a^2 + 7*a)/(a^2) Answer: "(a+7)/a"
MathPiper: (a+7)/a
Maxima:(%o557) (a+7)/a
#16 Problem: (x^2 - 3*x)/(6*x - 2*x^2)
MathPiper: (x-3)/(2*(3-x))
Maxima:(%o558) -1/2
#17 Problem: (5*a^2 - a)/(5*a - 1) Answer: "a"
MathPiper: a
Maxima:(%o559) a
#18 Problem: (10*a^2 - 2*a)/(10*a^2 + 2*a)
MathPiper: (5*a-1)/(5*a+1)
Maxima:(%o560) (5*a-1)/(5*a+1)
. %/output
%mathpiper
Echo("pp.105. Perform the following additions. Express each result in lowest terms. The letter symbols that appear represent positive integers.");
NewLine();
equations1 := {
{"2/3 + 5/3","7/3"},
"1/9 + 4/9 + 5/9",
{"2/7 + 3/7 + 5/7","10/7"},
"a/y + b/y + c/y",
{"a/x + 3*a/x + 4*a/x","8*a/x"},
"x/(x+y) + x/(x + y)",
{"a/(a + 1) + 1/(a + 1)","1"},
"2/3 + 4/5",
{"3 + 7/6 + 2/3","29/6"},
"y/3 + 2*y/9",
{"3*y + y/5","16*y/5"},
"x/2 + x/3 + x/4",
{"4/a + 3/(2*a)","11/(2*a)"},
"1/a + 1/b + 1/c",
{"b*c + 1/c","(b*c^2+1)/c"},
"x/(x+y) + 7",
{"1/(2*m) + (a + 3)/(4*m)","(a+5)/(4*m)"},
"9/x^2 + 4/x",
{"a/(x + y) + b/(x + y)","(a+b)/(x+y)"},
"1/a + 3/(a*b) + 2/b",
{"2*x/a + 3*y/b","(2*b*x+3*a*y)/(a*b)"},
"2/a + 7/(a*b*c) + 6/c",
};
count := 1;
ForEach(e,equations1)
[
If(IsList(e), [answer := e[2]; e := e[1];]);
Echo("#",count ,"Problem: ",e, If(IsBound(answer),ToString()[WriteString(" Answer: " );Write(answer);Clear(answer);],"") );
//Echo(PrettyForm(e));
Echo("MathPiper: ",Simplify(Eval(FromString(e:";") Read())));
me := ToString()[WriteString("ratsimp(");Write(Atom(e));WriteString(")");];
Echo("Maxima:",Maxima(me));
count := count + 1;
];
count - 1;
%/mathpiper
%output,preserve="false"
Result: 22
Side Effects:
pp.105. Perform the following additions. Express each result in lowest terms. The letter symbols that appear represent positive integers.
#1 Problem: 2/3 + 5/3 Answer: "7/3"
MathPiper: 7/3
Maxima:(%o385) 7/3
#2 Problem: 1/9 + 4/9 + 5/9
MathPiper: 10/9
Maxima:(%o386) 10/9
#3 Problem: 2/7 + 3/7 + 5/7 Answer: "10/7"
MathPiper: 10/7
Maxima:(%o387) 10/7
#4 Problem: a/y + b/y + c/y
MathPiper: (a+b+c)/y
Maxima:(%o388) (c+b+a)/y
#5 Problem: a/x + 3*a/x + 4*a/x Answer: "8*a/x"
MathPiper: (8*a)/x
Maxima:(%o389) 8*a/x
#6 Problem: x/(x+y) + x/(x + y)
MathPiper: (2*x)/(x+y)
Maxima:(%o390) 2*x/(y+x)
#7 Problem: a/(a + 1) + 1/(a + 1) Answer: "1"
MathPiper: 1
Maxima:(%o391) 1
#8 Problem: 2/3 + 4/5
MathPiper: 22/15
Maxima:(%o392) 22/15
#9 Problem: 3 + 7/6 + 2/3 Answer: "29/6"
MathPiper: 29/6
Maxima:(%o393) 29/6
#10 Problem: y/3 + 2*y/9
MathPiper: (5*y)/9
Maxima:(%o394) 5*y/9
#11 Problem: 3*y + y/5 Answer: "16*y/5"
MathPiper: (16*y)/5
Maxima:(%o395) 16*y/5
#12 Problem: x/2 + x/3 + x/4
MathPiper: (13*x)/12
Maxima:(%o396) 13*x/12
#13 Problem: 4/a + 3/(2*a) Answer: "11/(2*a)"
MathPiper: (11*a)/(2*a^2)
Maxima:(%o397) 11/(2*a)
#14 Problem: 1/a + 1/b + 1/c
MathPiper: (a*b+a*c+b*c)/(a*b*c)
Maxima:(%o398) ((b+a)*c+a*b)/(a*b*c)
#15 Problem: b*c + 1/c Answer: "(b*c^2+1)/c"
MathPiper: (b*c^2+1)/c
Maxima:(%o399) (b*c^2+1)/c
#16 Problem: x/(x+y) + 7
MathPiper: (8*x+7*y)/(x+y)
Maxima:(%o400) (7*y+8*x)/(y+x)
#17 Problem: 1/(2*m) + (a + 3)/(4*m) Answer: "(a+5)/(4*m)"
MathPiper: (m*a+5*m)/(4*m^2)
Maxima:(%o401) (a+5)/(4*m)
#18 Problem: 9/x^2 + 4/x
MathPiper: (4*x^2+9*x)/x^3
Maxima:(%o402) (4*x+9)/x^2
#19 Problem: a/(x + y) + b/(x + y) Answer: "(a+b)/(x+y)"
MathPiper: (a+b)/(x+y)
Maxima:(%o403) (b+a)/(y+x)
#20 Problem: 1/a + 3/(a*b) + 2/b
MathPiper: (2*a^2*b+a*b^2+3*a*b)/(a^2*b^2)
Maxima:(%o404) (b+2*a+3)/(a*b)
#21 Problem: 2*x/a + 3*y/b Answer: "(2*b*x+3*a*y)/(a*b)"
MathPiper: (2*x*b+3*a*y)/(a*b)
Maxima:(%o405) (3*a*y+2*b*x)/(a*b)
#22 Problem: 2/a + 7/(a*b*c) + 6/c
MathPiper: (6*a^2*b*c+2*a*b*c^2+7*a*c)/(a^2*b*c^2)
Maxima:(%o406) (2*b*c+6*a*b+7)/(a*b*c)
. %/output
%mathpiper
Echo("pp.112. Find the following products. Express each result in lowest terms. The letter symbols represent positive integers.");
NewLine();
equations1 := {
{"3*(4/9)","4/3"},
{"5*(7/11)",""},
{"2/3*6","4"},
{"5/8*4/15",""},
{"91/119*34/39","2/3"},
{"a/b*1/a",""},
{"(3*a)/(2*b)*(5*a^2)/(9*b)","(5*a^3)/(6*b^2)"},
{"(a/b)*(a/b)",""},
{"(1/x^2)*(2/3)*(x/4)","1/(6*x)"},
{"(m^2/n)*(n/m^2)",""},
{"((a^2+a*x)/3)*(6/(a+x))","2*a"},
{"((2*x+12)/(x+5))*((3*x+15)/(x+6))",""},
{"((x + 1)/x)*(x^2/(x^2+x))","1"},
{"((4*x*y)/(x+3))*((3*x^2+9*x)/(16*y^2))",""},
{"(2/6)*(1/2)*(3/4)","1/8"},
{"(a/2)*(4/a^2)*(3/5)",""},
{"((3*x+12)/x)*(2*x^2/(x+4))","6*x"},
{"(y^3/(15*x+6))*((5*x+2)/y)",""},
{"((2*a+b)/(7*a*b))*3*b^2/(4*a+2*b)","(3*b)/(14*a)"},
{"(5/(a^3+a^2*y))*((a^2+a*y)/25)",""},
{"((2*a^2+3*a^2)/b)*(b^3/a^2)","5*b^2"},
{"((4*y+4)/7)*(14/(2*y^2+2*y))",""},
{"skip",""},
{"skip",""},
{"(4*a+4)/4","a+1"},
{"(2*x+6)/2",""},
{"(a^2+a)/a","a+1"},
{"(a*x+a*y)/a",""},
};
count := 1;
ForEach(e,equations1)
[
If(IsList(e), [answer := e[2]; e := e[1];]);
Echo("#",count ,"Problem: ",e, If(IsBound(answer),ToString()[WriteString(" Answer: " );Write(answer);Clear(answer);],"") );
//Echo(PrettyForm(e));
Echo("MathPiper: ",Simplify(Eval(FromString(e:";") Read())));
me := ToString()[WriteString("ratsimp(");Write(Atom(e));WriteString(")");];
Echo("Maxima:",Maxima(me));
count := count + 1;
];
count - 1;
%/mathpiper
%output,preserve="false"
Result: 28
Side Effects:
pp.112. Find the following products. Express each result in lowest terms. The letter symbols represent positive integers.
#1 Problem: 3*(4/9) Answer: "4/3"
MathPiper: 4/3
Maxima:(%o429) 4/3
#2 Problem: 5*(7/11) Answer: ""
MathPiper: 35/11
Maxima:(%o430) 35/11
#3 Problem: 2/3*6 Answer: "4"
MathPiper: 4
Maxima:(%o431) 4
#4 Problem: 5/8*4/15 Answer: ""
MathPiper: 1/6
Maxima:(%o432) 1/6
#5 Problem: 91/119*34/39 Answer: "2/3"
MathPiper: 2/3
Maxima:(%o433) 2/3
#6 Problem: a/b*1/a Answer: ""
MathPiper: 1/b
Maxima:(%o434) 1/b
#7 Problem: (3*a)/(2*b)*(5*a^2)/(9*b) Answer: "(5*a^3)/(6*b^2)"
MathPiper: (5*a^3)/(6*b^2)
Maxima:(%o435) 5*a^3/(6*b^2)
#8 Problem: (a/b)*(a/b) Answer: ""
MathPiper: a^2/b^2
Maxima:(%o436) a^2/b^2
#9 Problem: (1/x^2)*(2/3)*(x/4) Answer: "1/(6*x)"
MathPiper: 1/(6*x)
Maxima:(%o437) 1/(6*x)
#10 Problem: (m^2/n)*(n/m^2) Answer: ""
MathPiper: 1
Maxima:(%o438) 1
#11 Problem: ((a^2+a*x)/3)*(6/(a+x)) Answer: "2*a"
MathPiper: 2*a
Maxima:(%o439) 2*a
#12 Problem: ((2*x+12)/(x+5))*((3*x+15)/(x+6)) Answer: ""
MathPiper: 6
Maxima:(%o440) 6
#13 Problem: ((x + 1)/x)*(x^2/(x^2+x)) Answer: "1"
MathPiper: 1
Maxima:(%o441) 1
#14 Problem: ((4*x*y)/(x+3))*((3*x^2+9*x)/(16*y^2)) Answer: ""
MathPiper: (3*x^2)/(4*y)
Maxima:(%o442) 3*x^2/(4*y)
#15 Problem: (2/6)*(1/2)*(3/4) Answer: "1/8"
MathPiper: 1/8
Maxima:(%o443) 1/8
#16 Problem: (a/2)*(4/a^2)*(3/5) Answer: ""
MathPiper: 6/(5*a)
Maxima:(%o444) 6/(5*a)
#17 Problem: ((3*x+12)/x)*(2*x^2/(x+4)) Answer: "6*x"
MathPiper: 6*x
Maxima:(%o445) 6*x
#18 Problem: (y^3/(15*x+6))*((5*x+2)/y) Answer: ""
MathPiper: y^2/3
Maxima:(%o446) y^2/3
#19 Problem: ((2*a+b)/(7*a*b))*3*b^2/(4*a+2*b) Answer: "(3*b)/(14*a)"
MathPiper: (3*b)/(14*a)
Maxima:(%o447) 3*b/(14*a)
#20 Problem: (5/(a^3+a^2*y))*((a^2+a*y)/25) Answer: ""
MathPiper: 1/(5*a)
Maxima:(%o448) 1/(5*a)
#21 Problem: ((2*a^2+3*a^2)/b)*(b^3/a^2) Answer: "5*b^2"
MathPiper: 5*b^2
Maxima:(%o449) 5*b^2
#22 Problem: ((4*y+4)/7)*(14/(2*y^2+2*y)) Answer: ""
MathPiper: 4/y
Maxima:(%o450) 4/y
#23 Problem: skip Answer: ""
MathPiper: skip
Maxima:(%o451) skip
#24 Problem: skip Answer: ""
MathPiper: skip
Maxima:(%o452) skip
#25 Problem: (4*a+4)/4 Answer: "a+1"
MathPiper: a+1
Maxima:(%o453) a+1
#26 Problem: (2*x+6)/2 Answer: ""
MathPiper: x+3
Maxima:(%o454) x+3
#27 Problem: (a^2+a)/a Answer: "a+1"
MathPiper: a+1
Maxima:(%o455) a+1
#28 Problem: (a*x+a*y)/a Answer: ""
MathPiper: x+y
Maxima:(%o456) y+x
. %/output
%mathpiper
Echo("pp.130. Problems 1-24: Perform the following divisions. Express results in lowest terms. The letter symbols represent positive integers.");
NewLine();
equations1 := {
{"(7/8)/(2/3)","21/16"},
{"4/(3/5)",""},
{"(3/5)/4","3/20"},
{"(a/b)/a",""},
{"a/(a/b)","b"},
{"((x+y)/x)/x",""},
{"x/((x+y)/x)","x^2/(x+y)"},
{"(x/y)/(y/x)",""},
{"(x/(x+y))/(x/y)","y/(x+y)"},
{"a/(a*b)",""},
{"(a*b)/a","b"},
{"(x/2)/((5*x^2)/8)",""},
{"((a+b)/a)/(b/a)","(a+b)/b"},
{"((a+b)/a)/(a/b)",""},
{"((2*a)/(3*b))/((4*a)/27)","9/(2*b)"},
{"(a/(a+b))/((3*a)/(a*c+b*c))",""},
{"((5*x+10)/x^2)/(5/x)","(x+2)/x"},
{"((x*y+x)/(y))/((a*y+a)/(y^2))",""},
{"(y^2/(15*x+6))/(y/(5*x+2))","y/3"},
{"((3*x+12)/x)/((x+4)/(2*x^2))",""},
{"(5/(a^3+a^2*y))/(25/(a^2+a*y))","1/(5*a)"},
{"((2*a+b)/(7*a*b))/((4*a+2*b)/(3*b^2))",""},
{"((4*y+4)/7)/((2*y^2+2*y)/14)","4/y"},
{"((2*a^2+3*a^2)/b)/(a^2/b^3)",""},
{"skip",""},
{"skip",""},//26.
{"(1/2+1/3)/(1/4+1/5)",""},
{"(1/x+1/y)/(2/x+2/y)",""},
{"(8+3/4)*(2/3)",""},
{"(4+1/3)*(6+1/2)",""},
{"(2+1/2)/(5+1/3)",""},//31.
{"(6+1/2)+(14+1/3)",""},
{"(4+2/7)/(3+1/3)",""},
{"(4+2/7)*(3+1/3)",""},
{"(1/x+3)/(4+2/x)",""},
{"((x+y)/4)/((2*x+2*y)/8)",""},//36.
{"((1+x)/3)/((3+3*x)/7)",""},
{"(3-1/x^2)/(2+1/x)",""},
{"(a/2+b/3)/((3*a+2*b)/5)",""},
{"(2/a+3/b)/(5/a+4/b)",""},//40
};
count := 1;
ForEach(e,equations1)
[
If(IsList(e), [answer := e[2]; e := e[1];]);
Echo("#",count ,"Problem: ",e, If(IsBound(answer),ToString()[WriteString(" Answer: " );Write(answer);Clear(answer);],"") );
//Echo(PrettyForm(e));
Echo("MathPiper: ",Simplify(Eval(FromString(e:";") Read())));
me := ToString()[WriteString("ratsimp(");Write(Atom(e));WriteString(")");];
Echo("Maxima:",Maxima(me));
count := count + 1;
];
count - 1;
%/mathpiper
%output,preserve="false"
Result: 40
Side Effects:
pp.130. Problems 1-24: Perform the following divisions. Express results in lowest terms. The letter symbols represent positive integers.
#1 Problem: (7/8)/(2/3) Answer: "21/16"
MathPiper: 21/16
Maxima:(%o471) 21/16
#2 Problem: 4/(3/5) Answer: ""
MathPiper: 20/3
Maxima:(%o472) 20/3
#3 Problem: (3/5)/4 Answer: "3/20"
MathPiper: 3/20
Maxima:(%o473) 3/20
#4 Problem: (a/b)/a Answer: ""
MathPiper: 1/b
Maxima:(%o474) 1/b
#5 Problem: a/(a/b) Answer: "b"
MathPiper: b
Maxima:(%o475) b
#6 Problem: ((x+y)/x)/x Answer: ""
MathPiper: (x+y)/x^2
Maxima:(%o476) (y+x)/x^2
#7 Problem: x/((x+y)/x) Answer: "x^2/(x+y)"
MathPiper: x^2/(x+y)
Maxima:(%o477) x^2/(y+x)
#8 Problem: (x/y)/(y/x) Answer: ""
MathPiper: x^2/y^2
Maxima:(%o478) x^2/y^2
#9 Problem: (x/(x+y))/(x/y) Answer: "y/(x+y)"
MathPiper: y/(x+y)
Maxima:(%o479) y/(y+x)
#10 Problem: a/(a*b) Answer: ""
MathPiper: 1/b
Maxima:(%o480) 1/b
#11 Problem: (a*b)/a Answer: "b"
MathPiper: b
Maxima:(%o481) b
#12 Problem: (x/2)/((5*x^2)/8) Answer: ""
MathPiper: 4/(5*x)
Maxima:(%o482) 4/(5*x)
#13 Problem: ((a+b)/a)/(b/a) Answer: "(a+b)/b"
MathPiper: (a+b)/b
Maxima:(%o483) (b+a)/b
#14 Problem: ((a+b)/a)/(a/b) Answer: ""
MathPiper: ((a+b)*b)/a^2
Maxima:(%o484) (b^2+a*b)/a^2
#15 Problem: ((2*a)/(3*b))/((4*a)/27) Answer: "9/(2*b)"
MathPiper: 9/(2*b)
Maxima:(%o485) 9/(2*b)
#16 Problem: (a/(a+b))/((3*a)/(a*c+b*c)) Answer: ""
MathPiper: c/3
Maxima:(%o486) c/3
#17 Problem: ((5*x+10)/x^2)/(5/x) Answer: "(x+2)/x"
MathPiper: (x+2)/x
Maxima:(%o487) (x+2)/x
#18 Problem: ((x*y+x)/(y))/((a*y+a)/(y^2)) Answer: ""
MathPiper: (x*y)/a
Maxima:(%o488) x*y/a
#19 Problem: (y^2/(15*x+6))/(y/(5*x+2)) Answer: "y/3"
MathPiper: y/3
Maxima:(%o489) y/3
#20 Problem: ((3*x+12)/x)/((x+4)/(2*x^2)) Answer: ""
MathPiper: 6*x
Maxima:(%o490) 6*x
#21 Problem: (5/(a^3+a^2*y))/(25/(a^2+a*y)) Answer: "1/(5*a)"
MathPiper: 1/(5*a)
Maxima:(%o491) 1/(5*a)
#22 Problem: ((2*a+b)/(7*a*b))/((4*a+2*b)/(3*b^2)) Answer: ""
MathPiper: (3*b)/(14*a)
Maxima:(%o492) 3*b/(14*a)
#23 Problem: ((4*y+4)/7)/((2*y^2+2*y)/14) Answer: "4/y"
MathPiper: 4/y
Maxima:(%o493) 4/y
#24 Problem: ((2*a^2+3*a^2)/b)/(a^2/b^3) Answer: ""
MathPiper: 5*b^2
Maxima:(%o494) 5*b^2
#25 Problem: skip Answer: ""
MathPiper: skip
Maxima:(%o495) skip
#26 Problem: skip Answer: ""
MathPiper: skip
Maxima:(%o496) skip
#27 Problem: (1/2+1/3)/(1/4+1/5) Answer: ""
MathPiper: 50/27
Maxima:(%o497) 50/27
#28 Problem: (1/x+1/y)/(2/x+2/y) Answer: ""
MathPiper: 1/2
Maxima:(%o498) 1/2
#29 Problem: (8+3/4)*(2/3) Answer: ""
MathPiper: 35/6
Maxima:(%o499) 35/6
#30 Problem: (4+1/3)*(6+1/2) Answer: ""
MathPiper: 169/6
Maxima:(%o500) 169/6
#31 Problem: (2+1/2)/(5+1/3) Answer: ""
MathPiper: 15/32
Maxima:(%o501) 15/32
#32 Problem: (6+1/2)+(14+1/3) Answer: ""
MathPiper: 125/6
Maxima:(%o502) 125/6
#33 Problem: (4+2/7)/(3+1/3) Answer: ""
MathPiper: 9/7
Maxima:(%o503) 9/7
#34 Problem: (4+2/7)*(3+1/3) Answer: ""
MathPiper: 100/7
Maxima:(%o504) 100/7
#35 Problem: (1/x+3)/(4+2/x) Answer: ""
MathPiper: (3*x+1)/(2*(2*x+1))
Maxima:(%o505) (3*x+1)/(4*x+2)
#36 Problem: ((x+y)/4)/((2*x+2*y)/8) Answer: ""
MathPiper: 1
Maxima:(%o506) 1
#37 Problem: ((1+x)/3)/((3+3*x)/7) Answer: ""
MathPiper: 7/9
Maxima:(%o507) 7/9
#38 Problem: (3-1/x^2)/(2+1/x) Answer: ""
MathPiper: (3*x^2-1)/(x*(2*x+1))
Maxima:(%o508) (3*x^2-1)/(2*x^2+x)
#39 Problem: (a/2+b/3)/((3*a+2*b)/5) Answer: ""
MathPiper: 5/6
Maxima:(%o509) 5/6
#40 Problem: (2/a+3/b)/(5/a+4/b) Answer: ""
MathPiper: (3*a+2*b)/(4*a+5*b)
Maxima:(%o510) (2*b+3*a)/(5*b+4*a)
. %/output
%mathpiper
Echo("pp.130. Problems 27-40: Perform the following calculations. Express results in lowest terms. In exercises in which letter symbols appear, tell what values of the letter symbols must be excluded. Problems 41-63: Combine the following expressions into a single fraction in lowest terms. Indicate the values of the letter symbols which must be excluded.");
NewLine();
equations1 := {
{"((1/2)+(1/3))/((1/4)+(1/5))",""},
{"((1/x)+(1/y))/((2/x)+(2/y))",""},
{"(8+(2/3))*(2/3)",""},
{"(4+(1/3))+(6+(1/2))",""},
{"(2+(1/2))/(5+(1/3))",""},
{"(6+(1/2))+(14+(1/3))",""},//32.
{"(4+(2/7))/(3+(1/3))",""},
{"(4+(2/7))*(3+(1/3))",""},
{"((1/x)+3)/(4+(2/x))",""},
{"((x+y)/4)/((2*x+2*y)/8)",""},//36.
{"((1+x)/3)/((3+3*x)/7)",""},
{"(3-(1/x^2))/(2+(1/x))",""},
{"((a/2)+(b/3))/((3*a+2*b)/5)",""},
{"((2/a)+(3/b))/((5/a)+(4/b))",""},
};
count := 27;
ForEach(e,equations1)
[
If(IsList(e), [answer := e[2]; e := e[1];]);
Echo("#",count ,"Problem: ",e, If(IsBound(answer),ToString()[WriteString(" Answer: " );Write(answer);Clear(answer);],"") );
//Echo(PrettyForm(e));
Echo("MathPiper: ",Simplify(Eval(FromString(e:";") Read())));
me := ToString()[WriteString("ratsimp(");Write(Atom(e));WriteString(")");];
Echo("Maxima:",Maxima(me));
count := count + 1;
];
count - 1;
%/mathpiper
%output,preserve="false"
Result: 40
Side Effects:
pp.130. Problems 27-40: Perform the following calculations. Express results in lowest terms. In exercises in which letter symbols appear, tell what values of the letter symbols must be excluded. Problems 41-63: Combine the following expressions into a single fraction in lowest terms. Indicate the values of the letter symbols which must be excluded.
#27 Problem: ((1/2)+(1/3))/((1/4)+(1/5)) Answer: ""
MathPiper: 50/27
Maxima:(%o511) 50/27
#28 Problem: ((1/x)+(1/y))/((2/x)+(2/y)) Answer: ""
MathPiper: 1/2
Maxima:(%o512) 1/2
#29 Problem: (8+(2/3))*(2/3) Answer: ""
MathPiper: 52/9
Maxima:(%o513) 52/9
#30 Problem: (4+(1/3))+(6+(1/2)) Answer: ""
MathPiper: 65/6
Maxima:(%o514) 65/6
#31 Problem: (2+(1/2))/(5+(1/3)) Answer: ""
MathPiper: 15/32
Maxima:(%o515) 15/32
#32 Problem: (6+(1/2))+(14+(1/3)) Answer: ""
MathPiper: 125/6
Maxima:(%o516) 125/6
#33 Problem: (4+(2/7))/(3+(1/3)) Answer: ""
MathPiper: 9/7
Maxima:(%o517) 9/7
#34 Problem: (4+(2/7))*(3+(1/3)) Answer: ""
MathPiper: 100/7
Maxima:(%o518) 100/7
#35 Problem: ((1/x)+3)/(4+(2/x)) Answer: ""
MathPiper: (3*x+1)/(2*(2*x+1))
Maxima:(%o519) (3*x+1)/(4*x+2)
#36 Problem: ((x+y)/4)/((2*x+2*y)/8) Answer: ""
MathPiper: 1
Maxima:(%o520) 1
#37 Problem: ((1+x)/3)/((3+3*x)/7) Answer: ""
MathPiper: 7/9
Maxima:(%o521) 7/9
#38 Problem: (3-(1/x^2))/(2+(1/x)) Answer: ""
MathPiper: (3*x^2-1)/(x*(2*x+1))
Maxima:(%o522) (3*x^2-1)/(2*x^2+x)
#39 Problem: ((a/2)+(b/3))/((3*a+2*b)/5) Answer: ""
MathPiper: 5/6
Maxima:(%o523) 5/6
#40 Problem: ((2/a)+(3/b))/((5/a)+(4/b)) Answer: ""
MathPiper: (3*a+2*b)/(4*a+5*b)
Maxima:(%o524) (2*b+3*a)/(5*b+4*a)
. %/output
%mathpiper
Echo("pp.130. Problems 41-63: Combine the following expressions into a single fraction in lowest terms. Indicate the values of the letter symbols which must be excluded.");
NewLine();
equations1 := {
{"(4/(2*x))-((3*x)/5)+(6/x)",""},
{"(8/(x+3))+5+(3/7)",""},
{"(2/(y+2))-(3/(y+2))",""},
{"(3/(2*x-1))+4-(x/(1-2*x))",""},
{"((6*a)/(2*a-3))-(9/(2*a-3))",""},
{"((a*x)/(x+a))*((x+a)/(x*a))",""},
{"((m-4)/12)*(18/(m^2-4*m))",""},//47
{"((x*y-x)/y)/((a*y-a)/(y^2))",""},
{"((2*a-b)/(a+b))-((2*a-2*b)/(a+b))",""},
{"((2*a)/(a-b))+(a/(b-a))",""},
{"(b/(3*a))-((a-1)/(5*b))",""},
{"((a*b+a*c)/(b*m+b*n))/((b+c)/(m+n))",""},//52.
{"((2*x+8)/(3*x-9))*(3/(x+4))",""},
{"((x^2+y^2)/(m+n))-((x^2-y^2)/(m+n))",""},
{"(1/2)-((a-1)/a)+((a-2)/a^2)",""},
{"((3/(x-4)))-(4/(x-4))",""},
{"(7/(a-b))-(5/(b-a))",""},
{"((2*x))",""},
};
count := 41;
ForEach(e,equations1)
[
If(IsList(e), [answer := e[2]; e := e[1];]);
Echo("#",count ,"Problem: ",e, If(IsBound(answer),ToString()[WriteString(" Answer: " );Write(answer);Clear(answer);],"") );
//Echo(PrettyForm(e));
Echo("MathPiper: ",Simplify(Eval(FromString(e:";") Read())));
me := ToString()[WriteString("ratsimp(");Write(Atom(e));WriteString(")");];
Echo("Maxima:",Maxima(me));
count := count + 1;
];
count - 1;
%/mathpiper
%output,preserve="false"
Result: 58
Side Effects:
pp.130. Problems 41-63: Combine the following expressions into a single fraction in lowest terms. Indicate the values of the letter symbols which must be excluded.
#41 Problem: (4/(2*x))-((3*x)/5)+(6/x) Answer: ""
MathPiper: (40*x-3*x^3)/(5*x^2)
Maxima:(%o525) -(3*x^2-40)/(5*x)
#42 Problem: (8/(x+3))+5+(3/7) Answer: ""
MathPiper: (2*(19*x+85))/(7*(x+3))
Maxima:(%o526) (38*x+170)/(7*x+21)
#43 Problem: (2/(y+2))-(3/(y+2)) Answer: ""
MathPiper: (-(y+2))/(y^2+4*y+4)
Maxima:(%o527) -1/(y+2)
#44 Problem: (3/(2*x-1))+4-(x/(1-2*x)) Answer: ""
MathPiper: (11*x-18*x^2-1)/(4*x-4*x^2-1)
Maxima:(%o528) (9*x-1)/(2*x-1)
#45 Problem: ((6*a)/(2*a-3))-(9/(2*a-3)) Answer: ""
MathPiper: 3
Maxima:(%o529) 3
#46 Problem: ((a*x)/(x+a))*((x+a)/(x*a)) Answer: ""
MathPiper: 1
Maxima:(%o530) 1
#47 Problem: ((m-4)/12)*(18/(m^2-4*m)) Answer: ""
MathPiper: 3/(2*m)
Maxima:(%o531) 3/(2*m)
#48 Problem: ((x*y-x)/y)/((a*y-a)/(y^2)) Answer: ""
MathPiper: (x*y)/a
Maxima:(%o532) x*y/a
#49 Problem: ((2*a-b)/(a+b))-((2*a-2*b)/(a+b)) Answer: ""
MathPiper: (a*b+b^2)/(a^2+2*a*b+b^2)
Maxima:(%o533) b/(b+a)
#50 Problem: ((2*a)/(a-b))+(a/(b-a)) Answer: ""
MathPiper: (a*b-a^2)/(2*a*b-a^2-b^2)
Maxima:(%o534) -a/(b-a)
#51 Problem: (b/(3*a))-((a-1)/(5*b)) Answer: ""
MathPiper: (5*b^2+3*a-3*a^2)/(15*b*a)
Maxima:(%o535) (5*b^2-3*a^2+3*a)/(15*a*b)
#52 Problem: ((a*b+a*c)/(b*m+b*n))/((b+c)/(m+n)) Answer: ""
MathPiper: a/b
Maxima:(%o536) a/b
#53 Problem: ((2*x+8)/(3*x-9))*(3/(x+4)) Answer: ""
MathPiper: (2*(x+4))/(x^2+x-12)
Maxima:(%o537) 2/(x-3)
#54 Problem: ((x^2+y^2)/(m+n))-((x^2-y^2)/(m+n)) Answer: ""
MathPiper: (2*y^2*m+2*y^2*n)/(m^2+2*m*n+n^2)
Maxima:(%o538) 2*y^2/(n+m)
#55 Problem: (1/2)-((a-1)/a)+((a-2)/a^2) Answer: ""
MathPiper: (4*a^2-a^3-4*a)/(2*a^3)
Maxima:(%o539) -(a^2-4*a+4)/(2*a^2)
#56 Problem: ((3/(x-4)))-(4/(x-4)) Answer: ""
MathPiper: (4-x)/(x^2-8*x+16)
Maxima:(%o540) -1/(x-4)
#57 Problem: (7/(a-b))-(5/(b-a)) Answer: ""
MathPiper: (12*(b-a))/(2*a*b-a^2-b^2)
Maxima:(%o541) -12/(b-a)
#58 Problem: ((2*x)) Answer: ""
MathPiper: 2*x
Maxima:(%o542) 2*x
. %/output
%mathpiper
//Manipulating symbolic equations.
z := a*b==c;
z+5;
z-5;
z*2;
z/6;
z^2;
Sqrt(z);
//Implement symbolic arithmetic so that m := 144 == 20 * a + b; n := 136 == 10 * a + b;c := m-n; works.
%/mathpiper
mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/options_test.mpw 0000644 0001750 0001750 00000002642 11343407116 025266 0 ustar giovanni giovanni %mathpiper
Retract("tstSolve",*);
RulebaseListed("tstSolve",{expression, variable, optionsList});
//Handle no option call.
5 # tstSolve(_expression, _variable) <-- tstSolve(expression, variable, {});
//Main routine. It will automatically accept 2 or more option calls because the
//options come in a list.
10 # tstSolve(_expression, _variable, optionsList_IsList) <--
[
Local(options);
Echo(expression, variable, optionsList);
options := OptionsToAssociativeList(optionsList);
Echo("All submitted options: ", options);
Echo("The roots option is set to ", options["roots"]);
];
//Handle a single option call because the option does not come in a list for some reason.
20 # tstSolve(_expression, _variable, _singleOption) <-- tstSolve(expression, variable, {singleOption});
%/mathpiper
%output,preserve="false"
Result: True
. %/output
//No option call.
In> tstSolve(x^2+x,x)
Result: {}
Side Effects:
x^2+x x {}
All submitted options: {}
The roots option is set to Empty
//One option call.
In> TestSolve(x^2+x,x,roots->R)
Result: TestSolve(x^2+x,x,roots->R)
//Multiple option call.
In> tstSolve(x^2+x,x,roots->R, option2 -> 15, option3 -> test)
Result: {{"option3","test"},{"option2","15"},{"roots","R"}}
Side Effects:
x^2+x x {roots->R,option2->15,option3->test}
All submitted options: {{"option3","test"},{"option2","15"},{"roots","R"}}
The roots option is set to R
mathpiper-0.81f+svn4469+dfsg3/tests/manual_tests/local_pattern_matching.mpw 0000644 0001750 0001750 00000252562 11417150721 027244 0 ustar giovanni giovanni %mathpiper
E := A(x,y) + B(x,y,z);
F := Deriv(z) E;
Echo("F: ",F);
G := ( F /: { (Deriv(_var)(_w))_(IsFreeOf(var,w)) <- 0 } );
//G := ( (Deriv(z)A(x,y)) /: {(Deriv(_var)(_w))_(IsFreeOf(var,w)) <- Echo("KALI ",,,var,,,w)} );
//G := ( (Deriv(z)A(x,y)) /: {(Deriv(_var)(_w)) <- Echo("KALI ",,,var,,,w)} );
// (Deriv(_var)(_x / _y))_(IsFreeOf(var,y)) <-- (Deriv(var) x) / y;
//WriteString("E = "); Echo(E);
//WriteString("F = "); Echo(F);
WriteString("G = "); Echo(G);
/*1 # (Deriv(_var)(_w))_(IsFreeOf(var,w)) <-- 0;
G := Eval(F) ;
WriteString("G = "); Echo(G);NewLine();
*/
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
F: (Deriv(z)A(x,y))+(Deriv(z)B(x,y,z))
G = 0+(Deriv(z)B(x,y,z))
. %/output
F: (Deriv(z)A(x,y))+(Deriv(z)B(x,y,z))
G = (Deriv(z)A(x,y))+(Deriv(z)B(x,y,z))
F: (Deriv(z)A(x,y))+(Deriv(z)B(x,y,z))
G = 0+(Deriv(z)B(x,y,z))
G = Deriv(z)B(x,y,z)
%mathpiper
(b + c) * (d + e) /: {(x_IsAtom + _y) <- Echo(x,,,y)};
%/mathpiper
%mathpiper,output="trace"
//(b + c) * (d + e) /: {(x_IsAtom + _y) <- Echo(x,,,y)};
Retract("LocProcessSingle",*);
40 # LocProcessSingle(pat_IsFunction <- _exp) <--
[
Local(justPattern, postPredicate);
If(Type(pat) = "_",
[
justPattern := pat[1];
postPredicate := pat[2];
],
[
justPattern := pat;
postPredicate := True;
]
);
{ {justPattern[0],PatternCreate(justPattern,postPredicate)},exp };
];
//TraceExcept("MacroLocal,ApplyPure,Apply,MapSingle,+,ForEach,*,++,>=,<=,:=,IsUniVar,IsNumber,IsNegativeNumber,For,IsInfinity,IsMatrix,IsNonObject,SubtractN,-,MathSign,IsGeneric,Or,IsString,AbsN,UnFence,LocalSymbols,GreaterThan,Retract,=,UnList,Hold,Equals,IsFunction,Listify,Head,Nth,MathNth,Type,Prog,And,NotEquals,Local,Tail,DefLoadFunction,Not,IsInteger,Set,String,Length,If,List,MakeVector,IsList,LessThan,While,DestructiveReverse,MacroSet,Eval,DestructiveInsert,AddN,IsAtom,Atom,ConcatStrings", (b + c) * (d + e) /: {(x_IsAtom + _y)_(IsZero(0)) <- Echo(x,,,y)} );
%/mathpiper
%mathpiper_trace,preserve="false"
Result: True
. %/mathpiper_trace
%mathpiper,output="trace"
//(b + c) * (d + e) /: {(x_IsAtom + _y) <- Echo(x,,,y)};
Retract("LocProcessSingle",*);
40 # LocProcessSingle(pat_IsFunction <- _exp) <--
[
{ {pat[0],PatternCreate(pat,True)},exp };
];
//10 # LocProcessSingle({_pat,_post,_exp}) <-- { {pat[0],PatternCreate(pat,post)},exp };
//20 # LocProcessSingle({pat_IsFunction,_exp}) <-- { {pat[0],PatternCreate(pat,True)},exp };
//30 # LocProcessSingle({pat_IsAtom,_exp}) <-- { pat,exp };
//50 # LocProcessSingle(pat_IsAtom <- _exp) <-- { pat,exp };
TraceExcept("MacroLocal,ApplyPure,Apply,MapSingle,+,ForEach,*,++,>=,<=,:=,IsUniVar,IsNumber,IsNegativeNumber,For,IsInfinity,IsMatrix,IsNonObject,SubtractN,-,MathSign,IsGeneric,Or,IsString,AbsN,UnFence,LocalSymbols,GreaterThan,Retract,=,UnList,Hold,Equals,IsFunction,Listify,Head,Nth,MathNth,Type,Prog,And,NotEquals,Local,Tail,DefLoadFunction,Not,IsInteger,Set,String,Length,If,List,MakeVector,IsList,LessThan,While,DestructiveReverse,MacroSet,Eval,DestructiveInsert,AddN,IsAtom,Atom,ConcatStrings", (b + c) * (d + e) /: {(x_IsAtom + _y) <- Echo(x,,,y)} );
%/mathpiper
%mathpiper
E := A(x,y) + B(x,y,z);
F := Deriv(z) E;
G := ( Eval(F) /: { (Deriv(_var)(_w))_(IsFreeOf(var,w)) <- 0 } );
WriteString("E = "); Echo(E);
WriteString("F = "); Echo(F);
WriteString("G = "); Echo(G);
WriteString("G simplified = "); Echo(Simplify(G));
1 # (Deriv(_var)(_w))_(IsFreeOf(var,w)) <-- 0;
G := Eval(F) ;
WriteString("G = "); Echo(G);NewLine();
%/mathpiper
%output,preserve="false"
Result: True
Side Effects:
E = A(x,y)+B(x,y,z)
F = Deriv(z)B(x,y,z)
G = Deriv(z)B(x,y,z)
G simplified = Deriv(z)B(x,y,z)
G = Deriv(z)B(x,y,z)
. %/output
(x_IsBound + y_IsOdd) <- m1,
(x_IsBound + y_IsEven) <- m3,
%mathpiper
Hold((a + b) * (1 + 2) * (2 + 1) * (1/2 + c) * (3/4 + d) ) /:
{
(x_IsOdd + y_IsEven) <- m1,
(x_IsEven + y_IsOdd) <- m2,
(x_IsRational + y_IsAtom)_(Denominator(x) = 2) <- m3,
};
%/mathpiper
%output,preserve="false"
Result: (a+b)*m1*m2*m3*(3/4+d)
. %/output
%mathpiper
Hold( (b + c) * (d + 1) * (4 + d) ) /:
{
(x_IsBound + y_IsBound) <- m2,
};
%/mathpiper
%output,preserve="false"
Result: m2*m2*m2
. %/output
%mathpiper,output="trace"
//(b + c) * (d + e) /: {(x_IsAtom + y_IsAtom) <- m1};
functions := "MacroLocal,ApplyPure,Apply,MapSingle,+,ForEach,*,++,>=,<=,<,:=,IsUniVar,IsNumber,IsNegativeNumber,For,IsInfinity,IsMatrix,IsNonObject,SubtractN,-,MathSign,IsGeneric,Or,IsString,AbsN,UnFence,LocalSymbols,GreaterThan,Retract,=,UnList,Hold,Equals,IsFunction,Listify,Head,Nth,MathNth,Type,Prog,And,NotEquals,Local,Tail,DefLoadFunction,Not,IsInteger,Set,String,Length,If,List,MakeVector,IsList,LessThan,While,DestructiveReverse,MacroSet,Eval,DestructiveInsert,AddN,IsAtom,Atom,ConcatStrings";
TraceExcept(functions,(b + c) * (d + 1) * (4 + d) /:
{
(x_IsBound + y_IsBound) <- m2,
}
);
%/mathpiper
%mathpiper_trace,preserve="false"
Result: m2*m2*m2
Side Effects:
Enter<**** user rulebase>{(/:, (b+c)*(d+1)*(4+d)/:{x_IsBound+y_IsBound<-m2});
Enter<**** user rulebase>{(<-, x_IsBound+y_IsBound<-m2);
Arg(left -> x_IsBound+y_IsBound);
Arg(right -> m2);
Leave<**** user rulebase>}(x_IsBound+y_IsBound<-m2 -> x_IsBound+y_IsBound<-m2, Local variables: right -> m2, left -> (+ (_ x IsBound )(_ y IsBound ))m2, );
Arg(arg1 -> (b+c)*(d+1)*(d+4));
Arg(arg2 -> {x_IsBound+y_IsBound<-m2});
**** Rule in function (/:) matched: Precedence: 10, Parameters: arg1, arg2, Predicates: (Pattern) True, Variables: expression, patterns, Types: Variable, Variable, Body: [ Set(patterns, LocProcess(patterns)); MacroSubstitute(expression, "LocPredicate", "LocChange");]
Enter<**** user rulebase>{(LocProcess, LocProcess(patterns));
Arg(patterns -> {x_IsBound+y_IsBound<-m2});
**** Rule in function (LocProcess) matched: Precedence: 1025, Parameters: patterns, Predicates: None., Body: [ MapSingle("LocProcessSingle", patterns);]
Enter<**** user rulebase>{(LocProcessSingle, LocProcessSingle(x_IsBound+y_IsBound<-m2));
Enter<**** user rulebase>{(<-, x_IsBound+y_IsBound<-m2);
Arg(left -> x_IsBound+y_IsBound);
Arg(right -> m2);
Leave<**** user rulebase>}(x_IsBound+y_IsBound<-m2 -> x_IsBound+y_IsBound<-m2, Local variables: right -> m2, left -> (+ (_ x IsBound )(_ y IsBound ))m2, );
Arg(arg1 -> x_IsBound+y_IsBound<-m2);
**** Rule in function (LocProcessSingle) matched: Precedence: 40, Parameters: arg1, Predicates: (Pattern) IsFunction(pat), True, Variables: pat, exp, Types: Sublist, Body: [ Local(justPattern, postPredicate); If(Type(pat)="_", [ justPattern:=pat[1]; postPredicate:=pat[2];], [ justPattern:=pat; postPredicate:=True;]); {{justPattern[0], PatternCreate(justPattern, postPredicate)}, exp};]
Enter{(PatternCreate, PatternCreate(justPattern,postPredicate));
Arg(parameter1 -> x_IsBound+y_IsBound);
Arg(parameter2 -> True);
Leave}(PatternCreate(justPattern,postPredicate) -> Pattern, Local variables: postPredicate -> True, justPattern -> (+ (_ x IsBound )(_ y IsBound )), exp -> m2, pat -> (+ (_ x IsBound )(_ y IsBound ))m2, arg1 -> (<- (+ (_ x IsBound )(_ y IsBound ))m2 ), );
Leave<**** user rulebase>}(LocProcessSingle(x_IsBound+y_IsBound<-m2) -> {{+,Pattern},m2}, Local variables: exp -> m2, pat -> (+ (_ x IsBound )(_ y IsBound ))m2, arg1 -> (<- (+ (_ x IsBound )(_ y IsBound ))m2 ), );
Leave<**** user rulebase>}(LocProcess(patterns) -> {{{+,Pattern},m2}}, Local variables: patterns -> (List (<- (+ (_ x IsBound )(_ y IsBound ))m2 )), );
Enter<**** user rulebase>{(MacroSubstitute, MacroSubstitute(expression,LocPredicate,LocChange));
Arg(body -> (b+c)*(d+1)*(d+4));
Arg(predicate -> LocPredicate);
Arg(change -> LocChange);
**** Rule in function (MacroSubstitute) matched: Precedence: 1025, Parameters: body, predicate, change, Predicates: None., Body: [ `MacroSubstitute(Hold(@body));]
Enter{(`, `MacroSubstitute(Hold(@body)));
Arg(parameter1 -> MacroSubstitute(Hold(@body)));
Enter<**** user rulebase>{(MacroSubstitute, MacroSubstitute(Hold((b+c)*(d+1)*(d+4))));
Arg(body -> (b+c)*(d+1)*(d+4));
Enter{(`, `ApplyPure(predicate,{Hold(Hold(@body))}));
Arg(parameter1 -> ApplyPure(predicate,{Hold(Hold(@body))}));
Enter<**** user rulebase>{(LocPredicate, LocPredicate(Hold((b+c)*(d+1)*(d+4))));
Arg(arg1 -> (b+c)*(d+1)*(d+4));
**** Rule in function (LocPredicate) matched: Precedence: 10, Parameters: arg1, Predicates: (Pattern) IsFunction(exp), True, Variables: exp, Types: Variable, Body: [ Local(tr, result, head); tr:=patterns; result:=False; While(tr!={})[ Set(head, Head(Head(tr))); If(NotIsAtom(head)Andexp[0]=head[1]AndPatternMatches(head[2], exp), [ Set($LocResult12, Eval(Head(Tail(Head(tr))))); Set(result, True); Set(tr, {});], [ Set(tr, Tail(tr));]);]; result;]
Enter<**** user rulebase>{(!=, tr!={});
Arg(aLeft -> {{{+,Pattern},m2}});
Arg(aRight -> {});
**** Rule in function (!=) matched: Precedence: 1025, Parameters: aLeft, aRight, Predicates: None., Body: NotaLeft=aRight
Leave<**** user rulebase>}(tr!={} -> True, Local variables: aRight -> (List ), aLeft -> (List (List (List + [BuiltinObject])m2 )), );
Enter<**** user rulebase>{(!=, tr!={});
Arg(aLeft -> {});
Arg(aRight -> {});
**** Rule in function (!=) matched: Precedence: 1025, Parameters: aLeft, aRight, Predicates: None., Body: NotaLeft=aRight
Leave<**** user rulebase>}(tr!={} -> False, Local variables: aRight -> (List ), aLeft -> (List ), );
Leave<**** user rulebase>}(LocPredicate(Hold((b+c)*(d+1)*(d+4))) -> False, Local variables: exp -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), arg1 -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), change -> "LocChange", predicate -> "LocPredicate", body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), patterns -> (List (List (List + [BuiltinObject])m2 )), expression -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), arg2 -> (List (<- (+ (_ x IsBound )(_ y IsBound ))m2 )), arg1 -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), );
Leave}(`ApplyPure(predicate,{Hold(Hold(@body))}) -> False, Local variables: body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), change -> "LocChange", predicate -> "LocPredicate", body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), patterns -> (List (List (List + [BuiltinObject])m2 )), expression -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), arg2 -> (List (<- (+ (_ x IsBound )(_ y IsBound ))m2 )), arg1 -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), );
Enter{(`, `IsFunction(Hold(@body)));
Arg(parameter1 -> IsFunction(Hold(@body)));
Leave}(`IsFunction(Hold(@body)) -> True, Local variables: body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), change -> "LocChange", predicate -> "LocPredicate", body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), patterns -> (List (List (List + [BuiltinObject])m2 )), expression -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), arg2 -> (List (<- (+ (_ x IsBound )(_ y IsBound ))m2 )), arg1 -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), );
**** Rule in function (MacroSubstitute) matched: Precedence: 2, Parameters: body, Predicates: `IsFunction(Hold(@body)), Body: [ `ApplyPure("MacroMapArgs", {Hold(Hold(@body)), "MacroSubstitute"});]
Enter{(`, `ApplyPure(MacroMapArgs,{Hold(Hold(@body)),MacroSubstitute}));
Arg(parameter1 -> ApplyPure(MacroMapArgs,{Hold(Hold(@body)),MacroSubstitute}));
Enter{(MacroMapArgs, MacroMapArgs(Hold((b+c)*(d+1)*(d+4)),MacroSubstitute));
Arg(expr -> Hold((b+c)*(d+1)*(d+4)));
Arg(oper -> MacroSubstitute);
**** Rule in function (MacroMapArgs) matched: Precedence: 1025, Parameters: expr, oper, Predicates: None., Body: [ Local(ex, tl, op); Set(op, @oper); Set(ex, Listify(@expr)); Set(tl, Tail(ex)); UnList(Concat({ex[1]}, `MacroMapSingle(@op, Hold(@tl))));], Substituted Macro Body: [ Local(ex,tl,op); Set(op,"MacroSubstitute"); Set(ex,Listify(Hold((b+c)*(d+1)*(d+4)))); Set(tl,Tail(ex)); UnList(Concat({ex[1]},`MacroMapSingle(@op,Hold(@tl))));]
Enter{(Concat, Concat({ex[1]},`MacroMapSingle(@op,Hold(@tl))));
Enter{(`, `MacroMapSingle(@op,Hold(@tl)));
Arg(parameter1 -> MacroMapSingle(@op,Hold(@tl)));
Enter<**** user rulebase>{(MacroMapSingle, MacroMapSingle(MacroSubstitute,Hold({(b+c)*(d+1),d+4})));
Arg($func15 -> MacroSubstitute);
Arg($list15 -> {(b+c)*(d+1),d+4});
**** Rule in function (MacroMapSingle) matched: Precedence: 1025, Parameters: $func15, $list15, Predicates: None., Body: [ Local(mapsingleresult); mapsingleresult:={}; ForEach(mapsingleitem, $list15)[ DestructiveInsert(mapsingleresult, 1, `ApplyPure($func15, {Hold(Hold(@mapsingleitem))}));]; DestructiveReverse(mapsingleresult);]
Enter{(`, `ApplyPure($func15,{Hold(Hold(@mapsingleitem))}));
Arg(parameter1 -> ApplyPure($func15,{Hold(Hold(@mapsingleitem))}));
Enter<**** user rulebase>{(MacroSubstitute, MacroSubstitute(Hold((b+c)*(d+1))));
Arg(body -> (b+c)*(d+1));
Enter{(`, `ApplyPure(predicate,{Hold(Hold(@body))}));
Arg(parameter1 -> ApplyPure(predicate,{Hold(Hold(@body))}));
Enter<**** user rulebase>{(LocPredicate, LocPredicate(Hold((b+c)*(d+1))));
Arg(arg1 -> (b+c)*(d+1));
**** Rule in function (LocPredicate) matched: Precedence: 10, Parameters: arg1, Predicates: (Pattern) IsFunction(exp), True, Variables: exp, Types: Variable, Body: [ Local(tr, result, head); tr:=patterns; result:=False; While(tr!={})[ Set(head, Head(Head(tr))); If(NotIsAtom(head)Andexp[0]=head[1]AndPatternMatches(head[2], exp), [ Set($LocResult12, Eval(Head(Tail(Head(tr))))); Set(result, True); Set(tr, {});], [ Set(tr, Tail(tr));]);]; result;]
Enter<**** user rulebase>{(!=, tr!={});
Arg(aLeft -> {{{+,Pattern},m2}});
Arg(aRight -> {});
**** Rule in function (!=) matched: Precedence: 1025, Parameters: aLeft, aRight, Predicates: None., Body: NotaLeft=aRight
Leave<**** user rulebase>}(tr!={} -> True, Local variables: aRight -> (List ), aLeft -> (List (List (List + [BuiltinObject])m2 )), );
Enter<**** user rulebase>{(!=, tr!={});
Arg(aLeft -> {});
Arg(aRight -> {});
**** Rule in function (!=) matched: Precedence: 1025, Parameters: aLeft, aRight, Predicates: None., Body: NotaLeft=aRight
Leave<**** user rulebase>}(tr!={} -> False, Local variables: aRight -> (List ), aLeft -> (List ), );
Leave<**** user rulebase>}(LocPredicate(Hold((b+c)*(d+1))) -> False, Local variables: exp -> (* (+ b c )(+ d 1 )), arg1 -> (* (+ b c )(+ d 1 )), body -> (* (+ b c )(+ d 1 )), mapsingleitem -> (* (+ b c )(+ d 1 )), foreachtail -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), $body22 -> (Prog (DestructiveInsert mapsingleresult 1 (` (ApplyPure $func15 (List (Hold (Hold (@ mapsingleitem )))))))), $list22 -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), $item22 -> mapsingleitem, mapsingleresult -> (List ), $list15 -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), $func15 -> "MacroSubstitute", op -> "MacroSubstitute", tl -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), ex -> (List * (* (+ b c )(+ d 1 ))(+ d 4 )), body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), change -> "LocChange", predicate -> "LocPredicate", body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), patterns -> (List (List (List + [BuiltinObject])m2 )), expression -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), arg2 -> (List (<- (+ (_ x IsBound )(_ y IsBound ))m2 )), arg1 -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), );
Leave}(`ApplyPure(predicate,{Hold(Hold(@body))}) -> False, Local variables: body -> (* (+ b c )(+ d 1 )), mapsingleitem -> (* (+ b c )(+ d 1 )), foreachtail -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), $body22 -> (Prog (DestructiveInsert mapsingleresult 1 (` (ApplyPure $func15 (List (Hold (Hold (@ mapsingleitem )))))))), $list22 -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), $item22 -> mapsingleitem, mapsingleresult -> (List ), $list15 -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), $func15 -> "MacroSubstitute", op -> "MacroSubstitute", tl -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), ex -> (List * (* (+ b c )(+ d 1 ))(+ d 4 )), body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), change -> "LocChange", predicate -> "LocPredicate", body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), patterns -> (List (List (List + [BuiltinObject])m2 )), expression -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), arg2 -> (List (<- (+ (_ x IsBound )(_ y IsBound ))m2 )), arg1 -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), );
Enter{(`, `IsFunction(Hold(@body)));
Arg(parameter1 -> IsFunction(Hold(@body)));
Leave}(`IsFunction(Hold(@body)) -> True, Local variables: body -> (* (+ b c )(+ d 1 )), mapsingleitem -> (* (+ b c )(+ d 1 )), foreachtail -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), $body22 -> (Prog (DestructiveInsert mapsingleresult 1 (` (ApplyPure $func15 (List (Hold (Hold (@ mapsingleitem )))))))), $list22 -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), $item22 -> mapsingleitem, mapsingleresult -> (List ), $list15 -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), $func15 -> "MacroSubstitute", op -> "MacroSubstitute", tl -> (List (* (+ b c )(+ d 1 ))(+ d 4 )), ex -> (List * (* (+ b c )(+ d 1 ))(+ d 4 )), body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), change -> "LocChange", predicate -> "LocPredicate", body -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), patterns -> (List (List (List + [BuiltinObject])m2 )), expression -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), arg2 -> (List (<- (+ (_ x IsBound )(_ y IsBound ))m2 )), arg1 -> (* (* (+ b c )(+ d 1 ))(+ d 4 )), );
**** Rule in function (MacroSubstitute) matched: Precedence: 2, Parameters: body, Predicates: `IsFunction(Hold(@body)), Body: [ `ApplyPure("MacroMapArgs", {Hold(Hold(@body)), "MacroSubstitute"});]
Enter{(`, `ApplyPure(MacroMapArgs,{Hold(Hold(@body)),MacroSubstitute}));
Arg(parameter1 -> ApplyPure(MacroMapArgs,{Hold(Hold(@body)),MacroSubstitute}));
Enter{(MacroMapArgs, MacroMapArgs(Hold((b+c)*(d+1)),MacroSubstitute));
Arg(expr -> Hold((b+c)*(d+1)));
Arg(oper -> MacroSubstitute);
**** Rule in function (MacroMapArgs) matched: Precedence: 1025, Parameters: expr, oper, Predicates: None., Body: [ Local(ex, tl, op); Set(op, @oper); Set(ex, Listify(@expr)); Set(tl, Tail(ex)); UnList(Concat({ex[1]}, `MacroMapSingle(@op, Hold(@tl))));], Substituted Macro Body: [ Local(ex,tl,op); Set(op,"MacroSubstitute"); Set(ex,Listify(Hold((b+c)*(d+1)))); Set(tl,Tail(ex)); UnList(Concat({ex[1]},`MacroMapSingle(@op,Hold(@tl))));]
Enter{(Concat, Concat({ex[1]},`MacroMapSingle(@op,Hold(@tl))));
Enter{(`, `MacroMapSingle(@op,Hold(@tl)));
Arg(parameter1 -> MacroMapSingle(@op,Hold(@tl)));
Enter<**** user rulebase>{(MacroMapSingle, MacroMapSingle(MacroSubstitute,Hold({b+c,d+1})));
Arg($func15 -> MacroSubstitute);
Arg($list15 -> {b+c,d+1});
**** Rule in function (MacroMapSingle) matched: Precedence: 1025, Parameters: $func15, $list15, Predicates: None., Body: [ Local(mapsingleresult); mapsingleresult:={}; ForEach(mapsingleitem, $list15)[ DestructiveInsert(mapsingleresult, 1, `ApplyPure($func15, {Hold(Hold(@mapsingleitem))}));]; DestructiveReverse(mapsingleresult);]
Enter{(`, `ApplyPure($func15,{Hold(Hold(@mapsingleitem))}));
Arg(parameter1 -> ApplyPure($func15,{Hold(Hold(@mapsingleitem))}));
Enter<**** user rulebase>{(MacroSubstitute, MacroSubstitute(Hold(b+c)));
Arg(body -> b+c);
Enter