Thomas Dean

227 Reputation

10 Badges

16 years, 132 days

MaplePrimes Activity


These are questions asked by Thomas Dean

I want to substitute the solution back into the original equation.  I get caught up in RootOf and have to manually do the substitutions.

F := [x^2+y+z-1, y^2+x+z-1, z^2+x+y-1];

soln1 := solve(F);

for s in soln1 do

subs(s,F)

end do;

The 4th soln has RootOf.

soln2 := solve(_Z^2 + 2*_Z - 1);

for s in soln2 do

evala(subs({x=s,y=s,z=s},F))

end do;

How do I do this all in one step?

Fsolve produces the correct solution.  solve followed by evalf produces a completely different solution.

What am I doing wrong?

## Ioannes Colla problem: "Divide 10 into three parts such that they
## shall be in continued proportion and that the product of the first
## two shall be 6"
eqs := [a+b+c=10, a/b=b/c, a*b=6];
fsolve(eqs); ## correct solution
evalf(solve(eqs)); ## different

Tom Dean

I tried the example in BodePlot help.

restart;
with(DynamicSystems):
sys := TransferFunction( 1/(s-10) ):
BodePlot(sys);


That works OK. But, if I invoke Syrup, the example no longer works.

restart;
with(Syrup);
with(DynamicSystems):
ckt := [V, Rsrc(50), C1(15e-9), L1(15e-6), C2(22e-9), L2(15e-6), C3(22e-9), L3(15e-6), C4(15e-9), 1, Rload(50)];

TF := subs(other, V=1, v[Rload]);
sys := TransferFunction(TF);

BodePlot(sys);
I get a message "not a valid plot structure".  OK, try the example, again.

sys := TransferFunction( 1/(s-10) ):
BodePlot(sys);
I also get the "not a valid plot structure" message.

What am I doing wrong?

This started as calculating the location of a machine tool bit that is tangent to a line and a circle.  I watched the part being made.  The machinist moved the tool bit manually until it touched straight and circular markings on a aluminum blank.  Repeating this two times, recording the x-y values, the g-code was altered and the CNC machine started to make the part.  Should be a simple calculation, right?

Well, not for me:

restart; with(geometry):
## Find the (x, y) location of a machine mill path such that the tool is
## tangent to a line and a circle.
##
## Given a line, L1, and a circle, C1, find a circle, C4 tangent to
## both L1 and C1.  Choose the X value of C4 to be such that the
## center of C4 is between the intersection of L1 with the X axis and
## origin.
x0 := (3+1/2)/2;
x1 := x0; y1 := x0 + (1+1/4);
point('P1', x1, y1); ## center of the circle

circle('C2', [P1, x0]);

## X value for line L1
x3 := (3+1/2)/2-(3/4+20/1000)/2-1/2; y3 := 1+1/4; evalf([x3, y3]);
## points P2 and P3 lie on the line
point('P2', x3, 0); point('P3', x3, y3);
line('L1', [P2, P3]);

intersection('I1', L1, C2);
for s in I1 do print(evalf(coordinates(s))) end do;

tr := 1/8;  ## tool radius, radius of C4
## find P4 such that C4 is tangent to L1
x4 := x3 - tr;
## P4 moves parallel to L1
point('P4', x4, 'y4');
circle('C4', [P4, tr]);
Equation(C4); Equation(C2);
intersection('I2', C2, C4);
## fails

## The centerline of the part is at x = (3+1/2)/2 Another dimension of
## the part, is (3/4+20/1000), centered on the centerline.  A second
## dimension of the part is 1/2.  From the physical layout of the
## part, observe that
x_value := (3+1/2)/2 - (3/4+20/1000)/2 - 1/2 - tr: evalf(%);
eq1 := subs(x = x_value, Equation(C4)); eq2 := subs(x = x_value, Equation(C2));
sol := solve([eq1, eq2]); evalf(%);
evalf(sol);

## want the solution with the least y value for point P4
res1 := subs(sol[1], coordinates(P4));
res2 := subs(sol[2], coordinates(P4));

if evalf(res1[2]) < evalf(res2[2]) then
    soln := res1;
else
    soln := res2;
end if;
evalf(soln);

point('P8', soln); evalf(coordinates(P8));
circle('C8', [P8, 1/8]); evalf(Equation(C8)); evalf(Equation(C2));
## the intersect fails  Why?

intersection('I8', C2, C8);

evalf(coordinates(I8[1])); evalf(coordinates(I8[2]));

solve([Equation(C2), Equation(C8)]); evalf(%);
print("The location is", evalf(soln));

 

I was working through some example problems and came across this statement.  Actually comparing Sympy results to Maple. (I prefer Maple).

"Calculate the volume integral of f(...) over the sphere of radius r"

I can solve the problem, but, got hung up on the exact meaning of the problem statement.

Tom Dean

restart
with(VectorCalculus):
with(LinearAlgebra):

## http://www.acme.byu.edu/wp-content/uploads/2017/08/Sympy.pdf
## Problem 7

f := proc(x, y, z)
    (x^2 + y^2 + z^2)^2
end proc;

(M, d) := Jacobian([rho*sin(phi)*cos(theta),
                    rho*sin(phi)*sin(theta),
                    rho*cos(phi)],
                   [rho, phi, theta],
                   'determinant' );
abs(d);
simplify(%);

eqn := f(rho*sin(phi)*cos(theta), rho*sin(phi)*sin(theta), rho*cos(phi));
eqn := eqn * abs(simplify(d));

soln := int(eqn,[rho=0..r,theta=0..2*Pi,phi=0..Pi]);
subs(r=3, soln);

 

3 4 5 6 7 8 9 Page 5 of 11