## 297 Reputation

18 years, 172 days

## Strange Result from Solve...

Maple 2018

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

## Strange Behavior of DynamicSystems[BodeP...

Maple

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)];

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?

## Intersection of a line and two circles...

Maple

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;

## 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, coordinates(P4));
res2 := subs(sol, coordinates(P4));

if evalf(res1) < evalf(res2) 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)); evalf(coordinates(I8));

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

## What is the meaning of "Calculate the vo...

Maple

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):

## 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);

## Syrup problem for band-pass filter...

Maple 2016

I am attempting to reproduce the results claimed by analog.com for a band pass filter.

I have checked the circuit specification and found no errors.

Am I expecting too much or am I doing something wrong?

## www.analog.com/designtools/en/filterwizard/
## Filter Requirements for Band-Pass, 4th order Butterworth
## Specifications: Optimize for Power, +Vs= 5, -Vs= -5
## Gain: 10 dB
## Passband: -3dB at 2kHz
## Stopband: -40dB at 40kHz
## Component Tolerances: Capacitor = 5%; Resistor = 1%; Inductor = 5%; Op Amp GBW = 20%

restart;
with(Syrup); Version;
with(DynamicSystems):

ckt := "*60 kHz Band Pass Filter  \n\
vin 1   0 \n\
R1A 1   2 165k \n\
R1B 5   7 169k \n\
R2A 2   0 976 \n\
R2B 7   0 1k \n\
R3A 6   0 221 \n\
R3B 11  0 226 \n\
R4A 5   6 12.7k \n\
R4B 10 11 12.7k \n\
R5A 4   3 97.6k \n\
R5B 9   8 100k \n\
R98 3   0 1e9 \n\
R99 8   0 1e9 \n\
C1A 2   4 270pF \n\
C1B 7   9 270pF \n\
C2A 2   3 270pF \n\
C2B 7   8 270pF \n\
* \n\
X1A 6  3 5  NonIdealOpAmp \n\
X1B 11 8 10 NonIdealOpAmp \n\
.include Library:-NonIdealOpAmp \n\
.end";

volts, others := Solve(ckt, 'ac', 'returnall');
gain := eval(v/vin, volts);
H := subs({A=80000, f0=15*10^6, Ro=100}, gain);
evalf(H);
tf := evalf(H);
sys := TransferFunction(tf);
PrintSystem(sys);
plotsetup(maplet);
MagnitudePlot(sys);

﻿